Gcc export symbols

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

Gcc export symbols

1,169 Views
benoitruelland
Contributor I

Hi everybody,
I want to import in a project, the absolute path of a Library from another project.

For example,
I have a boot and a jump to an app. if I use printf in my boot,
I want to use the same allocation of the function printf in my app.

I Don't know with gcc/ld, how to export/import symbols

Thanks,
Benoit

Labels (2)
0 Kudos
7 Replies

947 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Benoit Ruelland,

Do you just use the GCC compiler or a IDE based on GCC?

0 Kudos

947 Views
benoitruelland
Contributor I

Hello,
I'm using mcuExpresso.

0 Kudos

947 Views
converse
Senior Contributor V
0 Kudos

947 Views
benoitruelland
Contributor I

Thanks Con Verse.
What I want to do is access to absolute address of function into Library in another project.

0 Kudos

947 Views
converse
Senior Contributor V

Call the function in your application and link with the library containing that function. That is all you need to do.

0 Kudos

947 Views
benoitruelland
Contributor I

Thanks Con Verse.

a Library contain relative address for functions.
I want to access absolute address after linker process.

for illustrate, I just create a lib calculate with 2 functions
int calc_add(int a,int b)

int calc_sub(int a,int b)

In my first project I call lib_sub => linker give me this address :

 .text.calc_sub
                0x1a001bdc       0x1c C:\(somewhere in my computer)\Calculate\Debug\libCalculate.a(calc.o)
                0x1a001bdc                calc_sub

I do the same with my second project => linker give me this address :

.text.calc_sub
                0x1a000f80       0x1c C:\(somewhere in my computer)\Calculate\Debug\libCalculate.a(calc.o)
                0x1a000f80                calc_sub

You can see that the location of the function are not the same.

What I want to do, export symbol of my first project (Absolute address)

and import it in my second project.

For illustrate:

first project :

 .text.calc_sub
                0x1a001bdc       0x1c C:\(somewhere in my computer)\Calculate\Debug\libCalculate.a(calc.o)
                0x1a001bdc      calc_sub

second project : 

.text.calc_sub
                0x1a001bdc       0x1c C:\(somewhere in my computer)\Calculate\Debug\libCalculate.a(calc.o)
                0x1a001bdc      calc_sub

Thanks for help.

0 Kudos

947 Views
converse
Senior Contributor V

Sorry, I have no idea how to do that - or even if it is possible (but it doesn't sound like a good idea).

A better way of achieving a similar outcome would be to put  'jump' table at a fixed, known location in your 1st  application and then direct your call through the table in your 2nd application.

0 Kudos