* DWARF 2 sections and padding ?
@ 2003-02-21 16:16 Brian Ford
2003-02-21 17:16 ` Daniel Jacobowitz
0 siblings, 1 reply; 3+ messages in thread
From: Brian Ford @ 2003-02-21 16:16 UTC (permalink / raw)
To: gdb
I am trying to add DWARF 2 support for PE/COFF on Cygwin. PE/COFF
sections must be aligned to 512 byte boundaries. This extra padding
confuses the DWARF 2 parsing routines because they use the sections
raw_size, thus parsing an invalid compilation unit header (all
zeros).
The actual, smaller size is available in the section header. I am
confused about what the cooked_size is supposed to mean. It is currently
zero, but I think it could contain the smaller virtual size.
I have read the DWARF spec several times, and although it discusses this
issue briefly for some debugging sections, it is unclear to me how this
should really work. Unless I try to arrange for the producer (gcc) to
pad the compilation units with zeros instead of having bfd pad the end of
the sections, I don't know how to proceed.
I would like to just use an alternate size instead of the raw size (cooked
maybe?) but I don't know how this would affect other targets and I don't
want a PE specific hack in DWARF parsing code.
Any ideas? Thanks.
--
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] 3+ messages in thread
* Re: DWARF 2 sections and padding ?
2003-02-21 16:16 DWARF 2 sections and padding ? Brian Ford
@ 2003-02-21 17:16 ` Daniel Jacobowitz
2003-02-21 18:59 ` Brian Ford
0 siblings, 1 reply; 3+ messages in thread
From: Daniel Jacobowitz @ 2003-02-21 17:16 UTC (permalink / raw)
To: Brian Ford; +Cc: gdb, binutils
On Fri, Feb 21, 2003 at 10:16:49AM -0600, Brian Ford wrote:
> I am trying to add DWARF 2 support for PE/COFF on Cygwin. PE/COFF
> sections must be aligned to 512 byte boundaries. This extra padding
> confuses the DWARF 2 parsing routines because they use the sections
> raw_size, thus parsing an invalid compilation unit header (all
> zeros).
>
> The actual, smaller size is available in the section header. I am
> confused about what the cooked_size is supposed to mean. It is currently
> zero, but I think it could contain the smaller virtual size.
>
> I have read the DWARF spec several times, and although it discusses this
> issue briefly for some debugging sections, it is unclear to me how this
> should really work. Unless I try to arrange for the producer (gcc) to
> pad the compilation units with zeros instead of having bfd pad the end of
> the sections, I don't know how to proceed.
>
> I would like to just use an alternate size instead of the raw size (cooked
> maybe?) but I don't know how this would affect other targets and I don't
> want a PE specific hack in DWARF parsing code.
>
> Any ideas? Thanks.
I don't see why the raw size should include the padding; that should
just be used when _placing_ sections. But this is a binutils/bfd
issue; redirected to that list.
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: DWARF 2 sections and padding ?
2003-02-21 17:16 ` Daniel Jacobowitz
@ 2003-02-21 18:59 ` Brian Ford
0 siblings, 0 replies; 3+ messages in thread
From: Brian Ford @ 2003-02-21 18:59 UTC (permalink / raw)
To: binutils; +Cc: gdb
On Fri, 21 Feb 2003, Daniel Jacobowitz wrote:
> On Fri, Feb 21, 2003 at 10:16:49AM -0600, Brian Ford wrote:
> > I am trying to add DWARF 2 support for PE/COFF on Cygwin. PE/COFF
> > sections must be aligned to 512 byte boundaries. This extra padding
> > confuses the DWARF 2 parsing routines because they use the sections
> > raw_size, thus parsing an invalid compilation unit header (all
> > zeros).
> >
> > The actual, smaller size is available in the section header. I am
> > confused about what the cooked_size is supposed to mean. It is currently
> > zero, but I think it could contain the smaller virtual size.
> >
> > I have read the DWARF spec several times, and although it discusses this
> > issue briefly for some debugging sections, it is unclear to me how this
> > should really work. Unless I try to arrange for the producer (gcc) to
> > pad the compilation units with zeros instead of having bfd pad the end of
> > the sections, I don't know how to proceed.
> >
> > I would like to just use an alternate size instead of the raw size (cooked
> > maybe?) but I don't know how this would affect other targets and I don't
> > want a PE specific hack in DWARF parsing code.
> >
> > Any ideas? Thanks.
>
> I don't see why the raw size should include the padding; that should
> just be used when _placing_ sections. But this is a binutils/bfd
> issue; redirected to that list.
>
The raw size appears to translate directly to the size in the section
header. The PE/COFF format states this must be a multiple of the page
size.
Other COFF targets that define ALIGN_SECTIONS_IN_FILE do the same thing,
in separate code, though. There is one case where these other targets do
what you suggest, if COFF_PAGE_SIZE is defined:
/* In demand paged files the low order bits of the file offset
must match the low order bits of the virtual address. */
#ifdef COFF_PAGE_SIZE
if ((abfd->flags & D_PAGED) != 0
&& (current->flags & SEC_ALLOC) != 0)
sofar += (current->vma - sofar) % page_size;
#endif
I modified the PE/COFF code to do this instead and, although it violates
the format, a simple test appeared valid and runable on Windows XP. What
do the binutils maintainers think about making this change?
--
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] 3+ messages in thread
end of thread, other threads:[~2003-02-21 18:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-21 16:16 DWARF 2 sections and padding ? Brian Ford
2003-02-21 17:16 ` Daniel Jacobowitz
2003-02-21 18:59 ` Brian Ford
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox