/[gentoo-projects]/pax-utils/scanelf.c
Gentoo

Diff of /pax-utils/scanelf.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.107 Revision 1.108
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.107 2006/01/18 22:28:46 solar Exp $ 4 * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.108 2006/01/19 23:53:34 vapier 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
12static const char *rcsid = "$Id: scanelf.c,v 1.107 2006/01/18 22:28:46 solar Exp $"; 12static const char *rcsid = "$Id: scanelf.c,v 1.108 2006/01/19 23:53:34 vapier 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
152 152
153 shown = 0; 153 shown = 0;
154 multi_stack = multi_relro = multi_load = 0; 154 multi_stack = multi_relro = multi_load = 0;
155 max_pt_load = elf_max_pt_load(elf); 155 max_pt_load = elf_max_pt_load(elf);
156 156
157#define NOTE_GNU_STACK ".note.GNU-stack"
157#define SHOW_PHDR(B) \ 158#define SHOW_PHDR(B) \
158 if (elf->elf_class == ELFCLASS ## B) { \ 159 if (elf->elf_class == ELFCLASS ## B) { \
159 Elf ## B ## _Ehdr *ehdr = EHDR ## B (elf->ehdr); \ 160 Elf ## B ## _Ehdr *ehdr = EHDR ## B (elf->ehdr); \
160 Elf ## B ## _Off offset; \ 161 Elf ## B ## _Off offset; \
161 uint32_t flags, check_flags; \ 162 uint32_t flags, check_flags; \
193 } \ 194 } \
194 } else if (elf->shdr != NULL) { \ 195 } else if (elf->shdr != NULL) { \
195 /* no program headers which means this is prob an object file */ \ 196 /* no program headers which means this is prob an object file */ \
196 Elf ## B ## _Shdr *shdr = SHDR ## B (elf->shdr); \ 197 Elf ## B ## _Shdr *shdr = SHDR ## B (elf->shdr); \
197 Elf ## B ## _Shdr *strtbl = shdr + EGET(ehdr->e_shstrndx); \ 198 Elf ## B ## _Shdr *strtbl = shdr + EGET(ehdr->e_shstrndx); \
199 char *str; \
200 if ((void*)strtbl > (void*)(elf->data + sizeof(*strtbl))) \
201 goto skip_this_shdr##B; \
198 check_flags = SHF_WRITE|SHF_EXECINSTR; \ 202 check_flags = SHF_WRITE|SHF_EXECINSTR; \
199 for (i = 0; i < EGET(ehdr->e_shnum); ++i) { \ 203 for (i = 0; i < EGET(ehdr->e_shnum); ++i) { \
200 if (EGET(shdr[i].sh_type) != SHT_PROGBITS) continue; \ 204 if (EGET(shdr[i].sh_type) != SHT_PROGBITS) continue; \
201 offset = EGET(strtbl->sh_offset) + EGET(shdr[i].sh_name); \ 205 offset = EGET(strtbl->sh_offset) + EGET(shdr[i].sh_name); \
202 if (!strcmp((char*)(elf->data + offset), ".note.GNU-stack")) { \ 206 str = elf->data + offset; \
207 if (str > elf->data + offset + sizeof(NOTE_GNU_STACK)) continue; \
208 if (!strcmp(str, NOTE_GNU_STACK)) { \
203 if (multi_stack++) warnf("%s: multiple .note.GNU-stack's !?", elf->filename); \ 209 if (multi_stack++) warnf("%s: multiple .note.GNU-stack's !?", elf->filename); \
204 flags = EGET(shdr[i].sh_flags); \ 210 flags = EGET(shdr[i].sh_flags); \
205 if (be_quiet && ((flags & check_flags) != check_flags)) \ 211 if (be_quiet && ((flags & check_flags) != check_flags)) \
206 continue; \ 212 continue; \
207 ++*found_phdr; \ 213 ++*found_phdr; \
211 if (flags & SHF_EXECINSTR) ret[2] = 'X'; \ 217 if (flags & SHF_EXECINSTR) ret[2] = 'X'; \
212 if (flags & 0xFFFFFFF8) warn("Invalid section flags for GNU-stack"); \ 218 if (flags & 0xFFFFFFF8) warn("Invalid section flags for GNU-stack"); \
213 break; \ 219 break; \
214 } \ 220 } \
215 } \ 221 } \
222 skip_this_shdr##B: \
216 if (!multi_stack) { \ 223 if (!multi_stack) { \
217 *found_phdr = 1; \ 224 *found_phdr = 1; \
218 shown = 1; \ 225 shown = 1; \
219 memcpy(ret, "!WX", 3); \ 226 memcpy(ret, "!WX", 3); \
220 } \ 227 } \

Legend:
Removed from v.1.107  
changed lines
  Added in v.1.108

  ViewVC Help
Powered by ViewVC 1.1.20