[RFC v3] RISC-V: Fix SIGSEGV of --static-pie binaries on riscv64 [BZ #33911]
Andreas Schwab
schwab@suse.de
Mon Mar 9 12:47:18 GMT 2026
On Mär 08 2026, daichengrong wrote:
> diff --git a/sysdeps/riscv/dl-machine.h b/sysdeps/riscv/dl-machine.h
> index 8c7312ad98..0c6b55c3f3 100644
> --- a/sysdeps/riscv/dl-machine.h
> +++ b/sysdeps/riscv/dl-machine.h
> @@ -157,10 +157,17 @@ __attribute__ ((always_inline))
> elf_machine_rela_relative (ElfW(Addr) l_addr, const ElfW(Rela) *reloc,
> void *const reloc_addr)
> {
> - /* R_RISCV_RELATIVE might located in debug info section which might not
> - aligned to XLEN bytes. Also support relocations on unaligned offsets. */
> - ElfW(Addr) value = l_addr + reloc->r_addend;
> - memcpy (reloc_addr, &value, sizeof value);
> +#if __riscv_xlen == 64
> + uint64_t value = l_addr + reloc->r_addend;
> +
> + uint32_t lo = (uint32_t)value;
> + uint32_t hi = (uint32_t)(value >> 32);
> +
> + ((uint32_t*)reloc_addr)[0] = lo;
> + ((uint32_t*)reloc_addr)[1] = hi;
Why do you need to split the store?
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
More information about the Libc-alpha
mailing list