patch, XCOFF text alignment

trix@redhat.com trix@redhat.com
Tue Jun 11 22:31:00 GMT 2002


This patch fixes this problem.

http://sources.redhat.com/ml/binutils/2002-05/msg00753.html

The default alignment for the text section and csects is now 4 bytes.   This is what the native tools do.

I will be committing this soon.
Tom

--
Tom Rix
GCC Engineer
trix@redhat.com

-------------- next part --------------
bfd:
2002-06-11  Tom Rix  <trix@redhat.com>

	* coffcode.h (coff_compute_section_file_positions): Add data
	section to AIX loader alignment check.

	* coff-rs6000.c (_bfd_xcoff_mkobject): Set default text section 
	alignment to 4 bytes.
	(_bfd_xcoff_copy_private_bfd_data): Use text and data alignment
	power accessor macro.
	(do_shared_object_padding): Remove invalid assertion.

gas:
2002-06-11  Tom Rix  <trix@redhat.com>

	* config/tc-ppc.c (ppc_subseg_align): Delete.
	(ppc_change_csect): Default csect align is 2.
	* config/tc-ppc.h (SUB_SEGMENT_ALIGN): Delete 

gas/testsuite:
2002-06-12  Tom Rix  <trix@redhat.com>

	* gas/ppc/aix.exp: Run tests for all versions of powerpc AIX. Add
	text alignment tests.
	* gas/ppc/textalign-xcoff-001.d: New Test.
	* gas/ppc/textalign-xcoff-002.d: New Test.
	* gas/ppc/test1xcoff32.d : Change text section alignment.
	* gas/ppc/booke_xcoff.d: Remove invalid pad.

diff -rup -N -x *~ src-old/bfd/coff-rs6000.c src/bfd/coff-rs6000.c
--- src-old/bfd/coff-rs6000.c	Tue Jun 11 22:47:11 2002
+++ src/bfd/coff-rs6000.c	Wed Jun 12 00:02:25 2002
@@ -237,7 +237,7 @@ _bfd_xcoff_mkobject (abfd)
   xcoff_data (abfd)->debug_indices = NULL;
 
   /* text section alignment is different than the default */
-  /* xcoff_data (abfd)->text_align_power = 5; */
+  bfd_xcoff_text_align_power (abfd) = 2;
 
   return true;
 }
@@ -278,8 +278,8 @@ _bfd_xcoff_copy_private_bfd_data (ibfd, 
       else
 	ox->snentry = sec->output_section->target_index;
     }
-  ox->text_align_power = ix->text_align_power;
-  ox->data_align_power = ix->data_align_power;
+  bfd_xcoff_text_align_power (obfd) = bfd_xcoff_text_align_power (ibfd);
+  bfd_xcoff_data_align_power (obfd) = bfd_xcoff_data_align_power (ibfd);
   ox->modtype = ix->modtype;
   ox->cputype = ix->cputype;
   ox->maxdata = ix->maxdata;
