[PATCH] D27712: [ELF] - Do not crash when move location counter backward.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 14 23:37:48 PST 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL289782: [ELF] - Do not crash when move location counter backward. (authored by grimar).
Changed prior to commit:
https://reviews.llvm.org/D27712?vs=81230&id=81535#toc
Repository:
rL LLVM
https://reviews.llvm.org/D27712
Files:
lld/trunk/ELF/LinkerScript.cpp
lld/trunk/test/ELF/linkerscript/locationcountererr.s
Index: lld/trunk/ELF/LinkerScript.cpp
===================================================================
--- lld/trunk/ELF/LinkerScript.cpp
+++ lld/trunk/ELF/LinkerScript.cpp
@@ -464,7 +464,11 @@
if (auto *AssignCmd = dyn_cast<SymbolAssignment>(&Base)) {
if (AssignCmd->Name == ".") {
// Update to location counter means update to section size.
- Dot = AssignCmd->Expression(Dot);
+ uintX_t Val = AssignCmd->Expression(Dot);
+ if (Val < Dot)
+ error("unable to move location counter backward for: " +
+ CurOutSec->Name);
+ Dot = Val;
CurOutSec->Size = Dot - CurOutSec->Addr;
return;
}
Index: lld/trunk/test/ELF/linkerscript/locationcountererr.s
===================================================================
--- lld/trunk/test/ELF/linkerscript/locationcountererr.s
+++ lld/trunk/test/ELF/linkerscript/locationcountererr.s
@@ -0,0 +1,9 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
+# RUN: echo "SECTIONS { .text 0x2000 : {. = 0x10 ; *(.text) } }" > %t.script
+# RUN: not ld.lld %t --script %t.script -o %t1 2>&1 | FileCheck %s
+# CHECK: unable to move location counter backward for: .text
+
+.globl _start
+_start:
+nop
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27712.81535.patch
Type: text/x-patch
Size: 1242 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161215/c9605dfa/attachment.bin>
More information about the llvm-commits
mailing list