| 1 | /* |
1 | /* |
| 2 | * Copyright 2003-2006 Gentoo Foundation |
2 | * Copyright 2003-2006 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.161 2006/11/28 03:55:57 vapier Exp $ |
4 | * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.162 2006/11/28 04:01:04 vapier Exp $ |
| 5 | * |
5 | * |
| 6 | * Copyright 2003-2006 Ned Ludd - <solar@gentoo.org> |
6 | * Copyright 2003-2006 Ned Ludd - <solar@gentoo.org> |
| 7 | * Copyright 2004-2006 Mike Frysinger - <vapier@gentoo.org> |
7 | * Copyright 2004-2006 Mike Frysinger - <vapier@gentoo.org> |
| 8 | */ |
8 | */ |
| 9 | |
9 | |
| 10 | #include "paxinc.h" |
10 | #include "paxinc.h" |
| 11 | |
11 | |
| 12 | static const char *rcsid = "$Id: scanelf.c,v 1.161 2006/11/28 03:55:57 vapier Exp $"; |
12 | static const char *rcsid = "$Id: scanelf.c,v 1.162 2006/11/28 04:01:04 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 | #define do_state(option, flag) \ |
17 | #define do_state(option, flag) \ |
| … | |
… | |
| 1016 | /* scan an elf file and show all the fun stuff */ |
1016 | /* scan an elf file and show all the fun stuff */ |
| 1017 | #define prints(str) write(fileno(stdout), str, strlen(str)) |
1017 | #define prints(str) write(fileno(stdout), str, strlen(str)) |
| 1018 | static int scanelf_elfobj(elfobj *elf) |
1018 | static int scanelf_elfobj(elfobj *elf) |
| 1019 | { |
1019 | { |
| 1020 | unsigned long i; |
1020 | unsigned long i; |
| 1021 | char found_pax, found_phdr, found_relro, found_load, found_textrel, |
1021 | char found_pax, found_phdr, found_relro, found_load, found_textrel, |
| 1022 | found_rpath, found_needed, found_interp, found_bind, found_soname, |
1022 | found_rpath, found_needed, found_interp, found_bind, found_soname, |
| 1023 | found_sym, found_lib, found_file, found_textrels, found_section; |
1023 | found_sym, found_lib, found_file, found_textrels, found_section; |
| 1024 | static char *out_buffer = NULL; |
1024 | static char *out_buffer = NULL; |
| 1025 | static size_t out_len; |
1025 | static size_t out_len; |
| 1026 | |
1026 | |
| 1027 | found_pax = found_phdr = found_relro = found_load = found_textrel = \ |
1027 | found_pax = found_phdr = found_relro = found_load = found_textrel = \ |
| … | |
… | |
| 1757 | case 'i': show_interp = 1; break; |
1757 | case 'i': show_interp = 1; break; |
| 1758 | case 'b': show_bind = 1; break; |
1758 | case 'b': show_bind = 1; break; |
| 1759 | case 'S': show_soname = 1; break; |
1759 | case 'S': show_soname = 1; break; |
| 1760 | case 'T': show_textrels = 1; break; |
1760 | case 'T': show_textrels = 1; break; |
| 1761 | default: |
1761 | default: |
| 1762 | err("Invalid format specifier '%c' (byte %i)", |
1762 | err("Invalid format specifier '%c' (byte %i)", |
| 1763 | out_format[i], i+1); |
1763 | out_format[i], i+1); |
| 1764 | } |
1764 | } |
| 1765 | } |
1765 | } |
| 1766 | |
1766 | |
| 1767 | /* construct our default format */ |
1767 | /* construct our default format */ |