[Bug dynamic-link/31317] [RISCV] static PIE crashes during self relocation
yanzhang.wang at intel dot com
sourceware-bugzilla@sourceware.org
Fri Feb 23 03:06:56 GMT 2024
https://sourceware.org/bugzilla/show_bug.cgi?id=31317
--- Comment #6 from Wang, Yanzhang <yanzhang.wang at intel dot com> ---
I think the l_relocated is enough too.
I have did some investigation about this in the GNU ld and mold. If I
understand correctly, the mold will fill the relocated field if the command
option --apply-dynamic-relocs is true, whose default value is true.
But for GNU ld, this is ignored and skipped at
elfnn-riscv.c:riscv_elf_relocate_section
sreloc = elf_section_data (input_section)->sreloc;
riscv_elf_append_rela (output_bfd, sreloc, &outrel);
if (!relocate)
continue;
Although the relative rel has been computed but the relocate is true, so we do
nothing.
It seems this is not defined explicit somewhere and all the two different
behaviors seems right.
For this case, the l_scope in dl_main_map is a pointer and need relocate. In
the mold linker, the value in relocated field will be the value of global
dl_main_map's location. But in GNU ld, the value will be 0.
So we need only to use the l_relocated, it's a value which will not be relocaed
and will be set at the end of _dl_relocate_static_pie.
--
You are receiving this mail because:
You are on the CC list for the bug.
More information about the Glibc-bugs
mailing list