This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Debugging & relocation ..


Hi Lars,

>    I am building a set of source into a binary file, which is
> included as data in an executable (linked in actually, without
> symbols) which is then copied into the place it's supposed to
> execute, and now my question is if it is possible to generate
> debugging symbols for gcc concerning the binary that was built ?

Yes.  The simplest way is to create your binary file twice.  The first
time you create it the way you are currently doing and then link it
into your executable as normal.

The second time you use a custom linker script (or possibly just some
linker command line switches) that builds a second version of the
binary file.  This second binary is only a pretend file, it is not
executed, but the linker script is arranged so that it is relocated to
work at the destination address of the first binary.  This second
binary also contains all the debugging information that the compiler
generated (ie you do not strip it), so that the debug info is also
relocated to the correct addresses.

When you come to debug the first, in-memory, binary file you arrange
for the debugger to locate the second binary file which contains all
the debug info that it needs.


> also how do I use two files with debugging info ?

There are two methods.  Either place the file with the debug info in
it in the current directory and arrange for it to have the same name
as the in-memory executable being debugged.

Or, use the new --add-gnu-debuglink feature recently added to objcopy
(and so far only in the CVS sources).  This creates a special section
in an executable which contains the name of the second file containing
its debug information.  See the node on .gnu_debuglink in the gdb
texinfo file for more details.

Cheers
        Nick
        


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]