Re: ARM GCC rename static functions?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 27/06/11 07:02, Pan ruochen wrote:
> Hi All,
> 
> I found ARM GCC renamed some of static functions.
> 
> Here is my test code:
> $cat 1.c
> #include <stdio.h>
> #include <stdlib.h>
> #include <string.h>
> #include <unistd.h>
> #include <errno.h>
> #include <fcntl.h>
> #include <signal.h>
> #include <sys/mman.h>
> #include <sys/types.h>
> #include <sys/stat.h>
> #include <ucontext.h>
> 
> static void my_signal_handler(int signum, siginfo_t* siginfo,
> ucontext_t *lpContext)
> {
> 	mcontext_t *mc = &lpContext->uc_mcontext;
> 	fprintf(stderr, "[CORE]: Catch exception at 0x%x\n", mc->arm_pc);
> }
> 
> static int register_signal_handler(int sig, void *handler)
> {
> 	int ret = -EINVAL;
> 	sigset_t signal_set;
> 	if (sigemptyset(&signal_set) >= 0) {
> 		struct sigaction sa = {
> 			.sa_handler  = handler,
> 			.sa_mask     = signal_set,
> 			.sa_flags    = SA_SIGINFO,
> 			.sa_restorer = NULL
> 		};
> 		ret = sigaction(sig, &sa, NULL);
> 		if( ret < 0 )
> 			fprintf(stderr, "failed to install signal hander.\n");
> 	}
> 	return ret;
> }
> 
> int main()
> {
> 	register_signal_handler(SIGSEGV,my_signal_handler);
> 	register_signal_handler(SIGILL, my_signal_handler);
> 	register_signal_handler(SIGBUS, my_signal_handler);
> 	return 0;
> }
> 
> Then I did:
> $arm-none-linux-gnueabi-gcc -O2 1.c
> $arm-none-linux-gnueabi-objdump -dr -j .text a.out
> 
> 
> The ARM GCC renames the static function name from register_signal_handler to
> T.25, which will bring extra confusions in reading the unassembly code.
> 
> Why does gcc do these renaming stuff?

When optimizing, gcc generates clones of functions that are specialized to
particular tasks.  T.25 is a clone of register_signal_handler() that is
specialized to my_signal_handler().  You can see this if you read the assembly
language output.

Andrew.


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux