First of all, never spill symbolic addresses to the constant pool. This
creates costly dynamic relocations while providing little benefit.
Second, due to a bug, we were failing to elide the GOT for local symbol
references with nonzero offsets.
The low part uses an indirect relocation to the high part to determine
how to fill itself in. For example:
.L1:
auipc t0, %pcrel_hi(foo)
[unrelated code]
addi t0, t0, %pcrel_lo(.L1)
will correctly load &foo into t0.
It turns out that this instruction sequence can be generated to call
an absolute address. This adds a comment to the JALR with the full
expanded address, which is useful for debugging (it turns out it's
easier to just let my PC do addition rather than having to do it in my
head).
Note that amd64 does this exact thing, so it's probably correct... :)
Signed-off-by: Palmer Dabbelt <palmer.dabbelt@eecs.berkeley.edu>
Doing so removes their commonness, as though -fno-common had been set.
The sbss optimization is still available by specifying -fno-common.
h/t Matt Thomas