[llvm-dev] [llvm] r263971 - [llvm-objdump] Printing relocations in executable and shared object files. This partially reverts r215844 by removing test objdump-reloc-shared.test which stated GNU objdump doesn't print relocations, it does.
Colin LeMahieu via llvm-dev
llvm-dev at lists.llvm.org
Thu Mar 24 10:14:53 PDT 2016
While trying to fix a bug where llvm-objdump isn't printing relocations retained with ld -emit-relocs in shared object or executables, it seems like there isn't a way to split printing dynamic relocations from non-dynamic relocations as with GNU objdump -r and -R.
I was thinking of adding a function RelocationRef::isDynamic() and filtering them this way when printing.
Since RelocationRef covers ELF/COFF/MachO we would need reasonable behaviors for each platform.
Does this seem like a good approach and does anyone have input on how this function should behave on COFF/MachO?
-----Original Message-----
From: Rafael EspĂndola [mailto:rafael.espindola at gmail.com]
Sent: Tuesday, March 22, 2016 10:42 AM
To: Colin LeMahieu <colinl at codeaurora.org>
Cc: llvm-commits <llvm-commits at lists.llvm.org>
Subject: Re: [llvm] r263971 - [llvm-objdump] Printing relocations in executable and shared object files. This partially reverts r215844 by removing test objdump-reloc-shared.test which stated GNU objdump doesn't print relocations, it does.
On 22 March 2016 at 11:36, Colin LeMahieu <colinl at codeaurora.org> wrote:
> Thanks for the prompt reply and test case, I'll make sure this is considered.
>
> Admittedly I know less about the ELF spec than you do; I appreciate the patience while I try to contribute a fix for the incorrect logic in llvm-objdump and the ELFObjectFile.h that assumes relocations don't exist in executable or shared object files.
>
> If you have suggestions that could prevent future issues I appreciate the feedback.
The main one is: the assert is correct. Asking for the offset in a .so file is a bug in whatever is asking. If a tool wants to know the offset of a relocation in a section (objdump does), it needs to
* Find out if there is a section table at all, it is valid to omit it.
* Build a map of addresses to sections.
* Look up the address of a given relocation.
* Have a reasonable error/degradation if any of the above fails.
Cheers,
Rafael
More information about the llvm-dev
mailing list