[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.

llvm-svn: 281818
This commit is contained in:
George Rimar 2016-09-17 09:50:10 +00:00
parent 8034d49db5
commit dfbbbc86a1
2 changed files with 21 additions and 0 deletions

View File

@ -297,6 +297,7 @@ void LinkerScript<ELFT>::processCommands(OutputSectionFactory<ELFT> &Factory) {
for (InputSectionBase<ELFT> *S : V)
S->OutSec = nullptr;
Opt.Commands.erase(Iter);
--I;
continue;
}

View File

@ -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