-
Notifications
You must be signed in to change notification settings - Fork 43
Open
Description
We have incorrect layout when there is a forward reference in a dot assignment.
Reproducer:
#!/usr/bin/env bash
cat >1.c <<\EOF
int foo() { return 1; }
int val = 3;
EOF
cat > script.t << '!'
SECTIONS {
. = u;
.text : { *(.text*) }
.data : { *(.data*) }
.comment : { *(.comment*) }
u = 0x3000;
}
!
LDs=(ld.eld ld.lld aarch64-none-elf-ld.bfd)
SFs=(eld lld bfd)
clang -o 1.o --target=aarch64-unknown-elf 1.c -c -ffunction-sections
for i in "${!SFs[@]}"; do
${LDs[$i]} -o 1.${SFs[$i]}.out 1.o -T script.t -Map 1.${SFs[$i]}.map.txt
doneRunning llvm-readelf -S 1.eld.out outputs:
There are 7 section headers, starting at offset 0x1280:
Section Headers:
[Nr] Name Type Address Off Size ES Flg Lk Inf Al
[ 0] NULL 0000000000000000 000000 000000 00 0 0 0
[ 1] .text PROGBITS 0000000000000000 001000 000008 00 AX 0 0 4
[ 2] .data PROGBITS 0000000000000008 001008 000004 00 WA 0 0 4
[ 3] .comment PROGBITS 0000000000000000 00100c 0000ce 01 MS 0 0 1
[ 4] .shstrtab STRTAB 0000000000000000 0010da 000030 00 0 0 1
[ 5] .symtab SYMTAB 0000000000000000 001110 000108 18 6 8 8
[ 6] .strtab STRTAB 0000000000000000 001218 00002d 00 0 0 1
The address of .text section should be 0x3000 instead of 0x1000.
Metadata
Metadata
Assignees
Labels
No labels