[PATCH] D74824: [objdump] Fix disassembly for call/branch instructions for ELF binaries built with -ffunction-sections

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 19 18:14:47 PST 2020


MaskRay added inline comments.


================
Comment at: llvm/test/tools/llvm-objdump/X86/demangle.s:14
 # INLINE:      foo():
-# INLINE-NEXT:  0: {{.*}}  callq   0 <_Z3foov+0x5>
+# INLINE-NEXT:  0: {{.*}}  callq   0 <_Z3foov>
 # INLINE-NEXT:  0000000000000001:  R_X86_64_PLT32 foo()-0x4
----------------
The addend is incorrectly dropped.


================
Comment at: llvm/test/tools/llvm-objdump/X86/elf-disassemble-relocs.test:10
 # CHECK-NEXT:          0000000000000002:  R_X86_64_NONE        bar+0x8
-# CHECK-NEXT: 5: e8 00 00 00 00                callq   0 <.text+0xa>
-# CHECK-NEXT:          0000000000000006:  R_X86_64_PLT32       foo+0x1
+# CHECK-NEXT: 5: e8 00 00 00 00                callq   0 <whiz>
+# CHECK-NEXT:          0000000000000006:  R_X86_64_PLT32       whiz+0x1
----------------
This is not correct. `whiz` is undefined. It is incorrect to symbolize with an undefined symbol.

`objdump -d` does not print the symbol:

```
  5:   e8 00 00 00 00          callq  0xa
                        6: R_X86_64_PLT32       whiz+0x1
```




================
Comment at: llvm/test/tools/llvm-objdump/X86/section-filter-relocs.test:13
 # DISASM-NEXT:  0000000000000400 .text:
-# DISASM-NEXT:  400: e8 00 00 00 00                callq   0 <.text+0x5>
+# DISASM-NEXT:  400: e8 00 00 00 00                callq   0 <foo>
 # RELOC-NEXT:                      00000401:  R_X86_64_PC32        foo+0x1
----------------
`foo` is undefined. It is not correct to symbolize with an undefined symbol. The problem is that the display can get addends wrong.

For disassembly of object files, I think users should realize that they need to use `-d -r`.


================
Comment at: llvm/test/tools/llvm-objdump/xcoff-disassemble-all.test:3
+# RUN: FileCheck %s --check-prefixes=CHECK,NO-RELOC-OPTION
+# RUN: llvm-objdump -D -r %p/Inputs/xcoff-section-headers.o 2>&1 | \
+# RUN: FileCheck %s --check-prefixes=CHECK,RELOC-OPTION
----------------
You can move XCOFF support to a separate change.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74824/new/

https://reviews.llvm.org/D74824





More information about the llvm-commits mailing list