/[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.212 Revision 1.213
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.212 2009/03/15 09:13:20 vapier Exp $ 4 * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.213 2009/12/01 10:18:58 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
10static const char *rcsid = "$Id: scanelf.c,v 1.212 2009/03/15 09:13:20 vapier Exp $"; 10static const char *rcsid = "$Id: scanelf.c,v 1.213 2009/12/01 10:18:58 vapier Exp $";
11const char * const argv0 = "scanelf"; 11const 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 == '+')
128 128
129/* sub-funcs for scanelf_file() */ 129/* sub-funcs for scanelf_file() */
130static void scanelf_file_get_symtabs(elfobj *elf, void **sym, void **tab) 130static void scanelf_file_get_symtabs(elfobj *elf, void **sym, void **tab)
131{ 131{
132 /* find the best SHT_DYNSYM and SHT_STRTAB sections */ 132 /* find the best SHT_DYNSYM and SHT_STRTAB sections */
133
134 /* debug sections */
135 void *symtab = elf_findsecbyname(elf, ".symtab");
136 void *strtab = elf_findsecbyname(elf, ".strtab");
137 /* runtime sections */
138 void *dynsym = elf_findsecbyname(elf, ".dynsym");
139 void *dynstr = elf_findsecbyname(elf, ".dynstr");
140
133#define GET_SYMTABS(B) \ 141#define GET_SYMTABS(B) \
134 if (elf->elf_class == ELFCLASS ## B) { \ 142 if (elf->elf_class == ELFCLASS ## B) { \
135 Elf ## B ## _Shdr *symtab, *strtab, *dynsym, *dynstr; \
136 /* debug sections */ \
137 symtab = SHDR ## B (elf_findsecbyname(elf, ".symtab")); \
138 strtab = SHDR ## B (elf_findsecbyname(elf, ".strtab")); \
139 /* runtime sections */ \
140 dynsym = SHDR ## B (elf_findsecbyname(elf, ".dynsym")); \
141 dynstr = SHDR ## B (elf_findsecbyname(elf, ".dynstr")); \
142 if (symtab && dynsym) { \ 143 if (symtab && dynsym) { \
144 Elf ## B ## _Shdr *esymtab = symtab; \
145 Elf ## B ## _Shdr *edynsym = dynsym; \
143 *sym = (void*)((EGET(symtab->sh_size) > EGET(dynsym->sh_size)) ? symtab : dynsym); \ 146 *sym = (EGET(esymtab->sh_size) > EGET(edynsym->sh_size)) ? symtab : dynsym; \
144 } else { \ 147 } else \
145 *sym = (void*)(symtab ? symtab : dynsym); \ 148 *sym = symtab ? symtab : dynsym; \
146 } \
147 if (strtab && dynstr) { \ 149 if (strtab && dynstr) { \
150 Elf ## B ## _Shdr *estrtab = strtab; \
151 Elf ## B ## _Shdr *edynstr = dynstr; \
148 *tab = (void*)((EGET(strtab->sh_size) > EGET(dynstr->sh_size)) ? strtab : dynstr); \ 152 *tab = (EGET(estrtab->sh_size) > EGET(edynstr->sh_size)) ? strtab : dynstr; \
149 } else { \ 153 } else \
150 *tab = (void*)(strtab ? strtab : dynstr); \ 154 *tab = strtab ? strtab : dynstr; \
151 } \
152 } 155 }
153 GET_SYMTABS(32) 156 GET_SYMTABS(32)
154 GET_SYMTABS(64) 157 GET_SYMTABS(64)
155} 158}
156 159

Legend:
Removed from v.1.212  
changed lines
  Added in v.1.213

  ViewVC Help
Powered by ViewVC 1.1.20