| 1 | /* |
1 | /* |
| 2 | * Copyright 2003-2006 Gentoo Foundation |
2 | * Copyright 2003-2006 Gentoo Foundation |
| 3 | * Distributed under the terms of the GNU General Public License v2 |
3 | * Distributed under the terms of the GNU General Public License v2 |
| 4 | * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.129 2006/02/18 15:51:11 solar Exp $ |
4 | * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.130 2006/02/21 00:31:53 solar Exp $ |
| 5 | * |
5 | * |
| 6 | * Copyright 2003-2006 Ned Ludd - <solar@gentoo.org> |
6 | * Copyright 2003-2006 Ned Ludd - <solar@gentoo.org> |
| 7 | * Copyright 2004-2006 Mike Frysinger - <vapier@gentoo.org> |
7 | * Copyright 2004-2006 Mike Frysinger - <vapier@gentoo.org> |
| 8 | */ |
8 | */ |
| 9 | |
9 | |
| 10 | #include "paxinc.h" |
10 | #include "paxinc.h" |
| 11 | |
11 | |
| 12 | static const char *rcsid = "$Id: scanelf.c,v 1.129 2006/02/18 15:51:11 solar Exp $"; |
12 | static const char *rcsid = "$Id: scanelf.c,v 1.130 2006/02/21 00:31:53 solar Exp $"; |
| 13 | #define argv0 "scanelf" |
13 | #define argv0 "scanelf" |
| 14 | |
14 | |
| 15 | #define IS_MODIFIER(c) (c == '%' || c == '#') |
15 | #define IS_MODIFIER(c) (c == '%' || c == '#') |
| 16 | |
16 | |
| 17 | |
17 | |
| … | |
… | |
| 202 | } else \ |
202 | } else \ |
| 203 | continue; \ |
203 | continue; \ |
| 204 | flags = EGET(phdr[i].p_flags); \ |
204 | flags = EGET(phdr[i].p_flags); \ |
| 205 | if (be_quiet && ((flags & check_flags) != check_flags)) \ |
205 | if (be_quiet && ((flags & check_flags) != check_flags)) \ |
| 206 | continue; \ |
206 | continue; \ |
| 207 | if (fix_elf && ((flags & PF_X) != flags)) { \ |
207 | if ((EGET(phdr[i].p_type) != PT_LOAD) && (fix_elf && ((flags & PF_X) != flags))) { \ |
| 208 | ESET(phdr[i].p_flags, flags & (PF_X ^ (size_t)-1)); \ |
208 | ESET(phdr[i].p_flags, flags & (PF_X ^ (size_t)-1)); \ |
| 209 | ret[3] = ret[7] = '!'; \ |
209 | ret[3] = ret[7] = '!'; \ |
| 210 | flags = EGET(phdr[i].p_flags); \ |
210 | flags = EGET(phdr[i].p_flags); \ |
| 211 | } \ |
211 | } \ |
| 212 | memcpy(ret+offset, gnu_short_stack_flags(flags), 3); \ |
212 | memcpy(ret+offset, gnu_short_stack_flags(flags), 3); \ |