/[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.266 Revision 1.267
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.266 2014/06/18 03:16:52 vapier Exp $ 4 * $Header: /var/cvsroot/gentoo-projects/pax-utils/Attic/scanelf.c,v 1.267 2014/10/19 07:31:20 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.266 2014/06/18 03:16:52 vapier Exp $"; 10static const char rcsid[] = "$Id: scanelf.c,v 1.267 2014/10/19 07:31:20 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 == '+')
176 /* 176 /*
177 * If the sections are marked NOBITS, then they don't exist, so we just 177 * If the sections are marked NOBITS, then they don't exist, so we just
178 * skip them. This let's us work sanely with splitdebug ELFs (rather 178 * skip them. This let's us work sanely with splitdebug ELFs (rather
179 * than spewing a lot of "corrupt ELF" messages later on). In malformed 179 * than spewing a lot of "corrupt ELF" messages later on). In malformed
180 * ELFs, the section might be wrongly set to NOBITS, but screw em. 180 * ELFs, the section might be wrongly set to NOBITS, but screw em.
181 *
182 * We need to make sure the debug/runtime sym/str sets are used together
183 * as they are generated in sync. Trying to mix them won't work.
181 */ 184 */
182#define GET_SYMTABS(B) \ 185#define GET_SYMTABS(B) \
183 if (elf->elf_class == ELFCLASS ## B) { \ 186 if (elf->elf_class == ELFCLASS ## B) { \
184 Elf ## B ## _Shdr *esymtab = symtab; \ 187 Elf ## B ## _Shdr *esymtab = symtab; \
185 Elf ## B ## _Shdr *estrtab = strtab; \ 188 Elf ## B ## _Shdr *estrtab = strtab; \
188 \ 191 \
189 if (symtab && EGET(esymtab->sh_type) == SHT_NOBITS) \ 192 if (symtab && EGET(esymtab->sh_type) == SHT_NOBITS) \
190 symtab = NULL; \ 193 symtab = NULL; \
191 if (dynsym && EGET(edynsym->sh_type) == SHT_NOBITS) \ 194 if (dynsym && EGET(edynsym->sh_type) == SHT_NOBITS) \
192 dynsym = NULL; \ 195 dynsym = NULL; \
193 if (symtab && dynsym) \
194 *sym = (EGET(esymtab->sh_size) > EGET(edynsym->sh_size)) ? symtab : dynsym; \
195 else \
196 *sym = symtab ? symtab : dynsym; \
197 \
198 if (strtab && EGET(estrtab->sh_type) == SHT_NOBITS) \ 196 if (strtab && EGET(estrtab->sh_type) == SHT_NOBITS) \
199 strtab = NULL; \ 197 strtab = NULL; \
200 if (dynstr && EGET(edynstr->sh_type) == SHT_NOBITS) \ 198 if (dynstr && EGET(edynstr->sh_type) == SHT_NOBITS) \
201 dynstr = NULL; \ 199 dynstr = NULL; \
202 if (strtab && dynstr) \ 200 \
203 *str = (EGET(estrtab->sh_size) > EGET(edynstr->sh_size)) ? strtab : dynstr; \ 201 /* Use the set with more symbols if both exist. */ \
202 if (symtab && dynsym && strtab && dynstr) { \
203 if (EGET(esymtab->sh_size) > EGET(edynsym->sh_size)) \
204 goto debug##B; \
204 else \ 205 else \
205 *str = strtab ? strtab : dynstr; \ 206 goto runtime##B; \
207 } else if (symtab && strtab) { \
208 debug##B: \
209 *sym = symtab; \
210 *str = strtab; \
211 return; \
212 } else if (dynsym && dynstr) { \
213 runtime##B: \
214 *sym = dynsym; \
215 *str = dynstr; \
216 return; \
217 } \
206 } 218 }
207 GET_SYMTABS(32) 219 GET_SYMTABS(32)
208 GET_SYMTABS(64) 220 GET_SYMTABS(64)
209 221
210 if (*sym && *str) 222 if (*sym && *str)

Legend:
Removed from v.1.266  
changed lines
  Added in v.1.267

  ViewVC Help
Powered by ViewVC 1.1.20