How to link two libraries with duplicate symbols without skipping one of them?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to link two libraries with duplicate symbols without skipping one of them?

1,044 Views
Susmit
Contributor I

I am trying to create an elf on mips where I have to link two libraries, both containing some same symbol names. Now, all these symbols are accessed from these two libraries itself, so logically, I think that all symbols should get resolved locally within the library, thus we can get both symbols linked. But, when I try to build the .elf, I see that symbols from one library got skipped as the same symbol has been linked in already. Is there any way to bypass this or force the symbol resolutions to happen inside the libraries itself?

Regards -

Susmit

Labels (1)
0 Kudos
3 Replies

306 Views
CrasyCat
Specialist III

Hello

 

Problem here is that the two libraries you are attempting to link with your project are object libraries.
When you create the library, objects defined within an object library are not assigned an address.

This is done at linking time, when the liner takes all the object files and object libraries and tries to create an executable file.  

 

At linking time if you have two libraries referencing an object with the same name, for the linker this is the same object.

 

Only way to avoid that is to change the symbol name in one of the libraries.

 

CrasyCat

0 Kudos

306 Views
Susmit
Contributor I

Thanks a lot for the detailed explanation. Btw, can we make two executables out of those libraries so that they get some addresses in an address space & then again link them in the fianl executable if we reserve the same code space in the .lcf file in the final .elf? Is that something which might work?

Also, can I use overlays to bypass the symbol renaming? Basically if I put the load address for two libraries different but keep the run addresses same, & add some code to load from load address to run address at runtime, can that work?

Regards -

Susmit

 

0 Kudos

306 Views
CrasyCat
Specialist III

Hello

 

I am not familiar with CodeWarrior for MIPS and I do not know if such a feature exist in that tool chain.

I will not be able to help you further here.

 

CrasyCat

0 Kudos