From: Kai W. <kai...@gm...> - 2009-08-13 08:34:37
|
On Wed, Aug 12, 2009 at 05:29:04PM -0700, Chuck Tuffli wrote: > Is it possible to delete objects (symbols, relocations, etc) using the > current libelf API? I'm writing an application to remove a particular > function call and all the relocation entries from an "executable" > (really a kernel loadable module). Thanks! It is doable with libelf API: 1. Use libelf API to read the kernel module's symbol table and relocation entries into internal symbol list and relocation list, respectively. 2. Search the symbol table for that particular function call and delete it from the internel symbol list. (Keep track of this symbol index) 3. Search the relocation list for the relocation entry refering to that deleted symbol and delete it. 4. Update other relocation entries since symbol numbering might have changed at this point. 5. Use libelf API write out the internal symbol list and relocation list and other unchanged section to a new object. You may reuse some code from trunk/elfcopy. -Kai |