[lld] r263228 - Simplify now that local symbols can use getVA.

Simon Atanasyan via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 22 08:15:33 PDT 2016


On Wed, Mar 16, 2016 at 7:02 PM, Rafael EspĂ­ndola
<rafael.espindola at gmail.com> wrote:
>> Probably we are both right but talking about different things. Could
>> you remember me the case when MIPS differentiates symbols that are
>> born local and those that become local because of hidden visibility? I
>> thought you mean the case when public symbol behaves like a local one
>> from GOT point of view.
>
> What I mean is that I would expect both
>
> -------------------
>   lw      $t0,%got(foo+0x10004)($gp)
>   .data
> foo:
>   .word 0
> -------------------
>
> and
>
> ------------------------
>   lw      $t0,%got(foo+0x10004)($gp)
>   .data
> .global foo
> .hidden foo
> foo:
>   .word 0
> -------------------------
>
> to produce equivalent outputs, but they don't:

For "true" local symbols which can be referenced from the same module
only compiler creates two instructions for address loading:

lw   $8, 0($gp) # R_MIPS_GOT16
addi $8, $8, 0  # R_MIPS_LO16

The first instruction loads high 16 bits of the symbol address while
the second adds an offset. That allows to reduce number of required
GOT entries because only one global offset table entry is necessary
for every 64 KBytes of local data.

Hidden global symbols can be referenced from other object files. And
compiler might do not know that the symbol is hidden. So the compiler
creates a single instruction to load the symbol address and expect
that the corresponding GOT entry holds complete address of the symbol.

-- 
Simon Atanasyan


More information about the llvm-commits mailing list