aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2017-01-24 10:22:26 -1000
committerMike Frysinger <vapier@gentoo.org>2017-01-24 10:22:26 -1000
commit6a73ea4e32cc6ff6d1814048368b7b75da626565 (patch)
treeee88a473cabfab0b40b1e06af6ad7b5ae9e0ba87
parentscanelf: switch all string table lookups to scanelf_file_get_symtabs (diff)
downloadpax-utils-6a73ea4e32cc6ff6d1814048368b7b75da626565.tar.gz
pax-utils-6a73ea4e32cc6ff6d1814048368b7b75da626565.tar.bz2
pax-utils-6a73ea4e32cc6ff6d1814048368b7b75da626565.zip
scanelf: revert back to looking at .dynstr directly
The rpath/needed/soname strings are only listed in .dynstr, so trying to locate them in .strtab fails. Which means using the lookup helper breaks behavior on non-stripped files.
-rw-r--r--TODO4
-rw-r--r--scanelf.c27
2 files changed, 25 insertions, 6 deletions
diff --git a/TODO b/TODO
index be2d0a2..ded1158 100644
--- a/TODO
+++ b/TODO
@@ -30,3 +30,7 @@ allow digging into ARM_ATTRIBUTES (.ARM.attributes) sections
- need info on the section layout
- figure out how to integrate cleanly (target-independent driller)
http://sourceware.org/binutils/docs/as/GNU-Object-Attributes.html
+
+scanelf should look at the dynamic table for rpath/needed/soname entries instead
+of requiring section headers and looking up by section names. need to implement
+support for GNU_HASH first though so we can get the string table sizes.
diff --git a/scanelf.c b/scanelf.c
index 9695276..79ce59c 100644
--- a/scanelf.c
+++ b/scanelf.c
@@ -767,11 +767,16 @@ static void rpath_security_checks(elfobj *elf, char *item, const char *dt_type)
static void scanelf_file_rpath(elfobj *elf, char *found_rpath, char **ret, size_t *ret_len)
{
char *rpath, *runpath, **r;
- void *symtab_void, *strtab_void;
+ void *strtab_void;
if (!show_rpath) return;
- scanelf_file_get_symtabs(elf, &symtab_void, &strtab_void);
+ /*
+ * TODO: Switch to the string table found via dynamic tags.
+ * Note: We can't use scanelf_file_get_symtabs as these strings are
+ * *only* found in dynstr and not in .strtab.
+ */
+ strtab_void = elf_findsecbyname(elf, ".dynstr");
rpath = runpath = NULL;
#define SHOW_RPATH(B) \
@@ -913,7 +918,7 @@ static char *lookup_config_lib(const char *fname)
static const char *scanelf_file_needed_lib(elfobj *elf, char *found_needed, char *found_lib, int op, char **ret, size_t *ret_len)
{
char *needed;
- void *symtab_void, *strtab_void;
+ void *strtab_void;
char *p;
/*
@@ -923,7 +928,12 @@ static const char *scanelf_file_needed_lib(elfobj *elf, char *found_needed, char
if ((op == 0 && !show_needed) || (op == 1 && !find_lib))
return NULL;
- scanelf_file_get_symtabs(elf, &symtab_void, &strtab_void);
+ /*
+ * TODO: Switch to the string table found via dynamic tags.
+ * Note: We can't use scanelf_file_get_symtabs as these strings are
+ * *only* found in dynstr and not in .strtab.
+ */
+ strtab_void = elf_findsecbyname(elf, ".dynstr");
#define SHOW_NEEDED(B) \
Elf ## B ## _Dyn *dyn; \
@@ -1059,11 +1069,16 @@ static const char *scanelf_file_bind(elfobj *elf, char *found_bind)
static char *scanelf_file_soname(elfobj *elf, char *found_soname)
{
char *soname;
- void *symtab_void, *strtab_void;
+ void *strtab_void;
if (!show_soname) return NULL;
- scanelf_file_get_symtabs(elf, &symtab_void, &strtab_void);
+ /*
+ * TODO: Switch to the string table found via dynamic tags.
+ * Note: We can't use scanelf_file_get_symtabs as these strings are
+ * *only* found in dynstr and not in .strtab.
+ */
+ strtab_void = elf_findsecbyname(elf, ".dynstr");
#define SHOW_SONAME(B) \
Elf ## B ## _Dyn *dyn; \