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

Rafael EspĂ­ndola via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 22 08:36:36 PDT 2016

> 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.

I see. Could you add that as a comment?

What does the compiler do when the symbol is know to be hidden? I ask
because the decision for "one entry per symbol" versus "one entry per
page" seems something that should be decided based on the relocation.
In fact, a single symbol might require both entries if the compiler
uses the instruction pair above when it knows the symbol is hidden:

a.c: refers to a know hidden symbol foo: foo needs a page entry in the got.
b.c: refers to a regular undef foo: foo needs a full address entry in the got.


More information about the llvm-commits mailing list