This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: develop a 'customized ld'
- From: Nick Clifton <nickc at redhat dot com>
- To: sean yang <seanatpurdue at hotmail dot com>
- Cc: ramaseshan dot ravi at gmail dot com, binutils at sourceware dot org
- Date: Fri, 30 Sep 2005 12:02:45 +0100
- Subject: Re: develop a 'customized ld'
- References: <BAY105-F2929644101780FA51B9EF1C09A0@phx.gbl>
Hi Sean,
I would like to collect the information of call to some libc
functions.
Why not use the "--wrap <func-name>" linker command line switch ? That
way you can intercept calls to specific libc functions, add your own
wrapper code to collect the information you require and then call the
normal libc version.
I want to have the code obfuscated at link time also, say, insert some
junk(nop) to prevent others understanding it easily.
This is a separate issue. As a general principle I would argue against
obfuscation, it should never really be needed. If you must do it, then
just inserting junk instructions is not really going to help. They can
easily be detected and ignored by a determined examiner. Your best bet
would be to encrypt the binary and hope that you can keep your keys safe
so that an unauthorized viewer cannot decode the executable.
Getting back to your original question:
Could someone give me some hint where should I start? Can any expert
> assess the difficulty of achieving such functionality?
Conceptually intercepting certain instructions and modifying them is
very similar to relaxation, so I would suggest that you look at the
linker's support for this feature. Have a look at the various
*_relax_section() functions in the bfd/ directory for examples of this.
As for difficulty - well this is not really something I would ask a
binutils newbie to do. You have the potential to corrupt the binaries
you are producing in quite nasty and/or subtle ways. Good luck though!
Cheers
Nick