/[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.78 Revision 1.79
1/* 1/*
2 * Copyright 2003-2005 Gentoo Foundation 2 * Copyright 2003-2005 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.78 2005/06/08 22:23:16 vapier Exp $ 4 * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.79 2005/06/09 23:53:58 vapier Exp $
5 * 5 *
6 ******************************************************************** 6 ********************************************************************
7 * This program is free software; you can redistribute it and/or 7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as 8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the 9 * published by the Free Software Foundation; either version 2 of the
33#include <dirent.h> 33#include <dirent.h>
34#include <getopt.h> 34#include <getopt.h>
35#include <assert.h> 35#include <assert.h>
36#include "paxelf.h" 36#include "paxelf.h"
37 37
38static const char *rcsid = "$Id: scanelf.c,v 1.78 2005/06/08 22:23:16 vapier Exp $"; 38static const char *rcsid = "$Id: scanelf.c,v 1.79 2005/06/09 23:53:58 vapier Exp $";
39#define argv0 "scanelf" 39#define argv0 "scanelf"
40 40
41#define IS_MODIFIER(c) (c == '%' || c == '#') 41#define IS_MODIFIER(c) (c == '%' || c == '#')
42 42
43 43
213static char *scanelf_file_textrel(elfobj *elf, char *found_textrel) 213static char *scanelf_file_textrel(elfobj *elf, char *found_textrel)
214{ 214{
215 static char ret[] = "TEXTREL"; 215 static char ret[] = "TEXTREL";
216 unsigned long i; 216 unsigned long i;
217 217
218 if (!show_textrel) return NULL; 218 if (!show_textrel && !show_textrels) return NULL;
219 219
220 if (elf->phdr) { 220 if (elf->phdr) {
221#define SHOW_TEXTREL(B) \ 221#define SHOW_TEXTREL(B) \
222 if (elf->elf_class == ELFCLASS ## B) { \ 222 if (elf->elf_class == ELFCLASS ## B) { \
223 Elf ## B ## _Dyn *dyn; \ 223 Elf ## B ## _Dyn *dyn; \
245 if (be_quiet || be_wewy_wewy_quiet) 245 if (be_quiet || be_wewy_wewy_quiet)
246 return NULL; 246 return NULL;
247 else 247 else
248 return (char *)" - "; 248 return (char *)" - ";
249} 249}
250static char *scanelf_file_textrels(elfobj *elf, char *found_textrels) 250static char *scanelf_file_textrels(elfobj *elf, char *found_textrels, char *found_textrel)
251{ 251{
252 unsigned long p, s, r, rmax; 252 unsigned long p, s, r, rmax;
253 void *symtab_void, *strtab_void; 253 void *symtab_void, *strtab_void;
254 254
255 if (!show_textrels) return NULL; 255 if (!show_textrels) return NULL;
256
257 /* don't search for TEXTREL's if the ELF doesn't have any */
258 if (!*found_textrel) scanelf_file_textrel(elf, found_textrel);
259 if (!*found_textrel) return NULL;
256 260
257 scanelf_file_get_symtabs(elf, &symtab_void, &strtab_void); 261 scanelf_file_get_symtabs(elf, &symtab_void, &strtab_void);
258 262
259 if (symtab_void && strtab_void && elf->phdr && elf->shdr) { 263 if (symtab_void && strtab_void && elf->phdr && elf->shdr) {
260#define SHOW_TEXTRELS(B) \ 264#define SHOW_TEXTRELS(B) \
731 break; 735 break;
732 case 'o': out = get_elfetype(elf); break; 736 case 'o': out = get_elfetype(elf); break;
733 case 'x': out = scanelf_file_pax(elf, &found_pax); break; 737 case 'x': out = scanelf_file_pax(elf, &found_pax); break;
734 case 'e': out = scanelf_file_phdr(elf, &found_phdr, &found_relro, &found_load); break; 738 case 'e': out = scanelf_file_phdr(elf, &found_phdr, &found_relro, &found_load); break;
735 case 't': out = scanelf_file_textrel(elf, &found_textrel); break; 739 case 't': out = scanelf_file_textrel(elf, &found_textrel); break;
736 case 'T': out = scanelf_file_textrels(elf, &found_textrels); break; 740 case 'T': out = scanelf_file_textrels(elf, &found_textrels, &found_textrel); break;
737 case 'r': scanelf_file_rpath(elf, &found_rpath, &out_buffer, &out_len); break; 741 case 'r': scanelf_file_rpath(elf, &found_rpath, &out_buffer, &out_len); break;
738 case 'n': 742 case 'n':
739 case 'N': out = scanelf_file_needed_lib(elf, &found_needed, &found_lib, (out_format[i]=='N'), &out_buffer, &out_len); break; 743 case 'N': out = scanelf_file_needed_lib(elf, &found_needed, &found_lib, (out_format[i]=='N'), &out_buffer, &out_len); break;
740 case 'i': out = scanelf_file_interp(elf, &found_interp); break; 744 case 'i': out = scanelf_file_interp(elf, &found_interp); break;
741 case 'b': out = scanelf_file_bind(elf, &found_bind); break; 745 case 'b': out = scanelf_file_bind(elf, &found_bind); break;
752 756
753 if (!found_file && (!be_quiet || (be_quiet && FOUND_SOMETHING()))) { 757 if (!found_file && (!be_quiet || (be_quiet && FOUND_SOMETHING()))) {
754 xchrcat(&out_buffer, ' ', &out_len); 758 xchrcat(&out_buffer, ' ', &out_len);
755 xstrcat(&out_buffer, filename, &out_len); 759 xstrcat(&out_buffer, filename, &out_len);
756 } 760 }
757 if (!be_quiet || (be_quiet && FOUND_SOMETHING())) 761 if (!be_quiet || (be_quiet && FOUND_SOMETHING())) {
758 puts(out_buffer); 762 puts(out_buffer);
763 fflush(stdout);
764 }
759 765
760 unreadelf(elf); 766 unreadelf(elf);
761} 767}
762 768
763/* scan a directory for ET_EXEC files and print when we find one */ 769/* scan a directory for ET_EXEC files and print when we find one */

Legend:
Removed from v.1.78  
changed lines
  Added in v.1.79

  ViewVC Help
Powered by ViewVC 1.1.20