This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Stupid question: linking with a symbol under a different name
- From: Sasha Unknown <sasha2048 at gmail dot com>
- To: binutils at sourceware dot org
- Date: Mon, 3 Oct 2016 10:53:45 +0300
- Subject: Stupid question: linking with a symbol under a different name
- Authentication-results: sourceware.org; auth=none
- References: <8e8dd17f-71dd-05c2-5e8a-110d2e618ac2@gmail.com>
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