[lld] r363212 - [lld] Allow unrecognized signatures in debug sections
Reid Kleckner via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 12 15:22:44 PDT 2019
Author: rnk
Date: Wed Jun 12 15:22:44 2019
New Revision: 363212
URL: http://llvm.org/viewvc/llvm-project?rev=363212&view=rev
Log:
[lld] Allow unrecognized signatures in debug sections
An unrecognized signature (magic) at the beginning of a debug section
should not be a fatal error; it only means that the debug information
is in a format that is not supported by LLD. This can be due to it
being in CodeView versions 3 or earlier. These can occur in old import
libraries from legacy SDKs.
The test case was verified to work with MS link.exe.
Patch by Vladimir Panteleev!
Reviewed By: rnk
Differential Revision: https://reviews.llvm.org/D63177
Added:
lld/trunk/test/COFF/allow-unknown-debug-info.test
Modified:
lld/trunk/COFF/Chunks.cpp
Modified: lld/trunk/COFF/Chunks.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Chunks.cpp?rev=363212&r1=363211&r2=363212&view=diff
==============================================================================
--- lld/trunk/COFF/Chunks.cpp (original)
+++ lld/trunk/COFF/Chunks.cpp Wed Jun 12 15:22:44 2019
@@ -601,12 +601,15 @@ ArrayRef<uint8_t> SectionChunk::consumeD
if (!SectionName.startswith(".debug$"))
fatal("invalid section: " + SectionName);
- unsigned Magic = support::endian::read32le(Data.data());
- unsigned ExpectedMagic = SectionName == ".debug$H"
+ uint32_t Magic = support::endian::read32le(Data.data());
+ uint32_t ExpectedMagic = SectionName == ".debug$H"
? DEBUG_HASHES_SECTION_MAGIC
: DEBUG_SECTION_MAGIC;
- if (Magic != ExpectedMagic)
- fatal("section: " + SectionName + " has an invalid magic: " + Twine(Magic));
+ if (Magic != ExpectedMagic) {
+ warn("ignoring section " + SectionName + " with unrecognized magic 0x" +
+ utohexstr(Magic));
+ return {};
+ }
return Data.slice(4);
}
Added: lld/trunk/test/COFF/allow-unknown-debug-info.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/allow-unknown-debug-info.test?rev=363212&view=auto
==============================================================================
--- lld/trunk/test/COFF/allow-unknown-debug-info.test (added)
+++ lld/trunk/test/COFF/allow-unknown-debug-info.test Wed Jun 12 15:22:44 2019
@@ -0,0 +1,26 @@
+# RUN: yaml2obj %s > %t.obj
+# RUN: lld-link /dll /noentry /debug %t.obj 2>&1 | FileCheck %s
+
+# CHECK: ignoring section .debug$S with unrecognized magic 0x1
+
+--- !COFF
+header:
+ Machine: IMAGE_FILE_MACHINE_I386
+ Characteristics: []
+sections:
+ - Name: '.debug$S'
+ Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ]
+ SectionData: 01000000
+symbols:
+ - Name: '.debug$S'
+ Value: 0
+ SectionNumber: 1
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_STATIC
+ SectionDefinition:
+ Length: 4
+ NumberOfRelocations: 0
+ NumberOfLinenumbers: 0
+ CheckSum: 0
+ Number: 0
More information about the llvm-commits
mailing list