/[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.243 Revision 1.244
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.243 2012/04/29 05:41:14 vapier Exp $ 4 * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.244 2012/04/29 06:21:36 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.243 2012/04/29 05:41:14 vapier Exp $"; 10static const char rcsid[] = "$Id: scanelf.c,v 1.244 2012/04/29 06:21:36 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 == '+')
153 void *strtab = elf_findsecbyname(elf, ".strtab"); 153 void *strtab = elf_findsecbyname(elf, ".strtab");
154 /* runtime sections */ 154 /* runtime sections */
155 void *dynsym = elf_findsecbyname(elf, ".dynsym"); 155 void *dynsym = elf_findsecbyname(elf, ".dynsym");
156 void *dynstr = elf_findsecbyname(elf, ".dynstr"); 156 void *dynstr = elf_findsecbyname(elf, ".dynstr");
157 157
158 /*
159 * If the sections are marked NOBITS, then they don't exist, so we just
160 * skip them. This let's us work sanely with splitdebug ELFs (rather
161 * than spewing a lot of "corrupt ELF" messages later on). In malformed
162 * ELFs, the section might be wrongly set to NOBITS, but screw em.
163 */
158#define GET_SYMTABS(B) \ 164#define GET_SYMTABS(B) \
159 if (elf->elf_class == ELFCLASS ## B) { \ 165 if (elf->elf_class == ELFCLASS ## B) { \
160 if (symtab && dynsym) { \
161 Elf ## B ## _Shdr *esymtab = symtab; \ 166 Elf ## B ## _Shdr *esymtab = symtab; \
167 Elf ## B ## _Shdr *estrtab = strtab; \
162 Elf ## B ## _Shdr *edynsym = dynsym; \ 168 Elf ## B ## _Shdr *edynsym = dynsym; \
169 Elf ## B ## _Shdr *edynstr = dynstr; \
170 \
171 if (symtab && EGET(esymtab->sh_type) == SHT_NOBITS) \
172 symtab = NULL; \
173 if (dynsym && EGET(edynsym->sh_type) == SHT_NOBITS) \
174 dynsym = NULL; \
175 if (symtab && dynsym) \
163 *sym = (EGET(esymtab->sh_size) > EGET(edynsym->sh_size)) ? symtab : dynsym; \ 176 *sym = (EGET(esymtab->sh_size) > EGET(edynsym->sh_size)) ? symtab : dynsym; \
164 } else \ 177 else \
165 *sym = symtab ? symtab : dynsym; \ 178 *sym = symtab ? symtab : dynsym; \
179 \
180 if (strtab && EGET(estrtab->sh_type) == SHT_NOBITS) \
181 strtab = NULL; \
182 if (dynstr && EGET(edynstr->sh_type) == SHT_NOBITS) \
183 dynstr = NULL; \
166 if (strtab && dynstr) { \ 184 if (strtab && dynstr) \
167 Elf ## B ## _Shdr *estrtab = strtab; \
168 Elf ## B ## _Shdr *edynstr = dynstr; \
169 *str = (EGET(estrtab->sh_size) > EGET(edynstr->sh_size)) ? strtab : dynstr; \ 185 *str = (EGET(estrtab->sh_size) > EGET(edynstr->sh_size)) ? strtab : dynstr; \
170 } else \ 186 else \
171 *str = strtab ? strtab : dynstr; \ 187 *str = strtab ? strtab : dynstr; \
172 } 188 }
173 GET_SYMTABS(32) 189 GET_SYMTABS(32)
174 GET_SYMTABS(64) 190 GET_SYMTABS(64)
175 191

Legend:
Removed from v.1.243  
changed lines
  Added in v.1.244

  ViewVC Help
Powered by ViewVC 1.1.20