summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Atanasyan <simon@atanasyan.com>2014-06-10 13:43:13 +0000
committerSimon Atanasyan <simon@atanasyan.com>2014-06-10 13:43:13 +0000
commit6790b14ebb846c75f8aab43f3194bea1f3094ab1 (patch)
tree9b04e19c382ba385216bc6511c10c0e37ca6a7ee
parentecaba1799656d6ec91632e8100986be2d57319e7 (diff)
downloadbcm5719-llvm-6790b14ebb846c75f8aab43f3194bea1f3094ab1.tar.gz
bcm5719-llvm-6790b14ebb846c75f8aab43f3194bea1f3094ab1.zip
[ELF] Fix the bug -- LLD crashes if the --whole-archive option
is around non-archive. llvm-svn: 210530
-rw-r--r--lld/lib/Driver/GnuLdInputGraph.cpp2
-rw-r--r--lld/test/Driver/so-whole-archive.test63
2 files changed, 64 insertions, 1 deletions
diff --git a/lld/lib/Driver/GnuLdInputGraph.cpp b/lld/lib/Driver/GnuLdInputGraph.cpp
index a3c6543e125..febc737d1b5 100644
--- a/lld/lib/Driver/GnuLdInputGraph.cpp
+++ b/lld/lib/Driver/GnuLdInputGraph.cpp
@@ -32,7 +32,7 @@ error_code ELFFileNode::parse(const LinkingContext &ctx,
return ec;
assert(parsedFiles.size() == 1);
std::unique_ptr<File> f(parsedFiles[0].release());
- if (auto archive = reinterpret_cast<const ArchiveLibraryFile *>(f.get())) {
+ if (const auto *archive = dyn_cast<ArchiveLibraryFile>(f.get())) {
// Have this node own the FileArchive object.
_archiveFile.reset(archive);
f.release();
diff --git a/lld/test/Driver/so-whole-archive.test b/lld/test/Driver/so-whole-archive.test
new file mode 100644
index 00000000000..0732c35a7a9
--- /dev/null
+++ b/lld/test/Driver/so-whole-archive.test
@@ -0,0 +1,63 @@
+# Check that LLD does not show any error if the --whole-archive
+# is around non-archive.
+
+# RUN: yaml2obj -format=elf -docnum=1 %s > %t-so.o
+# RUN: yaml2obj -format=elf -docnum=2 %s > %t-exe.o
+# RUN: lld -flavor gnu -target mipsel -shared -o %t.so %t-so.o
+# RUN: lld -flavor gnu -target mipsel -o %t.exe %t-exe.o --whole-archive %t.so
+
+# so.o
+---
+FileHeader:
+ Class: ELFCLASS32
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_MIPS
+ Flags: [ EF_MIPS_NOREORDER, EF_MIPS_PIC, EF_MIPS_CPIC,
+ EF_MIPS_ABI_O32, EF_MIPS_ARCH_32 ]
+Sections:
+ - Name: .text
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+ AddressAlign: 0x10
+ Size: 0x04
+Symbols:
+ Global:
+ - Name: foo
+ Type: STT_FUNC
+ Section: .text
+ Size: 0x04
+
+# exe.o
+---
+FileHeader:
+ Class: ELFCLASS32
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_MIPS
+ Flags: [ EF_MIPS_NOREORDER, EF_MIPS_CPIC,
+ EF_MIPS_ABI_O32, EF_MIPS_ARCH_32 ]
+Sections:
+ - Name: .text
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+ AddressAlign: 0x10
+ Size: 0x04
+ - Name: .rel.text
+ Type: SHT_REL
+ Link: .symtab
+ AddressAlign: 0x04
+ Info: .text
+ Relocations:
+ - Offset: 0x00
+ Symbol: foo
+ Type: R_MIPS_26
+
+Symbols:
+ Global:
+ - Name: __start
+ Type: STT_FUNC
+ Section: .text
+ Size: 0x04
+ - Name: foo
+...
OpenPOWER on IntegriCloud