Skip to content

Commit 9b99abc

Browse files
author
George Rimar
committedJul 5, 2018
[ELF] - Advance position in a memory region when change the Dot.
This is https://bugs.llvm.org//show_bug.cgi?id=37836 Previously LLD could assign to Dot or set the address for the section with address expression but did not advance the position in a memory region. Patch fixes the issue. llvm-svn: 336335
1 parent 13f9425 commit 9b99abc

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed
 

‎lld/ELF/LinkerScript.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ void LinkerScript::setDot(Expr E, const Twine &Loc, bool InSec) {
135135
// Update to location counter means update to section size.
136136
if (InSec)
137137
expandOutputSection(Val - Dot);
138+
else
139+
expandMemoryRegions(Val - Dot);
140+
138141
Dot = Val;
139142
}
140143

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# REQUIRES: x86
2+
# RUN: echo ".section .text,\"ax\"; nop; .section .data,\"aw\"; nop;" \
3+
# RUN: | llvm-mc -filetype=obj -triple=x86_64-pc-linux - -o %t.o
4+
# RUN: ld.lld -o %t.so --script %s %t.o
5+
# RUN: llvm-objdump -section-headers %t.so | FileCheck %s
6+
7+
# CHECK: 1 .text 00000001 0000000000042000
8+
# CHECK-NEXT: 2 .data 00000001 0000000000042400
9+
10+
## Test that address expressions changes the position in a memory region.
11+
12+
MEMORY {
13+
ram (wxa) : ORIGIN = 0x42000, LENGTH = 0x100000
14+
}
15+
SECTIONS {
16+
.text : { *(.text*) }
17+
data_addr = ALIGN(1024);
18+
.data data_addr : { *(.data*) }
19+
}
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# REQUIRES: x86
2+
# RUN: echo ".section .text,\"ax\"; nop; .section .data,\"aw\"; nop;" \
3+
# RUN: | llvm-mc -filetype=obj -triple=x86_64-pc-linux - -o %t.o
4+
# RUN: ld.lld -o %t.so --script %s %t.o
5+
# RUN: llvm-objdump -section-headers %t.so | FileCheck %s
6+
7+
# CHECK: 1 .text 00000001 0000000000042000
8+
# CHECK-NEXT: 2 .data 00000001 0000000000044001
9+
10+
## Test that assign to Dot changes the position in a memory region.
11+
12+
MEMORY {
13+
ram (wxa) : ORIGIN = 0x42000, LENGTH = 0x100000
14+
}
15+
SECTIONS {
16+
.text : { *(.text*) }
17+
. += 0x2000;
18+
.data : { *(.data*) }
19+
}

0 commit comments

Comments
 (0)
Please sign in to comment.