public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: Support for DDWARF-2 debug info? (on Cygwin)
@ 2003-01-09 21:22 Brian Ford
  0 siblings, 0 replies; 2+ messages in thread
From: Brian Ford @ 2003-01-09 21:22 UTC (permalink / raw)
  To: cygwin; +Cc: gcc, binutils, gdb, Dave Hooper, Christopher Faylor

Please CC me on replys.  I am not currently subscribed to any of these
lists.

I am interested in contributing to this endeavor, but I need help
with a few specific problems.  Any pointers or information about known
issues would be greatly appreciated.

I have built gcc 3.2.1 (just --enable-languages=c so far) with "#define
DWARF2_DEBUGGING_INFO 1" added to config/i386/cygwin.h.  The resulting
compiler still produces stabs by default, but will accept "-gdwarf-2".

When using "-gdwarf-2", the debug information is, I believe, correctly
output, but the sections have incorrect attributes as shown by the
"objdump -h" output below.  (BTW, I know I will need to modify the built
in link script for binutils so it knows where to put these sections)  The
incorrect section attributes keep the resulting executable from running, I
think.

Can anyone tell me how to get these attributes set correctly?  Is the
problem in gcc or binutils?  I imagine this is just the tip of the
iceberg, so know gotchas are welcome.

$ objdump -h test.o

test.o:     file format pe-i386

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .text         00000040  00000000  00000000  000001a4  2**4
                  CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
  1 .data         00000000  00000000  00000000  00000000  2**4
                  ALLOC, LOAD, DATA
  2 .bss          00000000  00000000  00000000  00000000  2**4
                  ALLOC
  3 .debug_abbrev 0000015c  00000000  00000000  000001e4  2**2
                  CONTENTS, ALLOC, LOAD, DATA
  4 .debug_info   00001198  00000000  00000000  00000340  2**2
                  CONTENTS, ALLOC, LOAD, RELOC, DATA
  5 .debug_line   00000158  00000000  00000000  000014d8  2**2
                  CONTENTS, RELOC, READONLY
  6 .debug_frame  00000034  00000000  00000000  00001630  2**2
                  CONTENTS, ALLOC, LOAD, RELOC, DATA
  7 .debug_pubnames 0000001c  00000000  00000000  00001664  2**2
                  CONTENTS, ALLOC, LOAD, RELOC, DATA
  8 .debug_aranges 00000020  00000000  00000000  00001680  2**2
                  CONTENTS, ALLOC, LOAD, RELOC, DATA
  9 .debug_str    00000030  00000000  00000000  000016a0  2**2
                  CONTENTS, ALLOC, LOAD, DATA

I believe the .debug sections should be marked READONLY and DEBUGGING (as
they are in Solaris?), but not ALLOC, LOAD, or DATA.  Is this right?

Thanks.

On Sat, Jan 04, 2003 at 07:55:42PM -0000, Christopher Faylor wrote:
>On Sat, Jan 04, 2003 at 05:30:15AM -0000, Dave Hooper wrote:
>>a)  If the cygwin build of gcc/gdb/gas/etc supports DWARF-2 debug
>>information (it appears not but I may be overlooking something)
>
>It doesn't.
>
>>b)  If not, is it just a matter of #defining the appropriate flags in
>>/gcc/config/i386/cygwin.h and rebuilding gcc?
>
>No.  Code is needed in gcc.
>
>>c)  Whether DWARF-2 will become the standard debug info format for
>>cygwin builds of apps in the near future (as it already has for various
>>other platforms, e.g. djgpp).
>
>It would be nice to switch to Dwarf-2 but no one has has stepped forward
>to implement the required bits to handle this.  I don't remember what is
>required, unfortunately, but I have discussed it with gcc engineers.  If
>you're interested in working on this, asking in the gcc@gcc.gnu.org
>mailing list would probably be the place to start.
>

