Web lists-archives.com

Re: [Mingw-users] Can't do partial linking with libmoldname.a?

OK, I'm not sure whether "ld -r" works with import libraries ...

Maybe partial linking with an import library means gluing .text sections 
of many objects and preserve import sections?

// import libraries is also a bunch of object files
// extract the corresponding object file from archive
zby@winxp-vbox /c/src
$ ar x /mingw/lib/libmoldname.a doois00080.o

// see what is in that object file
zby@winxp-vbox /c/src
$ objdump -t -r -d doois00080.o

doois00080.o:     file format pe-i386

[  0](sec  5)(fl 0x00)(ty   0)(scl   3) (nx 0) 0x00000000 .idata$5
[  1](sec  7)(fl 0x00)(ty   0)(scl   3) (nx 0) 0x00000000 .idata$6
[  2](sec  1)(fl 0x00)(ty   0)(scl   2) (nx 0) 0x00000000 _strdup
[  3](sec  5)(fl 0x00)(ty   0)(scl   2) (nx 0) 0x00000000 __imp__strdup
[  4](sec  0)(fl 0x00)(ty   0)(scl   2) (nx 0) 0x00000000 

// there is also .text section in the object file, and have runnable 
code in it

Disassembly of section .text:

00000000 <_strdup>:
    0:   ff 25 00 00 00 00       jmp    *0x0
                         2: dir32        .idata$5
    6:   90                      nop
    7:   90                      nop

So the issue is that the "ld -r" can't work with import libraries?

>> From: 张博洋 <zhangboyang.id@xxxxxxxxx>
>> Date: Sat, 26 Nov 2016 17:26:41 +0800
>> Yes, linking some .o together works:
>> 	ld -r -o big.o somecode1.o somecode2.o somecode3.o
>> 	(OK, gcc -o test.exe big.o will generate runnable executable)
>> linking .o with libgcc.a or libmingwex.a also work:
>> 	ld -r -o big.o somecode1.o somecode2.o somecode3.o /mingw/lib/libmingwex.o
>> 	(OK)
>> But, linking with libmoldname.a will result in failure at the final step.
> libmoldname is an import library, while libmingwex is not, so these
> two examples are not the same use case.
> Let me rephrase: is there any reason to assume "ld -r" works with
> MinGW import libraries?
> And what is the semantics of "partial linking" with an import library,
> anyway?

MinGW-users mailing list

This list observes the Etiquette found at 
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

You may change your MinGW Account Options or unsubscribe at:
Also: mailto:mingw-users-request@xxxxxxxxxxxxxxxxxxxxx?subject=unsubscribe