Using objdump to force a section to load with gdb.

Ian Lance Taylor ian@zembu.com
Thu Jun 17 22:26:00 GMT 1999


   Date: Wed, 16 Jun 1999 00:06:11 +0000
   From: Brendan Simon <brendan@dgs.monash.edu.au>

   I have a linux kernel compiled for a mpc860 target and am trying to get
   it to run by downloading it into memory using a background debugger
   (BDM).  The boot code gets to the point where it trys to uncompress the
   kernel but fails because the image isn't loaded into memory (only .text,
   .rodata and .data are loaded).  I tried using objcopy to set the "image"
   section to "load" but it does not seem to work.  How can I get gdb to
   load the image section (either using a gdb command or binutils) ?

The problem with using objcopy to set the LOAD flag is that the only
sections which are loaded are those which are stored in program
segments.  objcopy isn't prepared to create a new program segment in
order to change a section flag.  This would be difficult to fix.

If your loader reads the section headers rather than the segment
headers, then you may be able to make this work by doing something
like
    powerpc-linux-objcopy --set-section-flags=image=alloc,load myzimage
The reason is that ELF records the ALLOC flag in the section header,
and objcopy should know how to change that.

The best way to make a loadable section is to mark the section as
loadable in the first place.  See the gas documentation for how to set
the section flags when using the .section directive.

Ian


More information about the Gdb mailing list