[PATCH] elf: Support DT_RELR relative relocation format [BZ #27924]

Cary Coutant ccoutant@gmail.com
Tue Oct 26 23:28:29 GMT 2021


> While in line with the proposed spec additions I'm afraid the uses of
> ElfW(Addr) here aren't universally correct: You assume that ELF
> container type (size) expresses an aspect of the ABI. While this is
> indeed the case for several arch-es, I think this has been a mistake.
> IA-64, while meanwhile mostly dead, is (was) an example where 64-bit
> code can validly live in a 32-bit ELF container (at least as far as
> the psABI is concerned; I have no idea whether glibc actually
> followed the spec). There's a separate ELF header flag indicating the
> ABI, and hence the size of a pointer.

The IA-64 ABI specifically requires the class of the container
(ELFCLASS32 vs ELFCLASS64) to match the runtime model for executable
objects. It's allowable to use ELFCLASS32 for 64-bit relocatable
objects, but not for executable objects. Thus, I think it's quite
reasonable to spec it this way, and it really isn't any different from
a non-RELR relocation. For executables, there really are strong ties
between the ELF container size and the runtime model.

One point that I don't think has been raised yet is that some
platforms, like IA-64, may have more than one RELATIVE relocation.
IA-64 has four -- R_IA64_REL{32|64}{MSB|LSB} -- only one of which
would be eligible (or expected) in a RELR context. I'm thinking that a
DT_RELRTYPE entry specifying the relocation type might be called for,
just to make it explicit. I suppose it could be optional for platforms
where there is only one choice of R_XXX_RELATIVE.

-cary


More information about the Libc-alpha mailing list