* pe-i386 object files with .bss sections
@ 2001-12-18 5:35 Christian Groessler
2001-12-19 20:24 ` DJ Delorie
0 siblings, 1 reply; 2+ messages in thread
From: Christian Groessler @ 2001-12-18 5:35 UTC (permalink / raw)
To: binutils; +Cc: cpg
Hi,
There is a problem in the generated section header for .bss
sections. s_size is set to 0 and s_paddr is set to the length of the
section. But it should be the other way round.
This gives a problem, when I try to link a gcc generated object file
(containing a bss section) with the MS linker, since the linker reads
a bss length of 0.
The meaning of the s_size and s_paddr fields seems to differ if it's an
object file or executable. binutils don't make this difference, they
handle object files like executables.
Quoting from MS docs:
VirtualSize (s_paddr): Total size of the section when loaded into
memory. If this value is greater than Size of
Raw Data, the section is zero-padded. This
field is valid only for executable images and
should be set to 0 for object files.
SizeOfRawData (s_size): Size of the section (object file) or size of
the initialized data on disk (image
files). For executable image, this must be a
multiple of FileAlignment from the optional
header. If this is less than VirtualSize the
remainder of the section is zero
filled. Because this field is rounded while
the VirtualSize field is not it is possible
for this to be greater than VirtualSize as
well. When a section contains only
uninitialized data, this field should be 0.
The following patch fixes the behaviour for object files, this is only
a suggestion. The real fix should distinguish whether we work on an
exe or obj file. (How?)
------------
diff -p -u -r1.5 peXXigen.c
--- peXXigen.c 2001/10/25 06:33:56 1.5
+++ peXXigen.c 2001/12/18 13:19:39
@@ -897,8 +897,8 @@ _bfd_XXi_swap_scnhdr_out (abfd, in, out)
sometimes). */
if ((scnhdr_int->s_flags & IMAGE_SCN_CNT_UNINITIALIZED_DATA) != 0)
{
- ps = scnhdr_int->s_size;
- ss = 0;
+ ps = 0;
+ ss = scnhdr_int->s_size;
}
else
{
------------
regards,
chris
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: pe-i386 object files with .bss sections
2001-12-18 5:35 pe-i386 object files with .bss sections Christian Groessler
@ 2001-12-19 20:24 ` DJ Delorie
0 siblings, 0 replies; 2+ messages in thread
From: DJ Delorie @ 2001-12-19 20:24 UTC (permalink / raw)
To: cpg; +Cc: binutils
> This gives a problem, when I try to link a gcc generated object file
> (containing a bss section) with the MS linker, since the linker reads
> a bss length of 0.
I think our goal as far as MS compatibility is concerned is to support
MS objects with GNU linker, not the other way around (although that
would be nice too). We've been slowly fixing the differences as we
go, but we have to be careful not to break backwards compatibility.
Plus, we share a lot of code with the generic COFF bfd, so we have to
be careful about the differences.
> The real fix should distinguish whether we work on an exe or obj
> file. (How?)
See if there's a way to detect if we're doing a PEI bfd (executable)
or a PE bfd (object).
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2001-12-20 4:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-12-18 5:35 pe-i386 object files with .bss sections Christian Groessler
2001-12-19 20:24 ` DJ Delorie
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).