This is the mail archive of the
mailing list for the binutils project.
Re: 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: Sat, 8 Oct 2016 14:05:01 +0300
- Subject: Re: Stupid question: linking with a symbol under a different name
- Authentication-results: sourceware.org; auth=none
- References: <email@example.com>
1. This is possible only with function. If it's a variable, I can't
create "wrapper variable" for it. (E.g. if symbol2 is "int" variable, I
of course can create foo.c with "int * const symbol1 = &symbol2", but
this won't match symbol1 convention from main.o, which expects symbol1
to be "int", not "int *".)
2. Even with function this gives some overhead (one additional call;
AFAIK, wrapper function won't be inlined in this case).
[Sorry for duplicate, first reply was accidentally sent to wrong address.]
On 06.10.16 15:58, Nick Clifton wrote:
Why not create a foo.c file that defines symbol1 and then passes any
reference on to symbol2 ?
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"?