This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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]

[committed] Fix abuse of MAX_OFILE_ALIGNMENT macro in PA backend


The HP linker has rather small limits for the alignment of common data.
I had abused the MAX_OFILE_ALIGNMENT macro to check for this but this
caused problem building ada.  To fix this, I moved the alignment check
to pa_asm_output_aligned_common.

Tested on hppa2.0w-hp-hpux11.11 with no regressions.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc-cnrc.gc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6602)

2005-01-15  John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>

	PR ada/19388
	* pa.c (pa_asm_output_aligned_common): Warn if specified alignment
	exceeds maximum alignment for global common data.
	* pa64-hpux.h (MAX_OFILE_ALIGNMENT): Define to 32768.
	* som.h (MAX_OFILE_ALIGNMENT): Likewise.

Index: config/pa/pa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/pa/pa.c,v
retrieving revision 1.282
diff -u -3 -p -r1.282 pa.c
--- config/pa/pa.c	30 Dec 2004 03:08:00 -0000	1.282
+++ config/pa/pa.c	15 Jan 2005 16:45:11 -0000
@@ -8253,6 +8253,17 @@ pa_asm_output_aligned_common (FILE *stre
 			      unsigned HOST_WIDE_INT size,
 			      unsigned int align)
 {
+  unsigned int max_common_align;
+
+  max_common_align = TARGET_64BIT ? 128 : (size >= 4096 ? 256 : 64);
+  if (align > max_common_align)
+    {
+      warning ("alignment (%u) for %s exceeds maximum alignment "
+	       "for global common data.  Using %u",
+	       align / BITS_PER_UNIT, name, max_common_align / BITS_PER_UNIT);
+      align = max_common_align;
+    }
+
   bss_section ();
 
   assemble_name (stream, name);
Index: config/pa/pa64-hpux.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/pa/pa64-hpux.h,v
retrieving revision 1.37
diff -u -3 -p -r1.37 pa64-hpux.h
--- config/pa/pa64-hpux.h	7 Jan 2005 01:11:57 -0000	1.37
+++ config/pa/pa64-hpux.h	15 Jan 2005 16:45:11 -0000
@@ -122,11 +122,10 @@ Boston, MA 02111-1307, USA.  */
 
    The .align directive in the HP assembler allows alignments up to
    4096 bytes.  However, the maximum alignment of a global common symbol
-   is 16 bytes using HP ld.  For consistency, we use the same limit
-   with GNU ld.  */
+   is 16 bytes using HP ld.  Unfortunately, this macro doesn't provide
+   a method to check for common symbols.  */
 #undef MAX_OFILE_ALIGNMENT
-#define MAX_OFILE_ALIGNMENT                                             \
-  (TREE_PUBLIC (decl) && DECL_COMMON (decl) ? 128 : 32768)
+#define MAX_OFILE_ALIGNMENT 32768
 
 /* Due to limitations in the target structure, it isn't currently possible
    to dynamically switch between the GNU and HP assemblers.  */
Index: config/pa/som.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/pa/som.h,v
retrieving revision 1.52
diff -u -3 -p -r1.52 som.h
--- config/pa/som.h	15 Dec 2004 05:10:57 -0000	1.52
+++ config/pa/som.h	15 Jan 2005 16:45:11 -0000
@@ -287,11 +287,9 @@ do {						\
    The .align directive in the HP assembler allows alignments up to 4096
    bytes.  However, the maximum alignment of a global common symbol is 8
    bytes for objects smaller than the page size (4096 bytes).  For larger
-   objects, the linker provides an alignment of 32 bytes.  */
-#define MAX_OFILE_ALIGNMENT						\
-  (TREE_PUBLIC (decl) && DECL_COMMON (decl)				\
-   ? (host_integerp (DECL_SIZE_UNIT (decl), 1) >= 4096 ? 256 : 64)	\
-   : 32768)
+   objects, the linker provides an alignment of 32 bytes.  Unfortunately,
+   this macro doesn't provide a mechanism to test for common symbols.  */
+#define MAX_OFILE_ALIGNMENT 32768
 
 /* The SOM linker hardcodes paths into binaries.  As a result, dotdots
    must be removed from library prefixes to prevent binaries from depending


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