[lld] r281818 - [ELF] Linkerscript: fixed bug about commands processing.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 17 02:50:10 PDT 2016


Author: grimar
Date: Sat Sep 17 04:50:10 2016
New Revision: 281818

URL: http://llvm.org/viewvc/llvm-project?rev=281818&view=rev
Log:
[ELF] Linkerscript: fixed bug about commands processing.

It was possible situation about some commands just were not processed
(were skipped) because of a bug appeared when constraint checking used.

Testcase is attached.

Added:
    lld/trunk/test/ELF/linkerscript/sections-constraint4.s
Modified:
    lld/trunk/ELF/LinkerScript.cpp

Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=281818&r1=281817&r2=281818&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Sat Sep 17 04:50:10 2016
@@ -297,6 +297,7 @@ void LinkerScript<ELFT>::processCommands
         for (InputSectionBase<ELFT> *S : V)
           S->OutSec = nullptr;
         Opt.Commands.erase(Iter);
+        --I;
         continue;
       }
 

Added: lld/trunk/test/ELF/linkerscript/sections-constraint4.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/sections-constraint4.s?rev=281818&view=auto
==============================================================================
--- lld/trunk/test/ELF/linkerscript/sections-constraint4.s (added)
+++ lld/trunk/test/ELF/linkerscript/sections-constraint4.s Sat Sep 17 04:50:10 2016
@@ -0,0 +1,20 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
+# RUN: echo "SECTIONS { \
+# RUN:  .foo : ONLY_IF_RO { *(.foo) } \
+# RUN:  .bar : {bar1 = .; *(.bar) } }" > %t1.script
+# RUN: ld.lld -o %t1 --script %t1.script %t
+# RUN: llvm-readobj -t %t1 | FileCheck %s
+
+# CHECK: Name: bar1
+
+.global _start
+_start:
+  nop
+
+.section .bar, "aw"
+bar:
+ .long 1
+
+.section .foo, "aw"
+ .long 0




More information about the llvm-commits mailing list