This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils 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]

pe-i386 object files with .bss sections


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


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