Alvaro Hernandorena
Alvaro Hernandorena

Reputation: 610

symbol lookup error undefined symbol on shared library calling main executable function

I have an already compiled linux executable, which loads "libA.so"

I used elfpatch on the executable to add another needed library "libB.so"

on my libB.so I can call any function that exists in LibA.so without any problem. But if I try to call a function from the main executable I get "symbol lookup error undefined symbol"

Is there a way for me to compile libB.so to access the functions in main executable? or my only choice is to access that function using dlopen?

Upvotes: 0

Views: 1606

Answers (2)

Alvaro Hernandorena
Alvaro Hernandorena

Reputation: 610

Ansering my old question I think in this project I was able to call a function from the main executable by address, literaly by address in the linux project I was working the main executable was always loaded in a relative address so I just used IDA , got the right address of the function, built a definition to the function with a absolute address and it worked. Also works in win32 if is not using some fancy memory address thing.

Upvotes: 0

Employed Russian
Employed Russian

Reputation: 213877

Is there a way for me to compile libB.so to access the functions in main executable?

Not without rebuilding the main executable. Explanation here.

or my only choice is to access that function using dlopen?

That isn't an option, dlopen will also fail to find the function in the main executable if that function is not exported from it.

Upvotes: 1

Related Questions