commit:     79489b3450faac9ffcc0ffc55d57dacdfed897be
Author:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
AuthorDate: Wed Mar 18 23:57:30 2020 +0000
Commit:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
CommitDate: Wed Mar 18 23:57:30 2020 +0000
URL:        https://gitweb.gentoo.org/proj/pax-utils.git/commit/?id=79489b34

scanelf.c: be more verbose at saying what all the addresses mean

Print out relocation type and explain addresses:

```
$ ./scanelf -T -v gdb
 TYPE   TEXTRELS FILE
  gdb: (memory/data?) [r_offset=0x0] r_type=0 in (optimized out?) 
[closest_prev_sym=0x0]
  gdb: (memory/data?) [r_offset=0x0] r_type=0 in (optimized out?) 
[closest_prev_sym=0x0]
  gdb: (memory/data?) [r_offset=0x0] r_type=0 in (optimized out?) 
[closest_prev_sym=0x0]
  gdb: (memory/data?) [r_offset=0x0] r_type=0 in (optimized out?) 
[closest_prev_sym=0x0]
  gdb: (memory/data?) [r_offset=0x0] r_type=0 in (optimized out?) 
[closest_prev_sym=0x0]
  gdb: (memory/data?) [r_offset=0x0] r_type=0 in (optimized out?) 
[closest_prev_sym=0x0]
```

Note: it's now more obvious that suspicious relocations are not real
and just zero-initialized leftovers of R_*_NONE type.

Bug: https://bugs.gentoo.org/713082
Signed-off-by: Sergei Trofimovich <slyfox <AT> gentoo.org>

 scanelf.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/scanelf.c b/scanelf.c
index f99aa19..c2bda35 100644
--- a/scanelf.c
+++ b/scanelf.c
@@ -707,7 +707,8 @@ static const char *scanelf_file_textrels(elfobj *elf, char 
*found_textrels, char
                                printf("%s", elf->data + 
EGET(strtab->sh_offset) + EGET(sym->st_name)); \
                        else \
                                printf("(memory/data?)"); \
-                       printf(" [0x%lX]", (unsigned long)r_offset); \
+                       printf(" [r_offset=0x%lX]", (unsigned long)r_offset); \
+                       printf(" r_type=%lu", (unsigned long)ELF ## B ## 
_ST_TYPE(r_info)); \
                        /* now try to find the closest symbol that this rel is 
probably in */ \
                        sym = SYM ## B (elf->vdata + EGET(symtab->sh_offset)); \
                        func = NULL; \
@@ -730,8 +731,8 @@ static const char *scanelf_file_textrels(elfobj *elf, char 
*found_textrels, char
                                } else \
                                        printf("(missing symbols)"); \
                        } else \
-                               printf("(optimized out)"); \
-                       printf(" [0x%lX]\n", (unsigned long)offset_tmp); \
+                               printf("(optimized out?)"); \
+                       printf(" [closest_prev_sym=0x%lX]\n", (unsigned 
long)offset_tmp); \
                        if (be_verbose && objdump && func) { \
                                Elf ## B ## _Addr end_addr = offset_tmp + 
EGET(func->st_size); \
                                char *sysbuf; \

Reply via email to