[lld] r203752 - [PECOFF] Handle objects with unknown machine type header value.
Rui Ueyama
ruiu at google.com
Wed Mar 12 22:12:36 PDT 2014
Author: ruiu
Date: Thu Mar 13 00:12:36 2014
New Revision: 203752
URL: http://llvm.org/viewvc/llvm-project?rev=203752&view=rev
Log:
[PECOFF] Handle objects with unknown machine type header value.
An object whose machine type header value is unknown looks a bit odd but
is valid. If an object contains only machine-type-independent data, you
can leave the type field unspecified. Some files in oldname.lib are such
object files.
Added:
lld/trunk/test/pecoff/Inputs/machine-type-unknown.obj.yaml
lld/trunk/test/pecoff/machinetype.test
Modified:
lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp
Modified: lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp?rev=203752&r1=203751&r2=203752&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/ReaderCOFF.cpp Thu Mar 13 00:12:36 2014
@@ -767,6 +767,9 @@ error_code FileCOFF::getReferenceArch(Re
case llvm::COFF::IMAGE_FILE_MACHINE_AMD64:
result = Reference::KindArch::x86_64;
return error_code::success();
+ case llvm::COFF::IMAGE_FILE_MACHINE_UNKNOWN:
+ result = Reference::KindArch::all;
+ return error_code::success();
}
llvm::errs() << "Unsupported machine type: " << header->Machine << "\n";
return llvm::object::object_error::parse_failed;
Added: lld/trunk/test/pecoff/Inputs/machine-type-unknown.obj.yaml
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/Inputs/machine-type-unknown.obj.yaml?rev=203752&view=auto
==============================================================================
--- lld/trunk/test/pecoff/Inputs/machine-type-unknown.obj.yaml (added)
+++ lld/trunk/test/pecoff/Inputs/machine-type-unknown.obj.yaml Thu Mar 13 00:12:36 2014
@@ -0,0 +1,37 @@
+---
+header:
+ Machine: IMAGE_FILE_MACHINE_UNKNOWN
+ Characteristics: []
+sections:
+ - Name: .drectve
+ Characteristics: [ IMAGE_SCN_LNK_INFO, IMAGE_SCN_LNK_REMOVE ]
+ Alignment: 2147483648
+ SectionData: ''
+symbols:
+ - Name: '@comp.id'
+ Value: 1
+ SectionNumber: 65535
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_STATIC
+ - Name: '@feat.00'
+ Value: 1
+ SectionNumber: 65535
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_STATIC
+ - Name: __imp___close
+ Value: 0
+ SectionNumber: 0
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_EXTERNAL
+ - Name: __imp__close
+ Value: 0
+ SectionNumber: 0
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_WEAK_EXTERNAL
+ NumberOfAuxSymbols: 1
+ AuxiliaryData: 020000000300000000000000000000000000
+...
Added: lld/trunk/test/pecoff/machinetype.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/machinetype.test?rev=203752&view=auto
==============================================================================
--- lld/trunk/test/pecoff/machinetype.test (added)
+++ lld/trunk/test/pecoff/machinetype.test Thu Mar 13 00:12:36 2014
@@ -0,0 +1,3 @@
+# RUN: yaml2obj %p/Inputs/hello.obj.yaml > %t1.obj
+# RUN: yaml2obj %p/Inputs/machine-type-unknown.obj.yaml > %t2.obj
+# RUN: lld -flavor link /out:%t.exe /subsystem:console /force -- %t1.obj %t2.obj
More information about the llvm-commits
mailing list