Stupid question: linking with a symbol under a different name

Sasha Unknown
Sat Oct 1 00:13:00 GMT 2016

Suppose I have:
- compiled object file "main.o" with unresolved symbol "f1";
- build shared library "" with exported symbol "f2".

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

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

More information about the Binutils mailing list