[PATCH] D19995: Optimize access to global variable references in PIE mode when linker supports copy relocations for PIE

H.J. Lu via llvm-commits llvm-commits at lists.llvm.org
Mon May 9 08:28:34 PDT 2016


On Mon, May 9, 2016 at 8:09 AM, Joerg Sonnenberger via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
> On Mon, May 09, 2016 at 08:08:28AM -0700, H.J. Lu wrote:
>> On Mon, May 9, 2016 at 7:53 AM, Joerg Sonnenberger via llvm-commits
>> <llvm-commits at lists.llvm.org> wrote:
>> > On Mon, May 09, 2016 at 07:30:20AM -0700, H.J. Lu wrote:
>> >> > The original ABI design was static linking and dynamic linking of the
>> >> > main program from exactly the same object files. Using GOT-style
>> >> > relocations is prohibitive on all platforms without cheap PC-relative
>> >> > addressing. This includes for example i386. I don't know why amd64
>> >>
>> >> You can use the new R_386_GOT32X relocation to access the
>> >> GOT in executable with the base register, like
>> >>
>> >> movl $foo at GOT, %eax
>> >> movl foo at GOT, %eax
>> >>
>> >> But not all linkers can relocate it properly.
>> >
>> > But that still requires the base register to be set up?
>>
>> The same as x86-64.
>
> Huh? AMD64 can address data explicitly via (%rip). i386 has no such
> index register, so normally uses %ebx for that?
>

See my example above.  There is no base register at all.

-- 
H.J.


More information about the llvm-commits mailing list