[PATCH] D61712: [ELF] Initialize Target before it may be referenced by findAux when reporting "duplicate symbol" error
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 8 18:44:01 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL360305: [ELF] Initialize Target before it may be dereferenced by findAux when reporting… (authored by MaskRay, committed by ).
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D61712/new/
https://reviews.llvm.org/D61712
Files:
lld/trunk/ELF/Driver.cpp
lld/trunk/test/ELF/undef-broken-debug.test
Index: lld/trunk/ELF/Driver.cpp
===================================================================
--- lld/trunk/ELF/Driver.cpp
+++ lld/trunk/ELF/Driver.cpp
@@ -441,6 +441,11 @@
if (errorCount())
return;
+ // The Target instance handles target-specific stuff, such as applying
+ // relocations or writing a PLT section. It also contains target-dependent
+ // values such as a default image base address.
+ Target = getTarget();
+
switch (Config->EKind) {
case ELF32LEKind:
link<ELF32LE>(Args);
@@ -1617,11 +1622,6 @@
if (Config->Strip != StripPolicy::None)
llvm::erase_if(InputSections, [](InputSectionBase *S) { return S->Debug; });
- // The Target instance handles target-specific stuff, such as applying
- // relocations or writing a PLT section. It also contains target-dependent
- // values such as a default image base address.
- Target = getTarget();
-
Config->EFlags = Target->calcEFlags();
Config->MaxPageSize = getMaxPageSize(Args);
Config->ImageBase = getImageBase(Args);
Index: lld/trunk/test/ELF/undef-broken-debug.test
===================================================================
--- lld/trunk/test/ELF/undef-broken-debug.test
+++ lld/trunk/test/ELF/undef-broken-debug.test
@@ -8,6 +8,10 @@
# CHECK: error: {{.*}}.o: relocation R_X86_64_64 at 0x29 has unsupported target
# CHECK: error: undefined symbol: bar
+# We used to dereference null Target in DWARF.cpp:findAux while reporting a duplicate symbol error,
+# because Target wasn't initialized yet.
+# RUN: not ld.lld %t.o %t.o -o /dev/null
+
--- !ELF
FileHeader:
Class: ELFCLASS64
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61712.198754.patch
Type: text/x-patch
Size: 1624 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190509/3f6b3654/attachment.bin>
More information about the llvm-commits
mailing list