[PATCH] D26133: [ELF] Allow relative relocations to absolute symbols in PIC

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 13 05:48:32 PST 2016

Petr Hosek <phosek at google.com> writes:

> You don't need a dynamic relocation in this case because the symbol is
> hidden (which is the same as if it was local) as the address can be can be
> computed statically at link time (relative to the image base). If you
> remove .hidden, then both gas and mc generate relocation as expected
> because now the address cannot be determined at link time.

Not if you are going to interpret it as being image based. If it is
image based then you need a dynamic relocation since we have no idea
where the image will end. If SHN_ABS is image relative, then a and b
need similar treatment in:

.global a
.hidden a
.global b
.hidden b
b = 42

.quad a
.quad b

and a needs a R_X86_64_RELATIVE, while b being absolute (not image
relative) does not.


More information about the llvm-commits mailing list