summaryrefslogtreecommitdiffstats
path: root/lld
diff options
context:
space:
mode:
authorGeorge Rimar <grimar@accesssoftek.com>2017-05-30 05:48:09 +0000
committerGeorge Rimar <grimar@accesssoftek.com>2017-05-30 05:48:09 +0000
commitd4096140e3516640c97d832c0ea7b889f62d388b (patch)
tree727fcb47b5f58349d3e21c2aef7dfb62542f2f44 /lld
parent707e37fb0d8389f28c60b31ae6769b3294dfa33a (diff)
downloadbcm5719-llvm-d4096140e3516640c97d832c0ea7b889f62d388b.tar.gz
bcm5719-llvm-d4096140e3516640c97d832c0ea7b889f62d388b.zip
[ELF] - Do not crash when linkerscript applies fill to .bss.
I found that during visual inspection of code while wrote different patch. Script in testcase probably have nothing common with real life, but we segfault currently using it. If output section is known NOBITS, there is no need to create writers threads for doing nothing or proccess any filler logic that is useless here. We can just early return, that is what this patch do. DIfferential revision: https://reviews.llvm.org/D33646 llvm-svn: 304192
Diffstat (limited to 'lld')
-rw-r--r--lld/ELF/LinkerScript.cpp3
-rw-r--r--lld/test/ELF/linkerscript/bss-fill.s7
2 files changed, 10 insertions, 0 deletions
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index 7c4bf3aaebb..99c464e3714 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -1080,6 +1080,9 @@ template <class ELFT> void OutputSectionCommand::writeTo(uint8_t *Buf) {
return;
}
+ if (Sec->Type == SHT_NOBITS)
+ return;
+
// Write leading padding.
ArrayRef<InputSection *> Sections = Sec->Sections;
uint32_t Filler = getFiller();
diff --git a/lld/test/ELF/linkerscript/bss-fill.s b/lld/test/ELF/linkerscript/bss-fill.s
new file mode 100644
index 00000000000..92f9fdf5619
--- /dev/null
+++ b/lld/test/ELF/linkerscript/bss-fill.s
@@ -0,0 +1,7 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
+# RUN: echo "SECTIONS { .bss : { . += 0x10000; *(.bss) } =0xFF };" > %t.script
+# RUN: ld.lld -o %t --script %t.script %t.o
+
+.section .bss,"",@nobits
+.short 0
OpenPOWER on IntegriCloud