-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviorlinkingmiscompilationThe compiler reports success but produces semantically incorrect code.The compiler reports success but produces semantically incorrect code.upstreamAn issue with a third party project that Zig uses.An issue with a third party project that Zig uses.
Milestone
Description
One more bug for our LLVM friends, this time the problem is inside the linker guts!
ASM file:
.section ".text","ax"
.global _start
.arm
.align 4
_start:
b _startLinker script:
OUTPUT_ARCH(arm)
ENTRY(_start)
PHDRS {
p0 PT_LOAD FLAGS(7);
p1 PT_LOAD FLAGS(7);
}
MEMORY {
m0 : ORIGIN = 0x1000, LENGTH = 0x1000
m1 : ORIGIN = 0x8000, LENGTH = 0x1000
}
SECTIONS
{
.s0 :
{
*(.s0)
} >m1 AT>m0 :p0
.s1 :
{
KEEP (*(.text))
KEEP (*(.data))
KEEP (*(.bss))
} >m0 :p1
}
Linked using the following command line: ld.lld-10 -T /tmp/script.ld /tmp/foo.o -o /tmp/foo
Version: 1:10~++20200228052623+4c6e5899859-1~exp1~20200228163220.107 (from the LLVM's APT repo)
The problem lies in how the physical address of the program headers is calculated, the value computed by lld is wildly wrong:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
LOAD 0x001000 0x00001000 0xffffa000 0x00004 0x00004 RWE 0x1000
On the other hand gnu ld produces the correct result:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
LOAD 0x000074 0x00000000 0x00000000 0x00000 0x00000 RWE 0x10000
LOAD 0x001000 0x00001000 0x00001000 0x00004 0x00004 RWE 0x10000
Metadata
Metadata
Assignees
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviorlinkingmiscompilationThe compiler reports success but produces semantically incorrect code.The compiler reports success but produces semantically incorrect code.upstreamAn issue with a third party project that Zig uses.An issue with a third party project that Zig uses.