[lld] r282067 - Linker script: Fix bug with several .bss
Eugene Leviant via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 21 04:29:29 PDT 2016
Author: evgeny777
Date: Wed Sep 21 06:29:28 2016
New Revision: 282067
URL: http://llvm.org/viewvc/llvm-project?rev=282067&view=rev
Log:
Linker script: Fix bug with several .bss
When final image has several .bss sections, lld fails
because second .bss always has zero VA. This causes
link error "Not enough space for ELF and program headers"
Added:
lld/trunk/test/ELF/linkerscript/double-bss.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=282067&r1=282066&r2=282067&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Wed Sep 21 06:29:28 2016
@@ -453,10 +453,11 @@ void LinkerScript<ELFT>::assignOffsets(O
process(**I);
flush();
for (OutputSectionBase<ELFT> *Base : Sections) {
- if (!AlreadyOutputOS.insert(Base).second)
+ if (AlreadyOutputOS.count(Base))
continue;
switchTo(Base);
Dot += CurOutSec->getSize();
+ flush();
}
std::for_each(E, Cmd->Commands.end(),
[this](std::unique_ptr<BaseCommand> &B) { process(*B.get()); });
Added: lld/trunk/test/ELF/linkerscript/double-bss.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/double-bss.s?rev=282067&view=auto
==============================================================================
--- lld/trunk/test/ELF/linkerscript/double-bss.s (added)
+++ lld/trunk/test/ELF/linkerscript/double-bss.s Wed Sep 21 06:29:28 2016
@@ -0,0 +1,16 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
+# RUN: echo "SECTIONS { .text : { *(.text*) } }" > %t.script
+# RUN: ld.lld -o %t1 --script %t.script %t
+# RUN: llvm-objdump -section-headers %t1 | FileCheck %s
+# CHECK: .bss 00000004 0000000000000122 BSS
+# CHECK-NEXT: .bss 00000100 0000000000000128 BSS
+
+.globl _start
+_start:
+ jmp _start
+
+.bss
+.zero 4
+
+.comm q,128,8
More information about the llvm-commits
mailing list