[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-commits llvm-commits at lists.llvm.org
Wed Mar 23 10:12:39 PDT 2016


I'm working on the not printing dynamic relocations for -r, that part makes sense.

It seems like the semantics of RelocationRef::getOffset and ObjectFile::getRelocationOffset is to get the offset within the target section that will be fixed up; it seems like this would apply to relocatable files as well as executables and shared object files if relocations are emitted.

Could you detail on why it's an error to query for this?

-----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-commits mailing list