[PATCH] D34977: [ELF] - Allow moving location counter backward in some cases.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 12 07:51:09 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL307794: [ELF] - Allow moving location counter backward in some cases. (authored by grimar).
Changed prior to commit:
https://reviews.llvm.org/D34977?vs=106207&id=106213#toc
Repository:
rL LLVM
https://reviews.llvm.org/D34977
Files:
lld/trunk/ELF/LinkerScript.cpp
lld/trunk/test/ELF/linkerscript/locationcountererr2.s
lld/trunk/test/ELF/linkerscript/out-of-order.s
Index: lld/trunk/ELF/LinkerScript.cpp
===================================================================
--- lld/trunk/ELF/LinkerScript.cpp
+++ lld/trunk/ELF/LinkerScript.cpp
@@ -111,13 +111,9 @@
void LinkerScript::setDot(Expr E, const Twine &Loc, bool InSec) {
uint64_t Val = E().getValue();
- if (Val < Dot) {
- if (InSec)
- error(Loc + ": unable to move location counter backward for: " +
- CurAddressState->OutSec->Name);
- else
- error(Loc + ": unable to move location counter backward");
- }
+ if (Val < Dot && InSec)
+ error(Loc + ": unable to move location counter backward for: " +
+ CurAddressState->OutSec->Name);
Dot = Val;
// Update to location counter means update to section size.
if (InSec)
Index: lld/trunk/test/ELF/linkerscript/out-of-order.s
===================================================================
--- lld/trunk/test/ELF/linkerscript/out-of-order.s
+++ lld/trunk/test/ELF/linkerscript/out-of-order.s
@@ -1,9 +1,18 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-linux %s -o %t.o
# RUN: echo "SECTIONS { .data 0x4000 : { *(.data) } .text 0x2000 : { *(.text) } }" > %t.script
-# RUN: not ld.lld -o %t.so --script %t.script %t.o -shared 2>&1 | FileCheck %s
+# RUN: ld.lld -o %t.so --script %t.script %t.o -shared
+# RUN: llvm-objdump -section-headers %t.so | FileCheck %s
-# CHECK: error: {{.*}}.script:1: unable to move location counter backward
+# CHECK: Sections:
+# CHECK-NEXT: Idx Name Size Address Type
+# CHECK-NEXT: 0 00000000 0000000000000000
+# CHECK-NEXT: 1 .data 00000008 0000000000004000 DATA
+# CHECK-NEXT: 2 .dynamic 00000060 0000000000004008
+# CHECK-NEXT: 3 .text 00000008 0000000000002000 TEXT DATA
+# CHECK-NEXT: 4 .dynsym 00000018 0000000000002008
+# CHECK-NEXT: 5 .hash 00000010 0000000000002020
+# CHECK-NEXT: 6 .dynstr 00000001 0000000000002030
.quad 0
.data
Index: lld/trunk/test/ELF/linkerscript/locationcountererr2.s
===================================================================
--- lld/trunk/test/ELF/linkerscript/locationcountererr2.s
+++ lld/trunk/test/ELF/linkerscript/locationcountererr2.s
@@ -2,8 +2,10 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
# RUN: echo "SECTIONS {" > %t.script
# RUN: echo ". = 0x20; . = 0x10; .text : {} }" >> %t.script
-# RUN: not ld.lld %t.o --script %t.script -o %t -shared 2>&1 | FileCheck %s
-# CHECK: {{.*}}.script:2: unable to move location counter backward
+# RUN: ld.lld %t.o --script %t.script -o %t -shared
+# RUN: llvm-objdump -section-headers %t | FileCheck %s
+# CHECK: Idx Name Size Address
+# CHECK: 1 .text 00000000 0000000000000010
# RUN: echo "SECTIONS { . = 0x20; . = ASSERT(0x1, "foo"); }" > %t2.script
# RUN: ld.lld %t.o --script %t2.script -o %t -shared
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34977.106213.patch
Type: text/x-patch
Size: 2887 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170712/a6f41cba/attachment.bin>
More information about the llvm-commits
mailing list