Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide function name in GCC compilation

Tags:

c

gcc

ld

I am compiling a c "hello world" program that juste include one simple function and a main function.

I am using GCC under Linux.

When I run readelf command on the binary, I can see symbol table and I can see function names in clear.

  • Is there a way to tell GCC (or the linker) to not generate this symbol table?

  • Is it possible to tell GCC to store only functions addresses, without storing function names in clear?

like image 349
Bob5421 Avatar asked Jun 15 '16 08:06

Bob5421


1 Answers

Use the -s option to strip the symbol table:

gcc -s -o hello hello.c
like image 57
Jens Avatar answered Oct 26 '22 16:10

Jens