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]

Re: Gas padding object files? (XCOFF, ppc, aix)


On Fri, May 31, 2002 at 11:10:58AM -0400, Jason Sullivan wrote:
> 
> When I assemble the attached code, gas pads a 0 in the word location after
> the final branch.

The reason for the padding is that bfd/coff-rs6000.c defines
COFF_DEFAULT_SECTION_ALIGNMENT_POWER as 3, thus aligning to multiples
of 8.  bfd/coffcode.h:coff_new_section_hook seems to have a means to
override the default value via bfd_xcoff_text_align_power, but those
values aren't set up when .text is created.

The reason for zero rather than nop padding is that bfd/coff-rs6000.c
sets up the bfd_target structures with allowable section_flags that
exclude SEC_CODE.  Lack of SEC_CODE in .text effectively neuters
gas/subsegs.c:subseg_text_p, ie. all sections are treated as data
sections with zero padding bytes.

This is the way I'd go about fixing it, but I'm not applying this
patch because a) I don't consider myself particularly knowledgeable
about coff, and b) The same patch ought to be applied for other BFD
coff back ends.  Would one of the coff maintainers look at this
please?

	* coff-rs6000.c (COFF_DEFAULT_SECTION_ALIGNMENT_POWER): Set to 2.
	(rs6000coff_vec): Add SEC_CODE to section_flags.
	(pmac_xcoff_vec): Likewise.

Index: bfd/coff-rs6000.c
===================================================================
RCS file: /cvs/src/src/bfd/coff-rs6000.c,v
retrieving revision 1.41
diff -u -p -r1.41 coff-rs6000.c
--- bfd/coff-rs6000.c	31 May 2002 01:07:21 -0000	1.41
+++ bfd/coff-rs6000.c	1 Jun 2002 07:50:06 -0000
@@ -73,7 +73,7 @@ void xcoff_rtype2howto PARAMS ((arelent 
        | (howto->bitsize - 1));						\
   }
 
-#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
+#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER 2
 #define COFF_LONG_FILENAMES
 #define NO_COFF_SYMBOLS
 #define RTYPE2HOWTO(cache_ptr, dst) xcoff_rtype2howto (cache_ptr, dst)
@@ -4063,7 +4063,8 @@ const bfd_target rs6000coff_vec =
    HAS_LINENO | HAS_DEBUG | DYNAMIC |
    HAS_SYMS | HAS_LOCALS | WP_TEXT),
 
-  (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
+  (SEC_HAS_CONTENTS | SEC_ALLOC	/* section flags */
+   | SEC_LOAD | SEC_RELOC | SEC_CODE),
   0,				/* leading char */
   '/',				/* ar_pad_char */
   15,				/* ar_max_namelen??? FIXMEmgo */
@@ -4325,7 +4326,8 @@ const bfd_target pmac_xcoff_vec =
    HAS_LINENO | HAS_DEBUG | DYNAMIC |
    HAS_SYMS | HAS_LOCALS | WP_TEXT),
 
-  (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
+  (SEC_HAS_CONTENTS | SEC_ALLOC	/* section flags */
+   | SEC_LOAD | SEC_RELOC | SEC_CODE),
   0,				/* leading char */
   '/',				/* ar_pad_char */
   15,				/* ar_max_namelen??? FIXMEmgo */

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre


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