[llvm-dev] LLD/COFF Trying to link very old .lib files

Vincent Rouillé via llvm-dev llvm-dev at lists.llvm.org
Thu Aug 17 07:35:03 PDT 2017


Hi,

In order to improve our build workflow, I'm trying to link against very old .lib (1998).
LLD seams to be the best chance we have to migrate to clang compiler while being able to link with a very old proprietary library.

LLD is having trouble with those symbols:

003 C0000040 UNDEF  notype       Section      | .idata$4
004 C0000040 UNDEF  notype       Section      | .idata$5

SectionNumber = UNDEF = 0 ->

The COFF spec says about this:

> If the symbol referred to (by the SymbolTableIndex field) has storage class IMAGE_SYM_CLASS_SECTION, the symbolís address is the beginning of the section. The section is usually in the same file, except when the object file is part of an archive (library). In that case, the section may be found in any other object file in the archive that has the same archivemember name as the current object file. (The relationship with the archive-member name is used in the linking of import tables, i.e. the .idata section.)
> IMAGE_SYM_CLASS_SECTION  = 104 Definition of a section (Microsoft tools use STATIC storage class instead).

I'm still trying to understand the meaning of such symbol in order to allow LLD to resolve them correctly.

Does this mean .idata$4 and .idata$5 refer to the same address which is the beginning of section .idata$6 ?
But in that case what does the associated C0000040 value means ?

Any hint ?

Thanks you,
Vincent Rouillé


Here is the dumpbin data related to my issue:

FILE HEADER VALUES
     14C machine (i386)
       2 number of sections
31C231B8 time date stamp Sat Jun 15 05:44:56 1996
     182 file pointer to symbol table
       7 number of symbols
      E0 size of optional header
     100 characteristics
            32 bit word machine

SECTION HEADER #1
.idata$2 name
       0 virtual size
       0 virtual address
      14 size of raw data
     144 file pointer to raw data
     158 file pointer to relocation table
       0 file pointer to line numbers
       3 number of relocations
       0 number of line numbers
C0100040 flags
         Initialized Data
         1 byte align
         Read Write

RAW DATA #1
00000000  00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00  ........|........
00000010  00 00 00 00                                        ....

RELOCATIONS #1
                                                Symbol    Symbol
 Offset    Type              Applied To         Index     Name
 --------  ----------------  -----------------  --------  ------
 0000000C  DIR32NB                    00000000         2  .idata$6
 00000000  DIR32NB                    00000000         3  .idata$4
 00000010  DIR32NB                    00000000         4  .idata$5

SECTION HEADER #2
.idata$6 name
       0 virtual size
       0 virtual address
       C size of raw data
     176 file pointer to raw data
     158 file pointer to relocation table
       0 file pointer to line numbers
       0 number of relocations
       0 number of line numbers
C0200040 flags
         Initialized Data
         2 byte align
         Read Write

RAW DATA #2
00000000  4D 53 56 43 52 54 2E 64 | 6C 6C 00 00              MSVCRT.d|ll..

COFF SYMBOL TABLE
000 00000000 SECT1  notype       External     | __IMPORT_DESCRIPTOR_MSVCRT
001 C0000040 SECT1  notype       Section      | .idata$2
002 00000000 SECT2  notype       Static       | .idata$6
003 C0000040 UNDEF  notype       Section      | .idata$4
004 C0000040 UNDEF  notype       Section      | .idata$5
005 00000000 UNDEF  notype       External     | __NULL_IMPORT_DESCRIPTOR
006 00000000 UNDEF  notype       External     | MSVCRT_NULL_THUNK_DATA

String Table Size = 0x50 bytes



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170817/263a56d4/attachment.html>


More information about the llvm-dev mailing list