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

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 6 11:54:56 PST 2017


Roland McGrath <mcgrathr at google.com> writes:

> After the static link, i.e. in any ET_EXEC or ET_DYN object, there is only
> one kind of symbol value: The st_value field is a statically "absolute"
> address that must be adjusted at runtime by the object's runtime load bias.

I disagree. As Cary points out in the binutils threads, it is valid for
a symbol to hold things like a size, which is truly absolute.

>
> In the runtime view, ELF sections are not a concept that exists, and
> neither is SHN_ABS.

I agree that it is redundant to include sections in the runtime
files. The way I look at it is that there are only 3 possibilities.

* The symbol is undefined (in ELF, section index is SHN_UNDEF).
* The symbol is an absolute value (in ELF, SHN_ABS).
* The symbol is relative to an address (in ELF, anything other
  than SHN_ABS and SHN_UNDEF).

It is a redundant that the format differentiates the various sections at
runtime, but it would be ever more redundant to have SHN_ABS to mean the
same. If you want a value that depends on where dso is loaded, just use
any section value other than SHN_ABS and SHN_UNDEF.

Cheers,
Rafael


More information about the llvm-commits mailing list