Stupid question: linking with a symbol under a different name

Sasha Unknown sasha2048@gmail.com
Mon Oct 3 07:53:00 GMT 2016


Suppose I have:
- compiled object file "main.o" with unresolved symbol "symbol1";
- build shared library "libused.so" with exported symbol "symbol2".

Is there way to somehow link program "main" from "main.o", telling it to 
use "symbol2" from "libused.so" as "symbol1"?
I tried to play with --defsym=symbol1=symbol2 option of ld, but the 
result was unsuccessful.

user@desktop:~/test$ ld -o main main.o --defsym=symbol1=symbol2 libused.so
--defsym:1: unresolvable symbol `symbol2' referenced in expression
--defsym:1: unresolvable symbol `symbol2' referenced in expression
ld: warning: cannot find entry symbol _start; defaulting to 
0000000000400249
ld: main.o(.text+0xa): unresolvable R_X86_64_PLT32 relocation against 
symbol `symbol1'
ld: final link failed: Nonrepresentable section on outpu



More information about the Binutils mailing list