Could you elaborate the meaning of the offset? Perhaps an example will help.
Is the offset used to avoid some disassembly work for the rtld PLT optimization?
>> >> If dynamic linker is allowed to
>> >>
>> >> 1. Change PLT to writable and non-executable.
>> >> 2. Update PLT entries.
>> >> 3. Change PLT back to read-only and executable.
>> >>
>> >> scanning R_X86_64_JUMP_SLOT relocations to locate the corresponding PLT
>> >> and GOT entries, dynamic linker may change indirect branch in PLT entries
>> >> to direct branch when
>> >>
>> >> 1. Lazy binding is disabled.
>> >> 2. The PLT entry can accommodate 32-bit direct branch.
>> >> 3. The indirect branch address stored in the GOT entry can be reached
>> >> by direct branch.
>> >>
>> >> The x86-64 psABI specifies that R_X86_64_JUMP_SLOT should be resolved
>> >> to the symbol value. But dynamic linkers in glibc versions older than
>> >> 2.33 don't ignore r_addend. Non-zero r_addend in R_X86_64_JUMP_SLOT
>> >> relocation is incompatible with such dynamic linkers.
>> >>
>> >> When loading an ELF binary, dynamic linker in glibc checks the EI_OSABI
>> >> and EI_ABIVERSION fields in its ELF header. It won't load the binary if
>> >> its EI_OSABI field == ELFOSABI_GNU and its EI_ABIVERSION field >=
>> >> LIBC_ABI_MAX which is defined as
This schemes will optimize PLT among immediately loaded shared objects Their
distances are usually within 32-bit direct branches. The executable is usually
located very far away from the shared objects.
The .plt.got optimization should be dropped, then?
cat > a.c <<e
void combined0(); void combined1();
void foo0(); void foo1();
unsigned long var;
void _start() {
var = (unsigned long)combined0 + (unsigned long)combined1;
combined0(); combined1();
foo0(); foo1();
}
e
cat > b.s <<e
.globl foo0, foo1, combined0, combined1
foo0: foo1: combined0: combined1:
e
gcc -fuse-ld=bfd -shared b.s -o b.so
gcc -fuse-ld=bfd -pie -nostdlib -fpie a.c b.so -o a
.plt and .plt.got have different PLT entries, nullifying this rtld PLT rewriting optimization.
>> > This doesn't work on executables which are loaded by kernel. We can
>> > add a version dependency of glibc 2.33 similar to DT_RELR.
>>
>> That is an implementation detail.
>>
>> The kernel maps the binary, and invokes the dynamic loader.
>>
>> The dynamic loader should be doing whatever checks it needs to do to ensure compatibility.
>>
>> Isn't a glibc bug that the loader doesn't check EI_ABIVERSION for a kernel loaded binary?
>
>We can't change existing ld.so to check EI_ABIVERSION for a kernel
>loaded binary. For DT_RELR, linker adds the GLIBC_ABI_DT_RELR
>version dependency so that DT_RELR will fail to run with existing
>ld.so which doesn't provide GLIBC_ABI_DT_RELR. We should do the
>same for R_X86_64_JUMP_SLOT with non-zero r_addend.
If the r_addend is repurposed, I agree that a symbol version similar to GLIBC_ABI_DT_RELR will work.
glibc reports an error if a Verneed is not defined.
>> >> enum
>> >> {
>> >> LIBC_ABI_DEFAULT = 0,
>> >> LIBC_ABI_UNIQUE,
>> >> LIBC_ABI_IFUNC,
>> >> LIBC_ABI_ABSOLUTE,
>> >> LIBC_ABI_MAX
>> >> };
>> >>
>> >> When non-zero r_addend in R_X86_64_JUMP_SLOT relocation, linker should
>> >> set the EI_OSABI field to ELFOSABI_GNU and the EI_ABIVERSION field to
>> >> LIBC_ABI_PLT define as
>> >>
>> >> enum
>> >> {
>> >> LIBC_ABI_DEFAULT = 0,
>> >> LIBC_ABI_UNIQUE,
>> >> LIBC_ABI_IFUNC,
>> >> LIBC_ABI_ABSOLUTE,
>> >> LIBC_ABI_PLT,
>> >> LIBC_ABI_MAX
>> >> };
>> >>
>> >> Dynamic linker in glibc should be updated to allow ELF binaries with
>> >> EI_OSABI == ELFOSABI_GNU and EI_ABIVERSION == LIBC_ABI_PLT.
>> >>
>> >>
>> >> H.J.
>> >
>> >
>> >
>>
>> --
>> Cheers,
>> Carlos.
>>
>
>
>--
>H.J.
>
>--
>You received this message because you are subscribed to the Google Groups "X86-64 System V Application Binary Interface" group.
>To unsubscribe from this group and stop receiving emails from it, send an email to
x86-64-abi+...@googlegroups.com.
>To view this discussion on the web visit
https://groups.google.com/d/msgid/x86-64-abi/CAMe9rOpiRS4Co1-%2BY_hTbM0WDUocf%3Dkpanfd8N%3D6tFSuk6eEpA%40mail.gmail.com.