diff mbox

pdp11: Fix misaligned variables

Message ID AB946ADB-89F8-4AF5-809E-86E6EF318957@dell.com
State New
Headers show

Commit Message

Paul Koning Dec. 30, 2010, 2:11 a.m. UTC
The assembly output for common and local variables wasn't forcing even byte alignment when required, causing execution failures due to alignment exceptions.  Fixed by this patch.

Checked by build and make check of selected testcases.  Committed.

	paul

ChangeLog:

2010-12-29  Paul Koning  <ni1d@arrl.net>

	* config/pdp11/pdp11-protos.h (pdp11_asm_output_var): Declare.
	* config/pdp11/pdp11.c (pdp11_asm_output_var): New function.
	* config/pdp11/pdp11.h (ASM_OUTPUT_ALIGNED_COMMON,
	ASM_OUTPUT_ALIGNED_LOCAL): New macros.
	(ASM_OUTPUT_COMMON, ASM_OUTPUT_LOCAL): Delete.
diff mbox

Patch

Index: config/pdp11/pdp11-protos.h
===================================================================
--- config/pdp11/pdp11-protos.h	(revision 168294)
+++ config/pdp11/pdp11-protos.h	(working copy)
@@ -44,3 +44,4 @@ 
 #endif /* RTX_CODE */
 
 extern void output_ascii (FILE *, const char *, int);
+extern void pdp11_asm_output_var (FILE *, const char *, int, int, bool);
Index: config/pdp11/pdp11.c
===================================================================
--- config/pdp11/pdp11.c	(revision 168294)
+++ config/pdp11/pdp11.c	(working copy)
@@ -716,6 +716,19 @@ 
 
 
 void
+pdp11_asm_output_var (FILE *file, const char *name, int size,
+		      int align, bool global)
+{
+  if (align > 8)
+    fprintf (file, "\n\t.even\n");
+  fprintf (file, ".globl ");
+  assemble_name (file, name);
+  fprintf (file, "\n");
+  assemble_name (file, name);
+  fprintf (file, ": .=.+ %#ho\n", (unsigned short)size);
+}
+
+void
 print_operand_address (FILE *file, register rtx addr)
 {
   register rtx breg;
Index: config/pdp11/pdp11.h
===================================================================
--- config/pdp11/pdp11.h	(revision 168294)
+++ config/pdp11/pdp11.h	(working copy)
@@ -648,20 +648,15 @@ 
 /* This says how to output an assembler line
    to define a global common symbol.  */
 
-#define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED)  \
-( fprintf ((FILE), ".globl "),			\
-  assemble_name ((FILE), (NAME)),		\
-  fprintf ((FILE), "\n"),			\
-  assemble_name ((FILE), (NAME)),		\
-  fprintf ((FILE), ": .=.+ %#ho\n", (unsigned short)(ROUNDED))		\
-)
+#define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN)  \
+    pdp11_asm_output_var (FILE, NAME, SIZE, ALIGN, true)
 
+
 /* This says how to output an assembler line
    to define a local common symbol.  */
 
-#define ASM_OUTPUT_LOCAL(FILE, NAME, SIZE, ROUNDED)  \
-( assemble_name ((FILE), (NAME)),				\
-  fprintf ((FILE), ":\t.=.+ %#ho\n", (unsigned short)(ROUNDED)))
+#define ASM_OUTPUT_ALIGNED_LOCAL(FILE, NAME, SIZE, ALIGN) \
+    pdp11_asm_output_var (FILE, NAME, SIZE, ALIGN, false)
 
 /* Print operand X (an rtx) in assembler syntax to file FILE.
    CODE is a letter or dot (`z' in `%z0') or 0 if no letter was specified.