This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Rename symbol at link time
- From: VÃclav Zeman <vhaisman at gmail dot com>
- To: DamienDaG <deusnei-div at yahoo dot fr>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Wed, 6 Jun 2012 09:54:44 +0200
- Subject: Re: Rename symbol at link time
- References: <33968382.post@talk.nabble.com>
On 6 June 2012 09:27, DamienDaG wrote:
>
> Hi
>
> I'm trying to build a very simple project composed of one source file and a
> linker script :
>
> file f1.c :
> #include <stdio.h>
>
> extern void fct1_wrongname();
>
> void fct9()
> {
> Â Â Â Âprintf("I'm fct9\n");
> }
>
> int main( int argc, char** argv)
> {
> Â Â Â Âfct1_wrongname();
> Â Â Â Âreturn 0;
> }
> end of file f1.c
>
> This file is compiled with command :
> gcc -O0 -xc -g -Wall -c f1.c -of1.o
> then build with :
> ld -T'Link.cmd' -O0 -Map out.map -o rename.exe f1.o
>
> file Link.cmd contains :
>
> fct1_wrongname = fct9 ;
>
> end of file Link.cmd
>
>
> Function fct1_wrongname doesn't exist, and I want to replace the call of
> this function by a call of fct9.
>
> I always get this error message :
> Link.cmd:4: undefined symbol `fct9' referenced in expression
>
> I need to use a linker script (here Link.cmd) to apply this to a larger
> project, and I can't use symbol definition (i.e. -D"fct1_wrongname=fct9")
> because there are to many symbols.
> I've been looking for a solution for a long time, but I couldn't find
> anything.
Is it possible that the linker script should contain leading
underscores for the symbols? E.g., _fct1_wrongname=_fct9? Take a look
at nm -AB output for the f1.o file.
--
VZ