This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Can GNU ld be forced to resolve symbols during partial linking ?


Hi Lambert,

> I want to link two object files together that are both dependant on
> the same library. I want to link that certain library statically to
> both object files, so they don't contain any more unresolved symbols
> to functions in the library. In the final linking step I want to
> link both object files together,

Err hang on a second - you have already linked these two object files
together during the relocatable link that you performed first, so how
can you link them together again in the final link ?

> resolving symbols that are only known in that stage (concerning
> positions and sizes of code). I need to have the library available
> in flash memory and in ram memory, so I need to link it twice.

Err, do you mean that you want to perform *two* partial links, the
first with one object file and the library, the second with the other
object file and the library, and then perform a final link, combining
the two (partially linked) object files into a single executable where
one object file ends up in RAM and the other ends up in FLASH ?


> I tried partially linking with the -r option and -l options to tell
> the linker what library it needs to link. But if I look to such a
> partially linked object file with objdump I see that calls to
> library functions are not yet resolved , I hoped I would see
> absolute addresses to functions in the assembler code but I don't see
> them. Apparently ld does not resolve any symbol in this stage, it
> does this in the stage where an absolute executable is linked
> together,

Well yes.  The references to the library cannot be resolved during a
partial link because the linker does not know where the library will
end up in relation to the object code.  It can resolve references
between two object files because it is going to create a single,
combined object file as its output.


> giving me only 2 options. Put the library in memory only 
> once (which is not what I want) or have the linker complain about
> double defined symbols (what it does when I link the library to both
> object files).

Err - how are you doing this ?  If you are extracting the object files
from the library and then linking them with each of your object files
in turn, then yes you will get the multiply defined symbol problem.

> My question is , can ld be forced to resolve all resolvable symbols
> during a partial link (with -r) and leaving all other symbols
> unresolved, to be resolved in a second linking stage ??

Basically no.  You are trying to do something that the linker does not
want to do, so whatever solution you do come up with will be a hack.
Sorry.

Cheers
        Nick


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]