This is the mail archive of the cygwin-patches mailing list for the Cygwin 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: Rewrite/fix cygwin1.dbg generation


Christopher Faylor wrote:
On Mon, Nov 05, 2007 at 12:20:48PM +0100, Corinna Vinschen wrote:
On Nov 5 10:19, Pedro Alves wrote:
It occurred me that the problem may be that
ld is accounting for the virtual address and virtual size of the last section
to write the SizeOfImage field in the PE headers, in
bfd/peXXigen.c:_bfd_XXi_swap_aouthdr_out.
We can change it to not include non ALLOC, DEBUG sections.

Anyone tried that already?
Not me.  It never occurred to me that this could be a problem in ld,
actually.  If that's the problem and we can fix it, that would be really
cool.  IIUTC, it would remove the necessity to create a cygwin1.dbg file
at all.


Uuups, I wrote ld, when I meant binutils/bfd/'the pe output mechanism'.


The .gnu_debuglink is added by objcopy, as you know, so fixing this
in bfd/* fixes every binutils tool that outputs a PE file.

The real question is if the above is actually doing the right thing wrt
LINK.EXE.  When I was playing with this, I could duplicate the behavior
I didn't want by fiddling with the bits in the sections with Microsoft
tools, bypassing ld entirely.  So, I'm not sure that this is an ld.exe
problem.


Not sure if we're talking about the same thing.


The idea would be that when calculating the size of the image
(SizeOfImage == memory the loader will allocate), we don't
account for the top sections that aren't supposed to be
allocated in the first place, in an attempt that
the loader doesn't include them in the single
VirtualAlloc it is doing to allocate the
whole contigous memory range where the image is fit in.

That is:

+---------------------------------------+-
| 0 .text                               |
|   (CONTENTS|ALLOC|LOAD|READONLY|CODE) | These should accounted
| 1 .data                               | for the size of the
|   (CONTENTS|ALLOC|LOAD|DATA)          | image (minus PE headers)
| 2 .nmastcbaas (*)                     |
|   (DEBUG)                             |
| 3 .bss                                |
|   (ALLOC)                             |
| 4 .cygheap (last alloced section)     |
|   (ALLOC)                             |
+---------------------------------------+-
| 5 .stabs                              |
|   (CONTENTS|READONLY|DEBUG|EXCLUDE)   |  These should not
| 6 .gnu_debuglink                      |
|   (CONTENTS|READONLY|DEBUG)           |
+---------------------------------------+-

* My Non ALLOC Section That Comes Before An ALLOC Section

... but unfortunatelly, the loader does some validations,
which seem to make this impossible (invalid PE).  Bummer.  This
must be one of the reasons MSFT came up with
IMAGE_DEBUG_DIRECTORY.

Oh, well, can't say I didn't try :-)

Cheers,
Pedro Alves



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