[llvm-commits] [llvm] r131205 - in /llvm/trunk/lib/MC: ELFObjectWriter.cpp ELFObjectWriter.h

Jason Kim jasonwkim at google.com
Fri May 13 14:50:05 PDT 2011

On Thu, May 12, 2011 at 6:13 PM, Rafael Ávila de Espíndola
<rafael.espindola at gmail.com> wrote:
> On 11-05-11 6:53 PM, Jason W Kim wrote:
>> Author: jasonwkim
>> Date: Wed May 11 17:53:06 2011
>> New Revision: 131205
>> URL: http://llvm.org/viewvc/llvm-project?rev=131205&view=rev
>> Log:
>> Address the last bit of relocation flag related divergence betweeen
>> LLVM and binutils.
>> With this patch, there are no functional differences between the .o
>> produced directly from LLVM versus the .s to .o via GNU as, for relocation tags
>> at least, for both PIC and non-PIC modes.
>> Because some non-PIC reloc tags are used (legally) on PIC, so IsPCRel flag is
>> necessary but not sufficient to determine whether the overall codegen mode is
>> PIC or not. Why is this necessary? There is an incompatibility of how relocs
>> are emitted in the .rodata section.  Binutils PIC likes to emit certain relocs
>> as section relative offsets.  Non-PIC does not do this.
>> So I added a hidden switch on the ELFObjectwriter "-arm-elf-force-pic" which
>> forces the objectwriter to pretend that all relocs are for PIC mode.
>> Todo: Activate ForceARMElfPIC to true if -relocation-model=pic is selected
>> on llc.
> Is this ARM only? On X86 at least no flag is passed to the assembler


> indicating that a given file is PIC or not. Since the MC interface is
> isomorphic with the assembler, llc should not pass any flags to mc.

That switch is necessary for producing code that is identical to gas.

This is a tough call.

Either we live with a hidden switch or make it "nicer" by linking the
two switches, or give MC access to upstream codegen internals.
Linking the cmdline switches  is the solution of least work, but I'm
punting on it for now

> Cheers,
> Rafael
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

More information about the llvm-commits mailing list