[PATCH] elf: Add _dl_ehdr_start_before_reloc

H.J. Lu hjl.tools@gmail.com
Sun Jun 15 04:34:33 GMT 2025


rtld.c has

extern const ElfW(Ehdr) __ehdr_start attribute_hidden;
...
  _dl_rtld_map.l_map_start = (ElfW(Addr)) &__ehdr_start;

As

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120653

shows, compiler may generate run-time relocation on __ehdr_start with

movq .LC0(%rip), %xmm0
...
.section .data.rel.ro.local,"aw"
.align 8
.LC0:
.quad __ehdr_start

This won't work before run-time relocation is finished in rtld.c.  Define
_dl_ehdr_start_before_reloc to allow x86-64 to generate LEA to avoid
run-time relocation on __ehdr_start in rtld.c.


-- 
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-elf-Add-_dl_ehdr_start_before_reloc.patch
Type: text/x-patch
Size: 5450 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/libc-alpha/attachments/20250615/b87da72f/attachment.bin>


More information about the Libc-alpha mailing list