[PATCH] D22206: COFF: drop the dependency on LIB.EXE for implibs

Saleem Abdulrasool via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 10 15:30:20 PDT 2016


compnerd created this revision.
compnerd added reviewers: rui314, ruiu.
compnerd added a subscriber: llvm-commits.
compnerd set the repository for this revision to rL LLVM.
compnerd added a project: lld.

lld currently relies on lib.exe in order to generate an empty import library.
The "empty" import library consists of 5 members:
  - first linker member
  - second linker member
  - Import Descriptor
  - NULL Import Descriptor
  - NULl Thunk

The first two entries (first and second linker members) are string tables which
are never updated.  Therefore, they may as well as not be present.  A subsequent
change to add that is probably warranted.  However, this does not prevent the
use of the linker.

The Import Descriptor is the content which is most important.  It provides an
Import Name Table entry for the library (as specified by the LIBRARY directive
in the DEF file).  Additionally, it contains undefined references to the NULL
Import Descriptor and the library NULL Thunk Data.  This ensures that the linker
will pull in the subsequent objects from the import library for the link.  The
Import Descriptor has a single symbol (__IMPORT_DESCRIPTOR_<Library>) which
contains 3 relocations, one to the INT (Import Name Table) entry, one to the ILT
(Import Lookup Table) entry, and one to the IAT (Import Address Table) entry.

The NULL Import Descriptor is the last import descriptor and terminates the
import descriptor array.  It contains a single symbol
(__NULL_IMPORT_DESCRIPTOR).

The NULL Thunk contains a single symbol (\x7f<Library>_NULL_THUNK_DATA) and
provides the terminator for the ILT and IAT.

These files are currently constructed manually following the example of the
Short Import Library format.  This is arguably less than ideal, and it may be
possible to use MCAssembler and feed it the fragments to construct the object.

The major difference between the LIB (LINK) generated objects and the ones
generated here is that they are all one section shorter (.debug$S) as they do
not contain the debug information and one symbol shorter (@comp.id) as they do
not contain the RICH signature.

Repository:
  rL LLVM

http://reviews.llvm.org/D22206

Files:
  COFF/DriverUtils.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22206.63441.patch
Type: text/x-patch
Size: 17586 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160710/2053cd2d/attachment.bin>


More information about the llvm-commits mailing list