From 8cc687cbacf4f2b9950e7ac4b3738e0add136098 Mon Sep 17 00:00:00 2001 From: Adhemerval Zanella Date: Fri, 18 Apr 2025 09:49:59 -0300 Subject: [PATCH] x86_64: Fix UB on plt rewrite The elf/tst-plt-rewrite2 and elf/tst-plt-rewrite2 triggers the failures with ubsan: UBSAN: Undefined behaviour in ../sysdeps/x86_64/dl-machine.h:637:39 store to misaligned address 0x00007adb50230021 for type 'uint32_t' --- sysdeps/x86_64/dl-machine.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sysdeps/x86_64/dl-machine.h b/sysdeps/x86_64/dl-machine.h index 572a1a7395..3799894589 100644 --- a/sysdeps/x86_64/dl-machine.h +++ b/sysdeps/x86_64/dl-machine.h @@ -633,7 +633,7 @@ x86_64_rewrite_plt (struct link_map *map, ElfW(Addr) plt_rewrite) /* Write out direct branch. */ *(uint8_t *) branch_start = JMP32_INSN_OPCODE; - *(uint32_t *) (branch_start + 1) = disp; + memcpy ((void *)(branch_start + 1), &disp, sizeof (uint32_t)); } else { -- 2.47.2