/[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.270 Revision 1.271
1/* 1/*
2 * Copyright 2003-2012 Gentoo Foundation 2 * Copyright 2003-2012 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/Attic/scanelf.c,v 1.270 2015/02/21 19:30:59 vapier Exp $ 4 * $Header: /var/cvsroot/gentoo-projects/pax-utils/Attic/scanelf.c,v 1.271 2015/02/22 00:10:27 vapier Exp $
5 * 5 *
6 * Copyright 2003-2012 Ned Ludd - <solar@gentoo.org> 6 * Copyright 2003-2012 Ned Ludd - <solar@gentoo.org>
7 * Copyright 2004-2012 Mike Frysinger - <vapier@gentoo.org> 7 * Copyright 2004-2012 Mike Frysinger - <vapier@gentoo.org>
8 */ 8 */
9 9
10static const char rcsid[] = "$Id: scanelf.c,v 1.270 2015/02/21 19:30:59 vapier Exp $"; 10static const char rcsid[] = "$Id: scanelf.c,v 1.271 2015/02/22 00:10:27 vapier Exp $";
11const char argv0[] = "scanelf"; 11const char 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 == '+')
429 } \ 429 } \
430 } else if (elf->shdr != NULL) { \ 430 } else if (elf->shdr != NULL) { \
431 /* no program headers which means this is prob an object file */ \ 431 /* no program headers which means this is prob an object file */ \
432 Elf ## B ## _Shdr *shdr = SHDR ## B (elf->shdr); \ 432 Elf ## B ## _Shdr *shdr = SHDR ## B (elf->shdr); \
433 Elf ## B ## _Shdr *strtbl = shdr + EGET(ehdr->e_shstrndx); \ 433 Elf ## B ## _Shdr *strtbl = shdr + EGET(ehdr->e_shstrndx); \
434 char *str; \
435 if ((void*)strtbl > elf->data_end) \ 434 if ((void*)strtbl > elf->data_end) \
436 goto skip_this_shdr##B; \ 435 goto skip_this_shdr##B; \
437 /* let's flag -w/+x object files since the final ELF will most likely \ 436 /* let's flag -w/+x object files since the final ELF will most likely \
438 * need write access to the stack (who doesn't !?). so the combined \ 437 * need write access to the stack (who doesn't !?). so the combined \
439 * output will bring in +w automatically and that's bad. \ 438 * output will bring in +w automatically and that's bad. \
440 */ \ 439 */ \
441 check_flags = /*SHF_WRITE|*/SHF_EXECINSTR; \ 440 check_flags = /*SHF_WRITE|*/SHF_EXECINSTR; \
442 for (i = 0; i < EGET(ehdr->e_shnum); ++i) { \ 441 for (i = 0; i < EGET(ehdr->e_shnum); ++i) { \
443 if (EGET(shdr[i].sh_type) != SHT_PROGBITS) continue; \ 442 if (EGET(shdr[i].sh_type) != SHT_PROGBITS) continue; \
444 offset = EGET(strtbl->sh_offset) + EGET(shdr[i].sh_name); \ 443 offset = EGET(strtbl->sh_offset) + EGET(shdr[i].sh_name); \
445 str = elf->data + offset; \ 444 if (offset >= elf->len - sizeof(NOTE_GNU_STACK)) \
446 if (str + sizeof(NOTE_GNU_STACK) > elf->data + elf->len) continue; \ 445 continue; \
447 if (!strcmp(str, NOTE_GNU_STACK)) { \ 446 if (!strcmp(elf->data + offset, NOTE_GNU_STACK)) { \
448 if (multi_stack++) warnf("%s: multiple .note.GNU-stack's !?", elf->filename); \ 447 if (multi_stack++) warnf("%s: multiple .note.GNU-stack's !?", elf->filename); \
449 flags = EGET(shdr[i].sh_flags); \ 448 flags = EGET(shdr[i].sh_flags); \
450 if (be_quiet && ((flags & check_flags) != check_flags)) \ 449 if (be_quiet && ((flags & check_flags) != check_flags)) \
451 continue; \ 450 continue; \
452 ++*found_phdr; \ 451 ++*found_phdr; \

Legend:
Removed from v.1.270  
changed lines
  Added in v.1.271

  ViewVC Help
Powered by ViewVC 1.1.20