Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide object filenames in a static library?

I want to deliver a C static library and hide the internal implementation as much as possible. I am using a code obfuscator on my code and that works very well for making symbols incomprhensible for a human. I am using xcode 4 which I assume has GCC like flags.

My problem is that my library still contains readable informations that I would like to hide or make incomprehensible to human:

1- Object file names: When I run nm on the .a , I still see the names of each object file. (i.e myObect1.o myObject2.o etc). Is there a way to remove these names from my .a?

2- file paths: When I run strings on my library, I still see paths to headers files as well as some .c file paths (included as #include). Is there a way to remove these as well. (GCC flag or other way)?

Thanks for you help,

baba

ps: I know about nm and strings but if you know of any other tools or if you can suggest anything else I should check is properly hidden in my .a, all suggestion is welcome.

like image 687
Baba Avatar asked Nov 04 '22 09:11

Baba


1 Answers

Consider distributing an amalgamation as SQLite does: http://www.sqlite.org/amalgamation.html. In other words, instead of a library, distribute a single .o file and a single .h file.

You'll have to annotate your internal functions as static. This will also give the compiler further opportunity for optimization. Lua uses such annotations. See for instance http://www.lua.org/source/5.1/ldo.h.html. For an amalgamation, LUAI_FUNC is defined as static.

like image 112
lhf Avatar answered Nov 09 '22 11:11

lhf