| 1 | /* |
1 | /* |
| 2 | * Copyright 2003-2007 Gentoo Foundation |
2 | * Copyright 2003-2007 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.187 2007/08/25 02:46:18 vapier Exp $ |
4 | * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.188 2007/08/31 17:45:24 solar Exp $ |
| 5 | * |
5 | * |
| 6 | * Copyright 2003-2007 Ned Ludd - <solar@gentoo.org> |
6 | * Copyright 2003-2007 Ned Ludd - <solar@gentoo.org> |
| 7 | * Copyright 2004-2007 Mike Frysinger - <vapier@gentoo.org> |
7 | * Copyright 2004-2007 Mike Frysinger - <vapier@gentoo.org> |
| 8 | */ |
8 | */ |
| 9 | |
9 | |
| 10 | static const char *rcsid = "$Id: scanelf.c,v 1.187 2007/08/25 02:46:18 vapier Exp $"; |
10 | static const char *rcsid = "$Id: scanelf.c,v 1.188 2007/08/31 17:45:24 solar Exp $"; |
| 11 | const char * const argv0 = "scanelf"; |
11 | const char * const argv0 = "scanelf"; |
| 12 | |
12 | |
| 13 | #include "paxinc.h" |
13 | #include "paxinc.h" |
| 14 | |
14 | |
| 15 | #define IS_MODIFIER(c) (c == '%' || c == '#' || c == '+') |
15 | #define IS_MODIFIER(c) (c == '%' || c == '#' || c == '+') |
| … | |
… | |
| 266 | warnf("%s: multiple PT_GNU_RELRO's !?", elf->filename); \ |
266 | warnf("%s: multiple PT_GNU_RELRO's !?", elf->filename); \ |
| 267 | found = found_relro; \ |
267 | found = found_relro; \ |
| 268 | offset = 4; \ |
268 | offset = 4; \ |
| 269 | check_flags = PF_X; \ |
269 | check_flags = PF_X; \ |
| 270 | } else if (EGET(phdr[i].p_type) == PT_LOAD) { \ |
270 | } else if (EGET(phdr[i].p_type) == PT_LOAD) { \ |
| 271 | if (ehdr->e_type == ET_DYN || ehdr->e_type == ET_EXEC) \ |
271 | if (EGET(ehdr->e_type) == ET_DYN || EGET(ehdr->e_type) == ET_EXEC) \ |
| 272 | if (multi_load++ > max_pt_load) \ |
272 | if (multi_load++ > max_pt_load) \ |
| 273 | warnf("%s: more than %i PT_LOAD's !?", elf->filename, max_pt_load); \ |
273 | warnf("%s: more than %i PT_LOAD's !?", elf->filename, max_pt_load); \ |
| 274 | if (file_matches_list(elf->filename, qa_wx_load)) \ |
274 | if (file_matches_list(elf->filename, qa_wx_load)) \ |
| 275 | continue; \ |
275 | continue; \ |
| 276 | found = found_load; \ |
276 | found = found_load; \ |
| … | |
… | |
| 944 | Elf ## B ## _Ehdr *ehdr = EHDR ## B (elf->ehdr); \ |
944 | Elf ## B ## _Ehdr *ehdr = EHDR ## B (elf->ehdr); \ |
| 945 | Elf ## B ## _Phdr *phdr = PHDR ## B (elf->phdr); \ |
945 | Elf ## B ## _Phdr *phdr = PHDR ## B (elf->phdr); \ |
| 946 | Elf ## B ## _Shdr *strtbl = SHDR ## B (strtbl_void); \ |
946 | Elf ## B ## _Shdr *strtbl = SHDR ## B (strtbl_void); \ |
| 947 | Elf ## B ## _Off offset; \ |
947 | Elf ## B ## _Off offset; \ |
| 948 | /* only look for soname in shared objects */ \ |
948 | /* only look for soname in shared objects */ \ |
| 949 | if (ehdr->e_type != ET_DYN) \ |
949 | if (EGET(ehdr->e_type) != ET_DYN) \ |
| 950 | return NULL; \ |
950 | return NULL; \ |
| 951 | for (i = 0; i < EGET(ehdr->e_phnum); i++) { \ |
951 | for (i = 0; i < EGET(ehdr->e_phnum); i++) { \ |
| 952 | if (EGET(phdr[i].p_type) != PT_DYNAMIC || EGET(phdr[i].p_filesz) == 0) continue; \ |
952 | if (EGET(phdr[i].p_type) != PT_DYNAMIC || EGET(phdr[i].p_filesz) == 0) continue; \ |
| 953 | offset = EGET(phdr[i].p_offset); \ |
953 | offset = EGET(phdr[i].p_offset); \ |
| 954 | if (offset >= elf->len - sizeof(Elf ## B ## _Dyn)) continue; \ |
954 | if (offset >= elf->len - sizeof(Elf ## B ## _Dyn)) continue; \ |