@@ -1730,7 +1730,6 @@ do_shared_object_padding (out_bfd, in_bf
       int text_align_power;
 
       text_align_power = bfd_xcoff_text_align_power (in_bfd);
-      BFD_ASSERT (2 < text_align_power);
 
       pad = 1 << text_align_power;
       pad -= (*offset + ar_header_size) & (pad - 1);
diff -rup -N -x *~ src-old/bfd/coffcode.h src/bfd/coffcode.h
--- src-old/bfd/coffcode.h	Tue Jun 11 22:47:11 2002
+++ src/bfd/coffcode.h	Wed Jun 12 00:02:25 2002
@@ -1782,8 +1782,8 @@ coff_mkobject_hook (abfd, filehdr, aouth
       xcoff->toc = internal_a->o_toc;
       xcoff->sntoc = internal_a->o_sntoc;
       xcoff->snentry = internal_a->o_snentry;
-      xcoff->text_align_power = internal_a->o_algntext;
-      xcoff->data_align_power = internal_a->o_algndata;
+      bfd_xcoff_text_align_power (abfd) = internal_a->o_algntext;
+      bfd_xcoff_data_align_power (abfd) = internal_a->o_algndata;
       xcoff->modtype = internal_a->o_modtype;
       xcoff->cputype = internal_a->o_cputype;
       xcoff->maxdata = internal_a->o_maxdata;
@@ -3084,8 +3084,10 @@ coff_compute_section_file_positions (abf
 	     AIX executable is stripped with gnu strip because the default vma
 	     of native is 0x10000150 but default for gnu is 0x10000140.  Gnu
 	     stripped gnu excutable passes this check because the filepos is 
-	     0x0140. */
-	  if (!strcmp (current->name, _TEXT)) 
+	     0x0140.  This problem also show up with 64 bit shared objects. The
+	     data section must also be aligned.  */
+	  if (!strcmp (current->name, _TEXT) 
+	      || !strcmp (current->name, _DATA)) 
 	    {
 	      bfd_vma pad;
 	      bfd_vma align;
diff -rup -N -x *~ src-old/gas/config/tc-ppc.c src/gas/config/tc-ppc.c
--- src-old/gas/config/tc-ppc.c	Tue Jun 11 22:47:17 2002
+++ src/gas/config/tc-ppc.c	Wed Jun 12 00:02:25 2002
@@ -1120,14 +1120,6 @@ ppc_mach ()
   return ppc_size == PPC_OPCODE_64 ? 620 : 0;
 }
 
-#ifdef OBJ_XCOFF
-int
-ppc_subseg_align ()
-{
-  return ppc_xcoff64 ? 3 : 2;
-}
-#endif
-
 extern char*
 ppc_target_format ()
 {
@@ -2836,7 +2828,7 @@ ppc_change_csect (sym)
       symbol_set_frag (sym, frag_now);
       S_SET_VALUE (sym, (valueT) frag_now_fix ());
 
-      symbol_get_tc (sym)->align = (ppc_xcoff64) ? 3 : 2;
+      symbol_get_tc (sym)->align = 2;
       symbol_get_tc (sym)->output = 1;
       symbol_get_tc (sym)->within = sym;
 
diff -rup -N -x *~ src-old/gas/config/tc-ppc.h src/gas/config/tc-ppc.h
--- src-old/gas/config/tc-ppc.h	Tue Jun 11 22:47:17 2002
+++ src/gas/config/tc-ppc.h	Wed Jun 12 00:02:25 2002
@@ -196,10 +196,6 @@ extern int ppc_frob_symbol PARAMS ((symb
 #define tc_adjust_symtab() ppc_adjust_symtab ()
 extern void ppc_adjust_symtab PARAMS ((void));
 
-/* Niclas Andersson <nican@ida.liu.se> says this is needed.  */
-extern int ppc_subseg_align PARAMS ((void));
-#define SUB_SEGMENT_ALIGN(SEG, FRCHAIN) ppc_subseg_align ()
-
 /* We also need to copy, in particular, the class of the symbol,
    over what obj-coff would otherwise have copied.  */
 #define OBJ_COPY_SYMBOL_ATTRIBUTES(dest,src)			\
diff -rup -N -x *~ src-old/gas/testsuite/gas/ppc/aix.exp src/gas/testsuite/gas/ppc/aix.exp
--- src-old/gas/testsuite/gas/ppc/aix.exp	Tue Jun 11 22:47:24 2002
+++ src/gas/testsuite/gas/ppc/aix.exp	Wed Jun 12 00:04:35 2002
@@ -1,4 +1,4 @@
-# Copyright (C) 2001 Free Software Foundation, Inc.
+# Copyright (C) 2001, 2002 Free Software Foundation, Inc.
 # Contributed by Red Hat
 
 # This program is free software; you can redistribute it and/or modify
@@ -56,8 +56,11 @@ proc do_align_test {} {
 }
 
 
-if [istarget powerpc*-*-aix4.3*] then {
+if [istarget powerpc-ibm-aix*] then {
 
     # Make sure that symbols are correctly aligned 
     do_align_test
+
+    run_dump_test "textalign-xcoff-001"
+    run_dump_test "textalign-xcoff-002"
 }
diff -rup -N -x *~ src-old/gas/testsuite/gas/ppc/booke_xcoff.d src/gas/testsuite/gas/ppc/booke_xcoff.d
--- src-old/gas/testsuite/gas/ppc/booke_xcoff.d	Tue Jun 11 22:47:24 2002
+++ src/gas/testsuite/gas/ppc/booke_xcoff.d	Wed Jun 12 00:02:25 2002
@@ -26,5 +26,4 @@ Disassembly of section .text:
   40:	7c 00 04 ac 	sync	
   44:	7c 09 55 ec 	dcba	r9,r10
   48:	7c 00 06 ac 	eieio
-  4c:	00 00 00 00 	.long 0x0
 Disassembly of section .data:
diff -rup -N -x *~ src-old/gas/testsuite/gas/ppc/test1xcoff32.d src/gas/testsuite/gas/ppc/test1xcoff32.d
--- src-old/gas/testsuite/gas/ppc/test1xcoff32.d	Tue Jun 11 22:47:24 2002
+++ src/gas/testsuite/gas/ppc/test1xcoff32.d	Wed Jun 12 00:02:25 2002
@@ -10,7 +10,7 @@ start address 0x0+0000
 
 Sections:
 Idx Name +Size +VMA +LMA +File off +Algn
-  0 \.text +00000068  0+0000  0+0000  000000a8  2\*\*3
+  0 \.text +00000068  0+0000  0+0000  000000a8  2\*\*2
  +CONTENTS, ALLOC, LOAD, RELOC, CODE
   1 \.data +00000028  0+0068  0+0068  00000110  2\*\*3
  +CONTENTS, ALLOC, LOAD, RELOC, DATA
diff -rup -N -x *~ src-old/gas/testsuite/gas/ppc/textalign-xcoff-001.d src/gas/testsuite/gas/ppc/textalign-xcoff-001.d
--- src-old/gas/testsuite/gas/ppc/textalign-xcoff-001.d	Wed Dec 31 18:00:00 1969
+++ src/gas/testsuite/gas/ppc/textalign-xcoff-001.d	Wed Jun 12 00:02:25 2002
@@ -0,0 +1,14 @@
+#objdump: -h
+#source: textalign-xcoff-001.s
+#as: 
+
+.*:     file format aixcoff-rs6000
+
+Sections:
+Idx Name          Size      VMA               LMA               File off  Algn
+  0 \.text         00000004  0000000000000000  0000000000000000  000000a8  2\*\*2
+                  CONTENTS, ALLOC, LOAD, CODE
+  1 \.data         00000008  0000000000000004  0000000000000004  000000ac  2\*\*3
+                  CONTENTS, ALLOC, LOAD, RELOC, DATA
+  2 \.bss          00000000  000000000000000c  000000000000000c  00000000  2\*\*3
+                  ALLOC
diff -rup -N -x *~ src-old/gas/testsuite/gas/ppc/textalign-xcoff-001.s src/gas/testsuite/gas/ppc/textalign-xcoff-001.s
--- src-old/gas/testsuite/gas/ppc/textalign-xcoff-001.s	Wed Dec 31 18:00:00 1969
+++ src/gas/testsuite/gas/ppc/textalign-xcoff-001.s	Wed Jun 12 00:02:25 2002
@@ -0,0 +1,11 @@
+	.globl __start
+	.globl .__start
+
+__start:	
+	.csect   .data[DS]
+	.long    .__start
+
+	.csect .text[pr]
+.__start:
+	nop
+	
\ No newline at end of file
diff -rup -N -x *~ src-old/gas/testsuite/gas/ppc/textalign-xcoff-002.d src/gas/testsuite/gas/ppc/textalign-xcoff-002.d
--- src-old/gas/testsuite/gas/ppc/textalign-xcoff-002.d	Wed Dec 31 18:00:00 1969
+++ src/gas/testsuite/gas/ppc/textalign-xcoff-002.d	Wed Jun 12 00:02:25 2002
@@ -0,0 +1,14 @@
+#objdump: -h
+#source: textalign-xcoff-001.s
+#as: -mppc64 -a64
+
+.*:     file format .*coff64-rs6000
+
+Sections:
+Idx Name          Size      VMA               LMA               File off  Algn
+  0 \.text         00000004  0000000000000000  0000000000000000  000000f0  2\*\*2
+                  CONTENTS, ALLOC, LOAD, CODE
+  1 \.data         00000008  0000000000000004  0000000000000004  000000f4  2\*\*3
+                  CONTENTS, ALLOC, LOAD, RELOC, DATA
+  2 \.bss          00000000  000000000000000c  000000000000000c  00000000  2\*\*3
+                  ALLOC


More information about the Binutils mailing list