0

Starting from an elf file that contains all information needed to fully debug my application, I would like to make an elf that contains only some symbols.
I managed to do this with GNU binutils strip tool :
strip -F elf32-big -p -s -K myFunc1-K myFunc2 -K myVar1 -K myVar2 myApp.elf
My concern here is that myVar1 and myVar2 are structured variables and the debugger cannot dig into them because 'strip' removed the .debug_info section from the elf (.debug_info is where the structure definitions are stored, I understood).
Ideally, I would keep in the elf only whats necessary for the debugger to parse my variables. I played with the options of 'strip'. I played with other binutils (readelf, objcopy, objdump...) after I read this thread. But it gave nothing satisfactory.
How would you do that?

Community
  • 1
  • 1
Akira
  • 1

1 Answers1

0

I don't know of a tool that already does what you want.

If I was asked to do this, first I would push back. Rather than trying to strip parts of the debuginfo, I would wonder why we couldn't use the existing split debuginfo approach. Coupled with build-ids this has the nice property that one can ship stripped executables but still get full debugging when needed -- just by pointing gdb to the debuginfo ELFs.

That said, if I did have to write it, I would say, first define exactly what you want to keep. Then, write a program to read the DWARF (say, using the elfutils libraries for this) and then write out new DWARF with just the desired information.

This is not extremely hard (see the "dwz" tool for an example of a DWARF manipulator...) but also not all that easy, either.

Tom Tromey
  • 21,507
  • 2
  • 45
  • 63
  • Thanks. I still wish someone comes with a solution that does not imply that I bother too much with the elf/dwarf internals. And just to avoid any confusion : my app is not a Linux app but a bare-metal one, a embedded scheduler, to be specific; and my debugger is not gdb but Lauterbach Trace32. – Akira Nov 06 '14 at 09:31