This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: ELF symbol aliasing in


Hi Matthias,


$ cat foo.c
int foo(void) { return 42; }
$ cat bar.c
#include <stdio.h>
extern int foo_alias(void);
int main() { printf("%d\n",foo_alias()); }
$ cat alias_table
foo foo_alias
$ gcc -c foo.c bar.c
$ gcc -o foo foo.o bar.o _SOME_MAGIC_HERE_
$ ./foo
42
... without changing foo.c or bar.c.

Is that possible?

If you do not mind introducing some indirection then it is easy:


  % cat alias_table.s
    .global foo_alias
  foo_alias:
    jmp foo

  % gcc foo.c bar.c alias_table.s
  % ./a.out
  42

Cheers
  Nick



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]