diff options
| author | George Rimar <grimar@accesssoftek.com> | 2018-07-05 10:44:17 +0000 |
|---|---|---|
| committer | George Rimar <grimar@accesssoftek.com> | 2018-07-05 10:44:17 +0000 |
| commit | 9b99abcf99956118fd0e13fcb50e510bf68e1134 (patch) | |
| tree | 129bcb96aa852ec3d22baecfb65f8806564d5783 | |
| parent | 13f9425e3a9afc8e8bfa6314de1a4a1d266d9a76 (diff) | |
| download | bcm5719-llvm-9b99abcf99956118fd0e13fcb50e510bf68e1134.tar.gz bcm5719-llvm-9b99abcf99956118fd0e13fcb50e510bf68e1134.zip | |
[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
| -rw-r--r-- | lld/ELF/LinkerScript.cpp | 3 | ||||
| -rw-r--r-- | lld/test/ELF/linkerscript/memory4.test | 19 | ||||
| -rw-r--r-- | lld/test/ELF/linkerscript/memory5.test | 19 |
3 files changed, 41 insertions, 0 deletions
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp index 3e3fe31570d..07697ec37f5 100644 --- a/lld/ELF/LinkerScript.cpp +++ b/lld/ELF/LinkerScript.cpp @@ -135,6 +135,9 @@ void LinkerScript::setDot(Expr E, const Twine &Loc, bool InSec) { // Update to location counter means update to section size. if (InSec) expandOutputSection(Val - Dot); + else + expandMemoryRegions(Val - Dot); + Dot = Val; } diff --git a/lld/test/ELF/linkerscript/memory4.test b/lld/test/ELF/linkerscript/memory4.test new file mode 100644 index 00000000000..e73d3608556 --- /dev/null +++ b/lld/test/ELF/linkerscript/memory4.test @@ -0,0 +1,19 @@ +# REQUIRES: x86 +# RUN: echo ".section .text,\"ax\"; nop; .section .data,\"aw\"; nop;" \ +# RUN: | llvm-mc -filetype=obj -triple=x86_64-pc-linux - -o %t.o +# RUN: ld.lld -o %t.so --script %s %t.o +# RUN: llvm-objdump -section-headers %t.so | FileCheck %s + +# CHECK: 1 .text 00000001 0000000000042000 +# CHECK-NEXT: 2 .data 00000001 0000000000042400 + +## Test that address expressions changes the position in a memory region. + +MEMORY { + ram (wxa) : ORIGIN = 0x42000, LENGTH = 0x100000 +} +SECTIONS { + .text : { *(.text*) } + data_addr = ALIGN(1024); + .data data_addr : { *(.data*) } +} diff --git a/lld/test/ELF/linkerscript/memory5.test b/lld/test/ELF/linkerscript/memory5.test new file mode 100644 index 00000000000..150ddf0e833 --- /dev/null +++ b/lld/test/ELF/linkerscript/memory5.test @@ -0,0 +1,19 @@ +# REQUIRES: x86 +# RUN: echo ".section .text,\"ax\"; nop; .section .data,\"aw\"; nop;" \ +# RUN: | llvm-mc -filetype=obj -triple=x86_64-pc-linux - -o %t.o +# RUN: ld.lld -o %t.so --script %s %t.o +# RUN: llvm-objdump -section-headers %t.so | FileCheck %s + +# CHECK: 1 .text 00000001 0000000000042000 +# CHECK-NEXT: 2 .data 00000001 0000000000044001 + +## Test that assign to Dot changes the position in a memory region. + +MEMORY { + ram (wxa) : ORIGIN = 0x42000, LENGTH = 0x100000 +} +SECTIONS { + .text : { *(.text*) } + . += 0x2000; + .data : { *(.data*) } +} |

