[LLVMdev] Sorting relocation entries

Jim Grosbach grosbach at apple.com
Wed Mar 21 15:50:21 PDT 2012


Hi Akira,

If I follow correctly, the relocation entries can thus be in a different order than the instructions that they're for? That seems a bit odd, but I suppose there's nothing inherently wrong with that. It's just not something, AFAIK, that llvm has had to deal with before. This should definitely be a target-specific thing, not a general ELFObjectWriter thing, as other targets may have entirely different needs. Offhand, it seems reasonable to have a post-processing pass over the relocation list before it's written out to the file. The target can manipulate the list in whatever manner it needs to. A hook on MCELFObjectTargetWriter should do the trick.

-Jim


On Mar 19, 2012, at 1:39 PM, Akira Hatanaka <ahatanak at gmail.com> wrote:

> What would be the best way to sort relocation entries before they are
> written out in ELFObjectWriter::WriteRelocationsFragment?
> 
> According to the Mips ABI documents I have, there are certain
> restrictions on the order relocations appear in the table (e.g.
> R_MIPS_HI16 and R_MIPS_GOT16 must be followed immediately by a
> R_MIPS_LO16). When I enable post RA scheduling, some of the
> restrictions are violated in the generated object code, which results
> in incorrect relocation values generated by the linker.
> 
> I am considering imitating what gas does in function mips_frob_file
> (line 15522 of tc-mips.c) to fix this problem:
> 
> http://repo.or.cz/w/binutils.git/blob/master:/gas/config/tc-mips.c
> 
> Are there any other targets that have similar restrictions or requirements?
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




More information about the llvm-dev mailing list