/[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.177 Revision 1.185
1/* 1/*
2 * Copyright 2003-2006 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/Attic/scanelf.c,v 1.177 2007/05/20 23:20:46 solar Exp $ 4 * $Header: /var/cvsroot/gentoo-projects/pax-utils/Attic/scanelf.c,v 1.185 2007/08/18 04:59:32 vapier Exp $
5 * 5 *
6 * Copyright 2003-2006 Ned Ludd - <solar@gentoo.org> 6 * Copyright 2003-2007 Ned Ludd - <solar@gentoo.org>
7 * Copyright 2004-2006 Mike Frysinger - <vapier@gentoo.org> 7 * Copyright 2004-2007 Mike Frysinger - <vapier@gentoo.org>
8 */ 8 */
9 9
10#include "paxinc.h" 10#include "paxinc.h"
11 11
12static const char *rcsid = "$Id: scanelf.c,v 1.177 2007/05/20 23:20:46 solar Exp $"; 12static const char *rcsid = "$Id: scanelf.c,v 1.185 2007/08/18 04:59:32 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/* prototypes */ 17/* prototypes */
43static char scan_symlink = 1; 43static char scan_symlink = 1;
44static char scan_archives = 0; 44static char scan_archives = 0;
45static char dir_recurse = 0; 45static char dir_recurse = 0;
46static char dir_crossmount = 1; 46static char dir_crossmount = 1;
47static char show_pax = 0; 47static char show_pax = 0;
48static char show_perms = 0;
48static char show_phdr = 0; 49static char show_phdr = 0;
49static char show_textrel = 0; 50static char show_textrel = 0;
50static char show_rpath = 0; 51static char show_rpath = 0;
51static char show_needed = 0; 52static char show_needed = 0;
52static char show_interp = 0; 53static char show_interp = 0;
53static char show_bind = 0; 54static char show_bind = 0;
54static char show_soname = 0; 55static char show_soname = 0;
55static char show_textrels = 0; 56static char show_textrels = 0;
56static char show_banner = 1; 57static char show_banner = 1;
58static char show_endian = 0;
57static char be_quiet = 0; 59static char be_quiet = 0;
58static char be_verbose = 0; 60static char be_verbose = 0;
59static char be_wewy_wewy_quiet = 0; 61static char be_wewy_wewy_quiet = 0;
60static char be_semi_verbose = 0; 62static char be_semi_verbose = 0;
61static char *find_sym = NULL, *versioned_symname = NULL; 63static char *find_sym = NULL, *versioned_symname = NULL;
70static char **qa_textrels = NULL; 72static char **qa_textrels = NULL;
71static char **qa_execstack = NULL; 73static char **qa_execstack = NULL;
72static char **qa_wx_load = NULL; 74static char **qa_wx_load = NULL;
73 75
74int match_bits = 0; 76int match_bits = 0;
77unsigned int match_perms = 0;
75caddr_t ldcache = 0; 78caddr_t ldcache = 0;
76size_t ldcache_size = 0; 79size_t ldcache_size = 0;
77unsigned long setpax = 0UL; 80unsigned long setpax = 0UL;
78 81
79int has_objdump = 0; 82int has_objdump = 0;
83
84static char *getstr_perms(const char *fname);
85static char *getstr_perms(const char *fname) {
86 struct stat st;
87 static char buf[8];
88
89 if ((stat(fname, &st)) == (-1))
90 return (char *) "";
91
92 snprintf(buf, sizeof(buf), "%o", st.st_mode);
93
94 return (char *) buf + 2;
95}
80 96
81/* find the path to a file by name */ 97/* find the path to a file by name */
82static char *which(const char *fname) 98static char *which(const char *fname)
83{ 99{
84 static char fullpath[BUFSIZ]; 100 static char fullpath[BUFSIZ];
340 Elf ## B ## _Dyn *dyn; \ 356 Elf ## B ## _Dyn *dyn; \
341 Elf ## B ## _Ehdr *ehdr = EHDR ## B (elf->ehdr); \ 357 Elf ## B ## _Ehdr *ehdr = EHDR ## B (elf->ehdr); \
342 Elf ## B ## _Phdr *phdr = PHDR ## B (elf->phdr); \ 358 Elf ## B ## _Phdr *phdr = PHDR ## B (elf->phdr); \
343 Elf ## B ## _Off offset; \ 359 Elf ## B ## _Off offset; \
344 for (i = 0; i < EGET(ehdr->e_phnum); i++) { \ 360 for (i = 0; i < EGET(ehdr->e_phnum); i++) { \
345 if (EGET(phdr[i].p_type) != PT_DYNAMIC) continue; \ 361 if (EGET(phdr[i].p_type) != PT_DYNAMIC || EGET(phdr[i].p_filesz) == 0) continue; \
346 offset = EGET(phdr[i].p_offset); \ 362 offset = EGET(phdr[i].p_offset); \
347 if (offset >= elf->len - sizeof(Elf ## B ## _Dyn)) continue; \ 363 if (offset >= elf->len - sizeof(Elf ## B ## _Dyn)) continue; \
348 dyn = DYN ## B (elf->data + offset); \ 364 dyn = DYN ## B (elf->data + offset); \
349 while (EGET(dyn->d_tag) != DT_NULL) { \ 365 while (EGET(dyn->d_tag) != DT_NULL) { \
350 if (EGET(dyn->d_tag) == DT_TEXTREL) { /*dyn->d_tag != DT_FLAGS)*/ \ 366 if (EGET(dyn->d_tag) == DT_TEXTREL) { /*dyn->d_tag != DT_FLAGS)*/ \
362 if (be_quiet || be_wewy_wewy_quiet) 378 if (be_quiet || be_wewy_wewy_quiet)
363 return NULL; 379 return NULL;
364 else 380 else
365 return " - "; 381 return " - ";
366} 382}
383
367static char *scanelf_file_textrels(elfobj *elf, char *found_textrels, char *found_textrel) 384static char *scanelf_file_textrels(elfobj *elf, char *found_textrels, char *found_textrel)
368{ 385{
369 unsigned long s, r, rmax; 386 unsigned long s, r, rmax;
370 void *symtab_void, *strtab_void, *text_void; 387 void *symtab_void, *strtab_void, *text_void;
371 388
541 Elf ## B ## _Off offset; \ 558 Elf ## B ## _Off offset; \
542 Elf ## B ## _Xword word; \ 559 Elf ## B ## _Xword word; \
543 /* Scan all the program headers */ \ 560 /* Scan all the program headers */ \
544 for (i = 0; i < EGET(ehdr->e_phnum); i++) { \ 561 for (i = 0; i < EGET(ehdr->e_phnum); i++) { \
545 /* Just scan dynamic headers */ \ 562 /* Just scan dynamic headers */ \
546 if (EGET(phdr[i].p_type) != PT_DYNAMIC) continue; \ 563 if (EGET(phdr[i].p_type) != PT_DYNAMIC || EGET(phdr[i].p_filesz) == 0) continue; \
547 offset = EGET(phdr[i].p_offset); \ 564 offset = EGET(phdr[i].p_offset); \
548 if (offset >= elf->len - sizeof(Elf ## B ## _Dyn)) continue; \ 565 if (offset >= elf->len - sizeof(Elf ## B ## _Dyn)) continue; \
549 /* Just scan dynamic RPATH/RUNPATH headers */ \ 566 /* Just scan dynamic RPATH/RUNPATH headers */ \
550 dyn = DYN ## B (elf->data + offset); \ 567 dyn = DYN ## B (elf->data + offset); \
551 while ((word=EGET(dyn->d_tag)) != DT_NULL) { \ 568 while ((word=EGET(dyn->d_tag)) != DT_NULL) { \
801 Elf ## B ## _Ehdr *ehdr = EHDR ## B (elf->ehdr); \ 818 Elf ## B ## _Ehdr *ehdr = EHDR ## B (elf->ehdr); \
802 Elf ## B ## _Phdr *phdr = PHDR ## B (elf->phdr); \ 819 Elf ## B ## _Phdr *phdr = PHDR ## B (elf->phdr); \
803 Elf ## B ## _Shdr *strtbl = SHDR ## B (strtbl_void); \ 820 Elf ## B ## _Shdr *strtbl = SHDR ## B (strtbl_void); \
804 Elf ## B ## _Off offset; \ 821 Elf ## B ## _Off offset; \
805 for (i = 0; i < EGET(ehdr->e_phnum); i++) { \ 822 for (i = 0; i < EGET(ehdr->e_phnum); i++) { \
806 if (EGET(phdr[i].p_type) != PT_DYNAMIC) continue; \ 823 if (EGET(phdr[i].p_type) != PT_DYNAMIC || EGET(phdr[i].p_filesz) == 0) continue; \
807 offset = EGET(phdr[i].p_offset); \ 824 offset = EGET(phdr[i].p_offset); \
808 if (offset >= elf->len - sizeof(Elf ## B ## _Dyn)) continue; \ 825 if (offset >= elf->len - sizeof(Elf ## B ## _Dyn)) continue; \
809 dyn = DYN ## B (elf->data + offset); \ 826 dyn = DYN ## B (elf->data + offset); \
810 while (EGET(dyn->d_tag) != DT_NULL) { \ 827 while (EGET(dyn->d_tag) != DT_NULL) { \
811 if (EGET(dyn->d_tag) == DT_NEEDED) { \ 828 if (EGET(dyn->d_tag) == DT_NEEDED) { \
876 Elf ## B ## _Dyn *dyn; \ 893 Elf ## B ## _Dyn *dyn; \
877 Elf ## B ## _Ehdr *ehdr = EHDR ## B (elf->ehdr); \ 894 Elf ## B ## _Ehdr *ehdr = EHDR ## B (elf->ehdr); \
878 Elf ## B ## _Phdr *phdr = PHDR ## B (elf->phdr); \ 895 Elf ## B ## _Phdr *phdr = PHDR ## B (elf->phdr); \
879 Elf ## B ## _Off offset; \ 896 Elf ## B ## _Off offset; \
880 for (i = 0; i < EGET(ehdr->e_phnum); i++) { \ 897 for (i = 0; i < EGET(ehdr->e_phnum); i++) { \
881 if (EGET(phdr[i].p_type) != PT_DYNAMIC) continue; \ 898 if (EGET(phdr[i].p_type) != PT_DYNAMIC || EGET(phdr[i].p_filesz) == 0) continue; \
882 dynamic = 1; \ 899 dynamic = 1; \
883 offset = EGET(phdr[i].p_offset); \ 900 offset = EGET(phdr[i].p_offset); \
884 if (offset >= elf->len - sizeof(Elf ## B ## _Dyn)) continue; \ 901 if (offset >= elf->len - sizeof(Elf ## B ## _Dyn)) continue; \
885 dyn = DYN ## B (elf->data + offset); \ 902 dyn = DYN ## B (elf->data + offset); \
886 while (EGET(dyn->d_tag) != DT_NULL) { \ 903 while (EGET(dyn->d_tag) != DT_NULL) { \
928 Elf ## B ## _Off offset; \ 945 Elf ## B ## _Off offset; \
929 /* only look for soname in shared objects */ \ 946 /* only look for soname in shared objects */ \
930 if (ehdr->e_type != ET_DYN) \ 947 if (ehdr->e_type != ET_DYN) \
931 return NULL; \ 948 return NULL; \
932 for (i = 0; i < EGET(ehdr->e_phnum); i++) { \ 949 for (i = 0; i < EGET(ehdr->e_phnum); i++) { \
933 if (EGET(phdr[i].p_type) != PT_DYNAMIC) continue; \ 950 if (EGET(phdr[i].p_type) != PT_DYNAMIC || EGET(phdr[i].p_filesz) == 0) continue; \
934 offset = EGET(phdr[i].p_offset); \ 951 offset = EGET(phdr[i].p_offset); \
935 if (offset >= elf->len - sizeof(Elf ## B ## _Dyn)) continue; \ 952 if (offset >= elf->len - sizeof(Elf ## B ## _Dyn)) continue; \
936 dyn = DYN ## B (elf->data + offset); \ 953 dyn = DYN ## B (elf->data + offset); \
937 while (EGET(dyn->d_tag) != DT_NULL) { \ 954 while (EGET(dyn->d_tag) != DT_NULL) { \
938 if (EGET(dyn->d_tag) == DT_SONAME) { \ 955 if (EGET(dyn->d_tag) == DT_SONAME) { \
1134 case 's': prints("SYM "); break; 1151 case 's': prints("SYM "); break;
1135 case 'N': prints("LIB "); break; 1152 case 'N': prints("LIB "); break;
1136 case 'T': prints("TEXTRELS "); break; 1153 case 'T': prints("TEXTRELS "); break;
1137 case 'k': prints("SECTION "); break; 1154 case 'k': prints("SECTION "); break;
1138 case 'a': prints("ARCH "); break; 1155 case 'a': prints("ARCH "); break;
1156 case 'O': prints("PERM "); break;
1157 case 'D': prints("ENDIAN "); break;
1139 default: warnf("'%c' has no title ?", out_format[i]); 1158 default: warnf("'%c' has no title ?", out_format[i]);
1140 } 1159 }
1141 } 1160 }
1142 if (!found_file) prints("FILE "); 1161 if (!found_file) prints("FILE ");
1143 prints("\n"); 1162 prints("\n");
1194 case 'e': out = scanelf_file_phdr(elf, &found_phdr, &found_relro, &found_load); break; 1213 case 'e': out = scanelf_file_phdr(elf, &found_phdr, &found_relro, &found_load); break;
1195 case 't': out = scanelf_file_textrel(elf, &found_textrel); break; 1214 case 't': out = scanelf_file_textrel(elf, &found_textrel); break;
1196 case 'T': out = scanelf_file_textrels(elf, &found_textrels, &found_textrel); break; 1215 case 'T': out = scanelf_file_textrels(elf, &found_textrels, &found_textrel); break;
1197 case 'r': scanelf_file_rpath(elf, &found_rpath, &out_buffer, &out_len); break; 1216 case 'r': scanelf_file_rpath(elf, &found_rpath, &out_buffer, &out_len); break;
1198 case 'M': out = get_elfeitype(EI_CLASS, elf->data[EI_CLASS]); break; 1217 case 'M': out = get_elfeitype(EI_CLASS, elf->data[EI_CLASS]); break;
1218 case 'D': out = get_endian(elf); break;
1219 case 'O': out = getstr_perms(elf->filename); break;
1199 case 'n': 1220 case 'n':
1200 case 'N': out = scanelf_file_needed_lib(elf, &found_needed, &found_lib, (out_format[i]=='N'), &out_buffer, &out_len); break; 1221 case 'N': out = scanelf_file_needed_lib(elf, &found_needed, &found_lib, (out_format[i]=='N'), &out_buffer, &out_len); break;
1201 case 'i': out = scanelf_file_interp(elf, &found_interp); break; 1222 case 'i': out = scanelf_file_interp(elf, &found_interp); break;
1202 case 'b': out = scanelf_file_bind(elf, &found_bind); break; 1223 case 'b': out = scanelf_file_bind(elf, &found_bind); break;
1203 case 'S': out = scanelf_file_soname(elf, &found_soname); break; 1224 case 'S': out = scanelf_file_soname(elf, &found_soname); break;
1318 if (!S_ISREG(st->st_mode)) { 1339 if (!S_ISREG(st->st_mode)) {
1319 if (be_verbose > 2) printf("%s: skipping non-file\n", filename); 1340 if (be_verbose > 2) printf("%s: skipping non-file\n", filename);
1320 return 1; 1341 return 1;
1321 } 1342 }
1322 1343
1344 if (match_perms) {
1345 if ((st->st_mode | match_perms) != st->st_mode)
1346 return 1;
1347 }
1323 if ((fd=open(filename, (fix_elf ? O_RDWR : O_RDONLY))) == -1) 1348 if ((fd=open(filename, (fix_elf ? O_RDWR : O_RDONLY))) == -1)
1324 return 1; 1349 return 1;
1325 1350
1326 if (scanelf_elf(filename, fd, st->st_size) == 1 && scan_archives) 1351 if (scanelf_elf(filename, fd, st->st_size) == 1 && scan_archives)
1327 /* if it isn't an ELF, maybe it's an .a archive */ 1352 /* if it isn't an ELF, maybe it's an .a archive */
1521} 1546}
1522 1547
1523#endif 1548#endif
1524 1549
1525/* scan /etc/ld.so.conf for paths */ 1550/* scan /etc/ld.so.conf for paths */
1526static void scanelf_ldpath() 1551static void scanelf_ldpath(void)
1527{ 1552{
1528 char scan_l, scan_ul, scan_ull; 1553 char scan_l, scan_ul, scan_ull;
1529 int i = 0; 1554 int i = 0;
1530 1555
1531 if (!ldpaths[0]) 1556 if (!ldpaths[0])
1545 if (!scan_ul) scanelf_dir("/usr/lib"); 1570 if (!scan_ul) scanelf_dir("/usr/lib");
1546 if (!scan_ull) scanelf_dir("/usr/local/lib"); 1571 if (!scan_ull) scanelf_dir("/usr/local/lib");
1547} 1572}
1548 1573
1549/* scan env PATH for paths */ 1574/* scan env PATH for paths */
1550static void scanelf_envpath() 1575static void scanelf_envpath(void)
1551{ 1576{
1552 char *path, *p; 1577 char *path, *p;
1553 1578
1554 path = getenv("PATH"); 1579 path = getenv("PATH");
1555 if (!path) 1580 if (!path)
1562 } 1587 }
1563 1588
1564 free(path); 1589 free(path);
1565} 1590}
1566 1591
1567/* usage / invocation handling functions */ 1592
1593/* usage / invocation handling functions */ /* Free Flags: c d j u w C G H I J K P Q U W Y Z */
1568#define PARSE_FLAGS "plRmyAXz:xetrnLibSs:k:gN:TaqvF:f:o:E:M:BhV" 1594#define PARSE_FLAGS "plRmyAXz:xetrnLibSs:k:gN:TaqvF:f:o:E:M:DO:BhV"
1569#define a_argument required_argument 1595#define a_argument required_argument
1570static struct option const long_opts[] = { 1596static struct option const long_opts[] = {
1571 {"path", no_argument, NULL, 'p'}, 1597 {"path", no_argument, NULL, 'p'},
1572 {"ldpath", no_argument, NULL, 'l'}, 1598 {"ldpath", no_argument, NULL, 'l'},
1573 {"recursive", no_argument, NULL, 'R'}, 1599 {"recursive", no_argument, NULL, 'R'},
1590 {"lib", a_argument, NULL, 'N'}, 1616 {"lib", a_argument, NULL, 'N'},
1591 {"gmatch", no_argument, NULL, 'g'}, 1617 {"gmatch", no_argument, NULL, 'g'},
1592 {"textrels", no_argument, NULL, 'T'}, 1618 {"textrels", no_argument, NULL, 'T'},
1593 {"etype", a_argument, NULL, 'E'}, 1619 {"etype", a_argument, NULL, 'E'},
1594 {"bits", a_argument, NULL, 'M'}, 1620 {"bits", a_argument, NULL, 'M'},
1621 {"endian", no_argument, NULL, 'D'},
1622 {"perms", a_argument, NULL, 'O'},
1595 {"all", no_argument, NULL, 'a'}, 1623 {"all", no_argument, NULL, 'a'},
1596 {"quiet", no_argument, NULL, 'q'}, 1624 {"quiet", no_argument, NULL, 'q'},
1597 {"verbose", no_argument, NULL, 'v'}, 1625 {"verbose", no_argument, NULL, 'v'},
1598 {"format", a_argument, NULL, 'F'}, 1626 {"format", a_argument, NULL, 'F'},
1599 {"from", a_argument, NULL, 'f'}, 1627 {"from", a_argument, NULL, 'f'},
1627 "Find a specified library", 1655 "Find a specified library",
1628 "Use strncmp to match libraries. (use with -N)", 1656 "Use strncmp to match libraries. (use with -N)",
1629 "Locate cause of TEXTREL", 1657 "Locate cause of TEXTREL",
1630 "Print only ELF files matching etype ET_DYN,ET_EXEC ...", 1658 "Print only ELF files matching etype ET_DYN,ET_EXEC ...",
1631 "Print only ELF files matching numeric bits", 1659 "Print only ELF files matching numeric bits",
1660 "Print Endianness",
1661 "Print only ELF files matching octal permissions",
1632 "Print all scanned info (-x -e -t -r -b)\n", 1662 "Print all scanned info (-x -e -t -r -b)\n",
1633 "Only output 'bad' things", 1663 "Only output 'bad' things",
1634 "Be verbose (can be specified more than once)", 1664 "Be verbose (can be specified more than once)",
1635 "Use specified format for output", 1665 "Use specified format for output",
1636 "Read input stream from a filename", 1666 "Read input stream from a filename",
1693 case 'E': 1723 case 'E':
1694 strncpy(match_etypes, optarg, sizeof(match_etypes)); 1724 strncpy(match_etypes, optarg, sizeof(match_etypes));
1695 break; 1725 break;
1696 case 'M': 1726 case 'M':
1697 match_bits = atoi(optarg); 1727 match_bits = atoi(optarg);
1728 if (match_bits == 0) {
1729 if (strcmp(optarg, "ELFCLASS32") == 0)
1730 match_bits = 32;
1731 if (strcmp(optarg, "ELFCLASS64") == 0)
1732 match_bits = 64;
1733 }
1734 break;
1735 case 'O':
1736 if (sscanf(optarg, "%o", &match_perms) == (-1))
1737 match_bits = 0;
1698 break; 1738 break;
1699 case 'o': { 1739 case 'o': {
1700 if (freopen(optarg, "w", stdout) == NULL) 1740 if (freopen(optarg, "w", stdout) == NULL)
1701 err("Could not open output stream '%s': %s", optarg, strerror(errno)); 1741 err("Could not open output stream '%s': %s", optarg, strerror(errno));
1702 break; 1742 break;
1785 case 'b': show_bind = 1; break; 1825 case 'b': show_bind = 1; break;
1786 case 'S': show_soname = 1; break; 1826 case 'S': show_soname = 1; break;
1787 case 'T': show_textrels = 1; break; 1827 case 'T': show_textrels = 1; break;
1788 case 'q': be_quiet = 1; break; 1828 case 'q': be_quiet = 1; break;
1789 case 'v': be_verbose = (be_verbose % 20) + 1; break; 1829 case 'v': be_verbose = (be_verbose % 20) + 1; break;
1790 case 'a': show_pax = show_phdr = show_textrel = show_rpath = show_bind = 1; break; 1830 case 'a': show_perms = show_pax = show_phdr = show_textrel = show_rpath = show_bind = show_endian = 1; break;
1791 1831 case 'D': show_endian = 1; break;
1792 case ':': 1832 case ':':
1793 err("Option '%c' is missing parameter", optopt); 1833 err("Option '%c' is missing parameter", optopt);
1794 case '?': 1834 case '?':
1795 err("Unknown option '%c' or argument missing", optopt); 1835 err("Unknown option '%c' or argument missing", optopt);
1796 default: 1836 default:
1803 } 1843 }
1804 /* let the format option override all other options */ 1844 /* let the format option override all other options */
1805 if (out_format) { 1845 if (out_format) {
1806 show_pax = show_phdr = show_textrel = show_rpath = \ 1846 show_pax = show_phdr = show_textrel = show_rpath = \
1807 show_needed = show_interp = show_bind = show_soname = \ 1847 show_needed = show_interp = show_bind = show_soname = \
1808 show_textrels = 0; 1848 show_textrels = show_perms = show_endian = 0;
1809 for (i = 0; out_format[i]; ++i) { 1849 for (i = 0; out_format[i]; ++i) {
1810 if (!IS_MODIFIER(out_format[i])) continue; 1850 if (!IS_MODIFIER(out_format[i])) continue;
1811 1851
1812 switch (out_format[++i]) { 1852 switch (out_format[++i]) {
1813 case '+': break; 1853 case '+': break;
1820 case 's': break; 1860 case 's': break;
1821 case 'N': break; 1861 case 'N': break;
1822 case 'o': break; 1862 case 'o': break;
1823 case 'a': break; 1863 case 'a': break;
1824 case 'M': break; 1864 case 'M': break;
1865 case 'D': show_endian = 1; break;
1866 case 'O': show_perms = 1; break;
1825 case 'x': show_pax = 1; break; 1867 case 'x': show_pax = 1; break;
1826 case 'e': show_phdr = 1; break; 1868 case 'e': show_phdr = 1; break;
1827 case 't': show_textrel = 1; break; 1869 case 't': show_textrel = 1; break;
1828 case 'r': show_rpath = 1; break; 1870 case 'r': show_rpath = 1; break;
1829 case 'n': show_needed = 1; break; 1871 case 'n': show_needed = 1; break;
1841 } else { 1883 } else {
1842 size_t fmt_len = 30; 1884 size_t fmt_len = 30;
1843 out_format = (char*)xmalloc(sizeof(char) * fmt_len); 1885 out_format = (char*)xmalloc(sizeof(char) * fmt_len);
1844 if (!be_quiet) xstrcat(&out_format, "%o ", &fmt_len); 1886 if (!be_quiet) xstrcat(&out_format, "%o ", &fmt_len);
1845 if (show_pax) xstrcat(&out_format, "%x ", &fmt_len); 1887 if (show_pax) xstrcat(&out_format, "%x ", &fmt_len);
1888 if (show_perms) xstrcat(&out_format, "%O ", &fmt_len);
1889 if (show_endian) xstrcat(&out_format, "%D ", &fmt_len);
1846 if (show_phdr) xstrcat(&out_format, "%e ", &fmt_len); 1890 if (show_phdr) xstrcat(&out_format, "%e ", &fmt_len);
1847 if (show_textrel) xstrcat(&out_format, "%t ", &fmt_len); 1891 if (show_textrel) xstrcat(&out_format, "%t ", &fmt_len);
1848 if (show_rpath) xstrcat(&out_format, "%r ", &fmt_len); 1892 if (show_rpath) xstrcat(&out_format, "%r ", &fmt_len);
1849 if (show_needed) xstrcat(&out_format, "%n ", &fmt_len); 1893 if (show_needed) xstrcat(&out_format, "%n ", &fmt_len);
1850 if (show_interp) xstrcat(&out_format, "%i ", &fmt_len); 1894 if (show_interp) xstrcat(&out_format, "%i ", &fmt_len);
1917 1961
1918 /* don't want to free(env) as it contains the memory that backs 1962 /* don't want to free(env) as it contains the memory that backs
1919 * the envvals array of strings */ 1963 * the envvals array of strings */
1920 return envvals; 1964 return envvals;
1921} 1965}
1966
1922static void parseenv() 1967static void parseenv(void)
1923{ 1968{
1924 qa_textrels = get_split_env("QA_TEXTRELS"); 1969 qa_textrels = get_split_env("QA_TEXTRELS");
1925 qa_execstack = get_split_env("QA_EXECSTACK"); 1970 qa_execstack = get_split_env("QA_EXECSTACK");
1926 qa_wx_load = get_split_env("QA_WX_LOAD"); 1971 qa_wx_load = get_split_env("QA_WX_LOAD");
1927} 1972}
1928 1973
1929#ifdef __PAX_UTILS_CLEANUP 1974#ifdef __PAX_UTILS_CLEANUP
1930static void cleanup() 1975static void cleanup(void)
1931{ 1976{
1932 free(out_format); 1977 free(out_format);
1933 free(qa_textrels); 1978 free(qa_textrels);
1934 free(qa_execstack); 1979 free(qa_execstack);
1935 free(qa_wx_load); 1980 free(qa_wx_load);

Legend:
Removed from v.1.177  
changed lines
  Added in v.1.185

  ViewVC Help
Powered by ViewVC 1.1.20