/[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.184 Revision 1.185
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.184 2007/08/12 16:35:25 vapier Exp $ 4 * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.185 2007/08/18 04:59:32 vapier 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#include "paxinc.h" 10#include "paxinc.h"
11 11
12static const char *rcsid = "$Id: scanelf.c,v 1.184 2007/08/12 16:35:25 vapier Exp $"; 12static const char *rcsid = "$Id: scanelf.c,v 1.185 2007/08/18 04:59:32 vapier Exp $";
13#define argv0 "scanelf" 13#define argv0 "scanelf"
14 14
15#define IS_MODIFIER(c) (c == '%' || c == '#' || c == '+') 15#define IS_MODIFIER(c) (c == '%' || c == '#' || c == '+')
16 16
17/* prototypes */ 17/* prototypes */
356 Elf ## B ## _Dyn *dyn; \ 356 Elf ## B ## _Dyn *dyn; \
357 Elf ## B ## _Ehdr *ehdr = EHDR ## B (elf->ehdr); \ 357 Elf ## B ## _Ehdr *ehdr = EHDR ## B (elf->ehdr); \
358 Elf ## B ## _Phdr *phdr = PHDR ## B (elf->phdr); \ 358 Elf ## B ## _Phdr *phdr = PHDR ## B (elf->phdr); \
359 Elf ## B ## _Off offset; \ 359 Elf ## B ## _Off offset; \
360 for (i = 0; i < EGET(ehdr->e_phnum); i++) { \ 360 for (i = 0; i < EGET(ehdr->e_phnum); i++) { \
361 if (EGET(phdr[i].p_type) != PT_DYNAMIC) continue; \ 361 if (EGET(phdr[i].p_type) != PT_DYNAMIC || EGET(phdr[i].p_filesz) == 0) continue; \
362 offset = EGET(phdr[i].p_offset); \ 362 offset = EGET(phdr[i].p_offset); \
363 if (offset >= elf->len - sizeof(Elf ## B ## _Dyn)) continue; \ 363 if (offset >= elf->len - sizeof(Elf ## B ## _Dyn)) continue; \
364 dyn = DYN ## B (elf->data + offset); \ 364 dyn = DYN ## B (elf->data + offset); \
365 while (EGET(dyn->d_tag) != DT_NULL) { \ 365 while (EGET(dyn->d_tag) != DT_NULL) { \
366 if (EGET(dyn->d_tag) == DT_TEXTREL) { /*dyn->d_tag != DT_FLAGS)*/ \ 366 if (EGET(dyn->d_tag) == DT_TEXTREL) { /*dyn->d_tag != DT_FLAGS)*/ \
558 Elf ## B ## _Off offset; \ 558 Elf ## B ## _Off offset; \
559 Elf ## B ## _Xword word; \ 559 Elf ## B ## _Xword word; \
560 /* Scan all the program headers */ \ 560 /* Scan all the program headers */ \
561 for (i = 0; i < EGET(ehdr->e_phnum); i++) { \ 561 for (i = 0; i < EGET(ehdr->e_phnum); i++) { \
562 /* Just scan dynamic headers */ \ 562 /* Just scan dynamic headers */ \
563 if (EGET(phdr[i].p_type) != PT_DYNAMIC) continue; \ 563 if (EGET(phdr[i].p_type) != PT_DYNAMIC || EGET(phdr[i].p_filesz) == 0) continue; \
564 offset = EGET(phdr[i].p_offset); \ 564 offset = EGET(phdr[i].p_offset); \
565 if (offset >= elf->len - sizeof(Elf ## B ## _Dyn)) continue; \ 565 if (offset >= elf->len - sizeof(Elf ## B ## _Dyn)) continue; \
566 /* Just scan dynamic RPATH/RUNPATH headers */ \ 566 /* Just scan dynamic RPATH/RUNPATH headers */ \
567 dyn = DYN ## B (elf->data + offset); \ 567 dyn = DYN ## B (elf->data + offset); \
568 while ((word=EGET(dyn->d_tag)) != DT_NULL) { \ 568 while ((word=EGET(dyn->d_tag)) != DT_NULL) { \
818 Elf ## B ## _Ehdr *ehdr = EHDR ## B (elf->ehdr); \ 818 Elf ## B ## _Ehdr *ehdr = EHDR ## B (elf->ehdr); \
819 Elf ## B ## _Phdr *phdr = PHDR ## B (elf->phdr); \ 819 Elf ## B ## _Phdr *phdr = PHDR ## B (elf->phdr); \
820 Elf ## B ## _Shdr *strtbl = SHDR ## B (strtbl_void); \ 820 Elf ## B ## _Shdr *strtbl = SHDR ## B (strtbl_void); \
821 Elf ## B ## _Off offset; \ 821 Elf ## B ## _Off offset; \
822 for (i = 0; i < EGET(ehdr->e_phnum); i++) { \ 822 for (i = 0; i < EGET(ehdr->e_phnum); i++) { \
823 if (EGET(phdr[i].p_type) != PT_DYNAMIC) continue; \ 823 if (EGET(phdr[i].p_type) != PT_DYNAMIC || EGET(phdr[i].p_filesz) == 0) continue; \
824 offset = EGET(phdr[i].p_offset); \ 824 offset = EGET(phdr[i].p_offset); \
825 if (offset >= elf->len - sizeof(Elf ## B ## _Dyn)) continue; \ 825 if (offset >= elf->len - sizeof(Elf ## B ## _Dyn)) continue; \
826 dyn = DYN ## B (elf->data + offset); \ 826 dyn = DYN ## B (elf->data + offset); \
827 while (EGET(dyn->d_tag) != DT_NULL) { \ 827 while (EGET(dyn->d_tag) != DT_NULL) { \
828 if (EGET(dyn->d_tag) == DT_NEEDED) { \ 828 if (EGET(dyn->d_tag) == DT_NEEDED) { \
893 Elf ## B ## _Dyn *dyn; \ 893 Elf ## B ## _Dyn *dyn; \
894 Elf ## B ## _Ehdr *ehdr = EHDR ## B (elf->ehdr); \ 894 Elf ## B ## _Ehdr *ehdr = EHDR ## B (elf->ehdr); \
895 Elf ## B ## _Phdr *phdr = PHDR ## B (elf->phdr); \ 895 Elf ## B ## _Phdr *phdr = PHDR ## B (elf->phdr); \
896 Elf ## B ## _Off offset; \ 896 Elf ## B ## _Off offset; \
897 for (i = 0; i < EGET(ehdr->e_phnum); i++) { \ 897 for (i = 0; i < EGET(ehdr->e_phnum); i++) { \
898 if (EGET(phdr[i].p_type) != PT_DYNAMIC) continue; \ 898 if (EGET(phdr[i].p_type) != PT_DYNAMIC || EGET(phdr[i].p_filesz) == 0) continue; \
899 dynamic = 1; \ 899 dynamic = 1; \
900 offset = EGET(phdr[i].p_offset); \ 900 offset = EGET(phdr[i].p_offset); \
901 if (offset >= elf->len - sizeof(Elf ## B ## _Dyn)) continue; \ 901 if (offset >= elf->len - sizeof(Elf ## B ## _Dyn)) continue; \
902 dyn = DYN ## B (elf->data + offset); \ 902 dyn = DYN ## B (elf->data + offset); \
903 while (EGET(dyn->d_tag) != DT_NULL) { \ 903 while (EGET(dyn->d_tag) != DT_NULL) { \
945 Elf ## B ## _Off offset; \ 945 Elf ## B ## _Off offset; \
946 /* only look for soname in shared objects */ \ 946 /* only look for soname in shared objects */ \
947 if (ehdr->e_type != ET_DYN) \ 947 if (ehdr->e_type != ET_DYN) \
948 return NULL; \ 948 return NULL; \
949 for (i = 0; i < EGET(ehdr->e_phnum); i++) { \ 949 for (i = 0; i < EGET(ehdr->e_phnum); i++) { \
950 if (EGET(phdr[i].p_type) != PT_DYNAMIC) continue; \ 950 if (EGET(phdr[i].p_type) != PT_DYNAMIC || EGET(phdr[i].p_filesz) == 0) continue; \
951 offset = EGET(phdr[i].p_offset); \ 951 offset = EGET(phdr[i].p_offset); \
952 if (offset >= elf->len - sizeof(Elf ## B ## _Dyn)) continue; \ 952 if (offset >= elf->len - sizeof(Elf ## B ## _Dyn)) continue; \
953 dyn = DYN ## B (elf->data + offset); \ 953 dyn = DYN ## B (elf->data + offset); \
954 while (EGET(dyn->d_tag) != DT_NULL) { \ 954 while (EGET(dyn->d_tag) != DT_NULL) { \
955 if (EGET(dyn->d_tag) == DT_SONAME) { \ 955 if (EGET(dyn->d_tag) == DT_SONAME) { \

Legend:
Removed from v.1.184  
changed lines
  Added in v.1.185

  ViewVC Help
Powered by ViewVC 1.1.20