This is an archive of the discontinued LLVM Phabricator instance.

COFF: Fix short import lib import name type bitshift
ClosedPublic

Authored by martell on Aug 15 2016, 9:20 PM.

Details

Summary

llvm-readobj: Support short import objects from within an archive
The import magic was previous just checked against the archive as a whole

As per the PE COFF spec (section 8.3, Import Name Type)
Offset: 18 Size 2 bits Name: Type
Offset: 20 Size 3 bits Name: Name Type

Offset: 20 added based on 18+2

Diff Detail

Event Timeline

martell updated this revision to Diff 68129.Aug 15 2016, 9:20 PM
martell retitled this revision from to COFF: Fix short import lib import name type bitshift.
martell updated this object.
martell added reviewers: ruiu, compnerd.
martell set the repository for this revision to rL LLVM.
martell added a subscriber: llvm-commits.

llvm-readobj reads this field. perhaps we could have a testcase?

llvm-readobj reads this field. perhaps we could have a testcase?

lld also uses it to determine stripping of the symbol names.
This is mostly why i686 was broken at link time

I will add a test case

compnerd edited edge metadata.Aug 15 2016, 10:21 PM

Please add a test case for llvm via llvm-readobj.

llvm-readobj hello.lib

File: HELLO.dll
Format: COFF-x86-64
Arch: x86_64
AddressSize: 64bit

File: HELLO.dll
Format: COFF-x86-64
Arch: x86_64
AddressSize: 64bit

File: HELLO.dll
Format: COFF-x86-64
Arch: x86_64
AddressSize: 64bit

Error reading file: hello.lib: Unrecognized file type..

It seems that objdump does not know how to handle short import sections.
Are you sure it is being used?

compnerd added a comment.EditedAug 15 2016, 10:42 PM

Yeah, it should be:

if (COFFImportFile *Import = dyn_cast<COFFImportFile>(&Binary))
  dumpCOFFImportFile(Import);
martell updated this revision to Diff 68145.Aug 16 2016, 12:26 AM
martell updated this object.
martell edited edge metadata.
martell removed rL LLVM as the repository for this revision.
compnerd accepted this revision.Aug 17 2016, 8:44 PM
compnerd edited edge metadata.
This revision is now accepted and ready to land.Aug 17 2016, 8:44 PM
This revision was automatically updated to reflect the committed changes.