[lld] r283214 - [ELF] Don't discard excluded section if -r is used
Eugene Leviant via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 4 05:05:43 PDT 2016
Author: evgeny777
Date: Tue Oct 4 07:05:42 2016
New Revision: 283214
URL: http://llvm.org/viewvc/llvm-project?rev=283214&view=rev
Log:
[ELF] Don't discard excluded section if -r is used
This conforms to GNU ld/gold behavior and fixes crash in case
excluded section also has associated relocation section
Modified:
lld/trunk/ELF/InputFiles.cpp
lld/trunk/test/ELF/exclude.s
Modified: lld/trunk/ELF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.cpp?rev=283214&r1=283213&r2=283214&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.cpp (original)
+++ lld/trunk/ELF/InputFiles.cpp Tue Oct 4 07:05:42 2016
@@ -226,7 +226,7 @@ void elf::ObjectFile<ELFT>::initializeSe
if (Sections[I] == &InputSection<ELFT>::Discarded)
continue;
- if (Sec.sh_flags & SHF_EXCLUDE) {
+ if (!Config->Relocatable && (Sec.sh_flags & SHF_EXCLUDE)) {
Sections[I] = &InputSection<ELFT>::Discarded;
continue;
}
Modified: lld/trunk/test/ELF/exclude.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/exclude.s?rev=283214&r1=283213&r2=283214&view=diff
==============================================================================
--- lld/trunk/test/ELF/exclude.s (original)
+++ lld/trunk/test/ELF/exclude.s Tue Oct 4 07:05:42 2016
@@ -2,11 +2,18 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
# RUN: ld.lld -o %t1 %t
# RUN: llvm-objdump -section-headers %t1 | FileCheck %s
+# RUN: ld.lld -r -o %t1 %t
+# RUN: llvm-objdump -section-headers %t1 | FileCheck --check-prefix=RELOCATABLE %s
+
# CHECK-NOT: .aaa
+# RELOCATABLE: .aaa
.globl _start
_start:
jmp _start
.section .aaa,"ae"
+ .quad .bbb
+
+.section .bbb,"a"
.quad 0
More information about the llvm-commits
mailing list