Gentoo Archives: gentoo-commits

From: Mike Frysinger <vapier@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/pax-utils:master commit in: /
Date: Tue, 24 Jan 2017 20:39:51
Message-Id: 1485289346.6a73ea4e32cc6ff6d1814048368b7b75da626565.vapier@gentoo
1 commit: 6a73ea4e32cc6ff6d1814048368b7b75da626565
2 Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
3 AuthorDate: Tue Jan 24 20:22:26 2017 +0000
4 Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
5 CommitDate: Tue Jan 24 20:22:26 2017 +0000
6 URL: https://gitweb.gentoo.org/proj/pax-utils.git/commit/?id=6a73ea4e
7
8 scanelf: revert back to looking at .dynstr directly
9
10 The rpath/needed/soname strings are only listed in .dynstr, so trying
11 to locate them in .strtab fails. Which means using the lookup helper
12 breaks behavior on non-stripped files.
13
14 TODO | 4 ++++
15 scanelf.c | 27 +++++++++++++++++++++------
16 2 files changed, 25 insertions(+), 6 deletions(-)
17
18 diff --git a/TODO b/TODO
19 index be2d0a2..ded1158 100644
20 --- a/TODO
21 +++ b/TODO
22 @@ -30,3 +30,7 @@ allow digging into ARM_ATTRIBUTES (.ARM.attributes) sections
23 - need info on the section layout
24 - figure out how to integrate cleanly (target-independent driller)
25 http://sourceware.org/binutils/docs/as/GNU-Object-Attributes.html
26 +
27 +scanelf should look at the dynamic table for rpath/needed/soname entries instead
28 +of requiring section headers and looking up by section names. need to implement
29 +support for GNU_HASH first though so we can get the string table sizes.
30
31 diff --git a/scanelf.c b/scanelf.c
32 index 9695276..79ce59c 100644
33 --- a/scanelf.c
34 +++ b/scanelf.c
35 @@ -767,11 +767,16 @@ static void rpath_security_checks(elfobj *elf, char *item, const char *dt_type)
36 static void scanelf_file_rpath(elfobj *elf, char *found_rpath, char **ret, size_t *ret_len)
37 {
38 char *rpath, *runpath, **r;
39 - void *symtab_void, *strtab_void;
40 + void *strtab_void;
41
42 if (!show_rpath) return;
43
44 - scanelf_file_get_symtabs(elf, &symtab_void, &strtab_void);
45 + /*
46 + * TODO: Switch to the string table found via dynamic tags.
47 + * Note: We can't use scanelf_file_get_symtabs as these strings are
48 + * *only* found in dynstr and not in .strtab.
49 + */
50 + strtab_void = elf_findsecbyname(elf, ".dynstr");
51 rpath = runpath = NULL;
52
53 #define SHOW_RPATH(B) \
54 @@ -913,7 +918,7 @@ static char *lookup_config_lib(const char *fname)
55 static const char *scanelf_file_needed_lib(elfobj *elf, char *found_needed, char *found_lib, int op, char **ret, size_t *ret_len)
56 {
57 char *needed;
58 - void *symtab_void, *strtab_void;
59 + void *strtab_void;
60 char *p;
61
62 /*
63 @@ -923,7 +928,12 @@ static const char *scanelf_file_needed_lib(elfobj *elf, char *found_needed, char
64 if ((op == 0 && !show_needed) || (op == 1 && !find_lib))
65 return NULL;
66
67 - scanelf_file_get_symtabs(elf, &symtab_void, &strtab_void);
68 + /*
69 + * TODO: Switch to the string table found via dynamic tags.
70 + * Note: We can't use scanelf_file_get_symtabs as these strings are
71 + * *only* found in dynstr and not in .strtab.
72 + */
73 + strtab_void = elf_findsecbyname(elf, ".dynstr");
74
75 #define SHOW_NEEDED(B) \
76 Elf ## B ## _Dyn *dyn; \
77 @@ -1059,11 +1069,16 @@ static const char *scanelf_file_bind(elfobj *elf, char *found_bind)
78 static char *scanelf_file_soname(elfobj *elf, char *found_soname)
79 {
80 char *soname;
81 - void *symtab_void, *strtab_void;
82 + void *strtab_void;
83
84 if (!show_soname) return NULL;
85
86 - scanelf_file_get_symtabs(elf, &symtab_void, &strtab_void);
87 + /*
88 + * TODO: Switch to the string table found via dynamic tags.
89 + * Note: We can't use scanelf_file_get_symtabs as these strings are
90 + * *only* found in dynstr and not in .strtab.
91 + */
92 + strtab_void = elf_findsecbyname(elf, ".dynstr");
93
94 #define SHOW_SONAME(B) \
95 Elf ## B ## _Dyn *dyn; \