[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug ld/27119] ld improperly relocates function address, creating an inv
From: |
me at rhysre dot net |
Subject: |
[Bug ld/27119] ld improperly relocates function address, creating an invalid pointer |
Date: |
Mon, 28 Dec 2020 23:45:05 +0000 |
https://sourceware.org/bugzilla/show_bug.cgi?id=27119
--- Comment #2 from Rhys Rustad-Elliott <me at rhysre dot net> ---
(In reply to H.J. Lu from comment #1)
> Please try
>
> [hjl@gnu-cfl-2 pr27119]$ cat link.lds
> OUTPUT_FORMAT("elf64-x86-64")
> OUTPUT_ARCH(i386:x86-64)
> ENTRY(_start)
>
> SECTIONS
> {
> . = 0x0000000001000000;
> .text : {
> *(.text)
> }
> .data : {
> *(.data)
> }
> }
> [hjl@gnu-cfl-2 pr27119]$ make
> gcc -B./ -fPIE -c -o prog.o prog.c
> gcc -B./ -fPIE -c -o func.o func.c
> ./ld -pie -o prog prog.o func.o -T link.lds
> objcopy -O binary prog binary
> [hjl@gnu-cfl-2 pr27119]$ radare2 -a x86 -b 64 binary
> -- Setup dbg.fpregs to true to visualize the fpu registers in the debugger
> view.
> [0x00000000]> pd 12
> 0x00000000 55 push rbp
> 0x00000001 4889e5 mov rbp, rsp
> 0x00000004 488d05070000. lea rax, [0x00000012] ;
> "UH\x89\xe5\x90]\xc3"
> 0x0000000b 488945f8 mov qword [rbp - 8], rax
> 0x0000000f 90 nop
> 0x00000010 5d pop rbp
> 0x00000011 c3 ret
> 0x00000012 55 push rbp
> 0x00000013 4889e5 mov rbp, rsp
> 0x00000016 90 nop
> 0x00000017 5d pop rbp
> 0x00000018 c3 ret
> [0x00000000]>
Confirming that linking to an ELF and then using objcopy to convert it to a
flat binary works around this issue for me as described here.
I assume regardless that this behavior should still be considered a bug in ld
though right?
--
You are receiving this mail because:
You are on the CC list for the bug.
- [Bug ld/27119] New: ld improperly relocates function address, creating an invalid pointer, me at rhysre dot net, 2020/12/28
- [Bug ld/27119] ld improperly relocates function address, creating an invalid pointer, me at rhysre dot net, 2020/12/28
- [Bug ld/27119] ld improperly relocates function address, creating an invalid pointer, hjl.tools at gmail dot com, 2020/12/28
- [Bug ld/27119] ld improperly relocates function address, creating an invalid pointer,
me at rhysre dot net <=
- [Bug ld/27119] ld improperly relocates function address, creating an invalid pointer, hjl.tools at gmail dot com, 2020/12/28
- [Bug ld/27119] ld improperly relocates function address, creating an invalid pointer, amonakov at gmail dot com, 2020/12/29
- [Bug ld/27119] ld improperly relocates function address, creating an invalid pointer, hjl.tools at gmail dot com, 2020/12/29