[PATCH] D88076: [llvm-readelf/obj] - Stop printing wrong addresses for arm32 unwind info for non-relocatable objects.

Peter Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 22 11:45:58 PDT 2020


psmith added a comment.

I think there may still be problems in a non-relocatable ELF file when there is more than one executable output section as there is only one .ARM.exidx output section and only one sh_link.



================
Comment at: llvm/test/tools/llvm-readobj/ELF/ARM/unwind-non-relocatable.test:69
+    ContentArray: [
+## Entry 1. Address of .ARM.exidx (0x24C) + entry offset (8) + 0x7fffffe4 == 0x230 (func1).
+                    0xE4, 0xFF, 0xFF, 0x7F, ## Word(0) = 0x7fffffe4.
----------------
entry offset should be (0) for the first entry


================
Comment at: llvm/tools/llvm-readobj/ARMEHABIPrinter.h:547
+    // offset to the referenced entity.
+    const uint64_t Offset =
+        IsRelocatable
----------------
Offset is a bit confusing in this context. As I understand it, it is an offset for relocatable objects but an absolute address for non-relocatable objects.


================
Comment at: llvm/tools/llvm-readobj/ARMEHABIPrinter.h:549
+        IsRelocatable
+            ? PREL31(Word0, IT->sh_addr)
+            : PREL31(Word0, IT->sh_addr + Entry * IndexTableEntrySize);
----------------
You may want to replace the IT->sh_addr with 0 rather than using the 0 from the relocatable object sh_addr, not a strong opinion though.




================
Comment at: llvm/tools/llvm-readobj/ARMEHABIPrinter.h:552
     SW.printHex("FunctionAddress", Offset);
     if (ErrorOr<StringRef> Name = FunctionAtAddress(IT->sh_link, Offset))
       SW.printString("FunctionName", *Name);
----------------
For a non-relocatable ELF file the sh_link field is not reliable as there can be more than one OutputSection, but there will only be one .ARM.exidx OutputSection and the sh_link can only point to one OutputSection. I think that FunctionAtAddress will need changing so that it doesn't require a matching section when there is non-relocatable objects.




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

https://reviews.llvm.org/D88076



More information about the llvm-commits mailing list