-- 
Brian Ford
Senior Realtime Software Engineer
VITAL - Visual Simulation Systems
FlightSafety International
Phone: 314-551-8460
Fax:   314-551-8444


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Support for DDWARF-2 debug info? (on Cygwin)
       [not found] <m3fzrtozn2.fsf@north-pole.nickc.cambridge.redhat.com>
@ 2003-01-16 17:51 ` Brian Ford
  0 siblings, 0 replies; 2+ messages in thread
From: Brian Ford @ 2003-01-16 17:51 UTC (permalink / raw)
  To: Nick Clifton; +Cc: cygwin, binutils, dave, cgf, gcc

On 16 Jan 2003, Nick Clifton wrote:

> Hi Brian,
>
> > My current problem is that all previous DWARF2 implementations
> > assign a VMA of zero to the .debug_* sections in the link script.
> > This violates the PE format and makes the executable unusable.
>
> I saw your post about this to the binutils list.
>
> Does the PE format require that the debugging sections be loaded into
> memory when the executable is invoked ?  The reason that the ELF
> format allows the .debug sections to have a VMA of zero is that they
> also do not have the ALLOC flag, so they are not loaded into memory.
> (A debugger wanting to access the sections for a running process must
> locate the executable on disk an load them/mmap them from there).
>
No, they do not need to be loaded into memory, and they do not have the
ALLOC flag set.  But, the PE format requires all sections to be adjacent
and in ascending order of VMA.  It also specifies debug sections should be
last.  I think it just tries to load everything up to the fist non-ALLOC
section, or so it seams.

> > I am still consulting the DWARF2 spec to see if gcc and gas are
> > correct in generating VMA addresses.  If so, I guess I have to fix
> > the dwarf parsing code in bfd and gdb to subtract the section base
> > VMA.
>
> I do not believe that the DWARF2 spec mandates the VMA addresses of
> the .debug sections.  It does say that their contents must be
> contiguous, and it does specify the meaning of their contents, but it
> does not specify the meaning of partially-complete .debug sections.
> (ie ones attached to relocations that have not yet been resolved).
>
No, it does not, but I did find out it mandates section relative offsets.
So, the dwarf parsing code is correct.  It is gcc that has taken a
short cut.  BTW, these problems are with fully linked executables.

From gcc/dwarf2asm.c:122

/* Output a section-relative reference to a label.  In general this
   can only be done for debugging symbols.  E.g. on most targets with
   the GNU linker, this is accomplished with a direct reference and
   the knowledge that the debugging section will be placed at VMA 0.
   Some targets have special relocations for this that we must use.  */

void
dw2_asm_output_offset VPARAMS ((int size, const char *label,
                               const char *comment, ...))
{
  VA_OPEN (ap, comment);
  VA_FIXEDARG (ap, int, size);
  VA_FIXEDARG (ap, const char *, label);
  VA_FIXEDARG (ap, const char *, comment);

#ifdef ASM_OUTPUT_DWARF_OFFSET
  ASM_OUTPUT_DWARF_OFFSET (asm_out_file, size, label);
#else
  dw2_assemble_integer (size, gen_rtx_SYMBOL_REF (Pmode, label));
#endif

[snip]

So, all I need to do is define ASM_OUTPUT_DWARF_OFFSET correctly in
gcc/config/i386/cygwin.h.

Does anyone have I good way to define a section relative offset in
assembly for Cygwin, or do I need to define labels for the sections in the
link script as use them?  That seems messy.

> So, I think it is the case that BFD and GDB are both assuming that the
> VMA of the sections will be zero, but that this is not required.
>
Actually, as stated above, bfd and gdb are correct.  The VMA should not
be relevant as section relative offsets are specified.

-- 
Brian Ford
Senior Realtime Software Engineer
VITAL - Visual Simulation Systems
FlightSafety International
Phone: 314-551-8460
Fax:   314-551-8444

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-01-16 16:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-09 21:22 Support for DDWARF-2 debug info? (on Cygwin) Brian Ford
     [not found] <m3fzrtozn2.fsf@north-pole.nickc.cambridge.redhat.com>
2003-01-16 17:51 ` Brian Ford

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).