Subject: port-m68k/6308: egcs 'alignment greather than maximum object file alignment' problem
To: None <gnats-bugs@gnats.netbsd.org>
From: Chas Williams <chas@cmf.nrl.navy.mil>
List: netbsd-bugs
Date: 10/15/1998 18:35:56
>Number:         6308
>Category:       port-m68k
>Synopsis:       egcs using too small a value for object file alignment
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    gnats-admin (GNATS administrator)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Oct 15 15:50:01 1998
>Last-Modified:
>Originator:     
>Organization:
	naval research lab, washington, dc
>Release:        11 OCT 98
>Environment:
	
thirdoffive, NetBSD 1.3H, mac68k


>Description:
	egcs complains about __attribute__(aligned(N)) when N is > 2
	gcc doesnt seem to have this problem. 

	apparently in egcs's varasm.c, handling for 'uninitialized definitions'
	in assemble_variable() has been moved after the check of the
	alignment of the declaration again the maximum alignment
	that can be specified for the object file.  now the alignment
	of the uninitialized definition is checked.


	gcc performed the handling before this test, and in the conditional
	they jumped to the end of the assemble_variable, avoiding the
	test of alignment against MAX_OFILE_ALIGNMENT. 

	MAX_OFILE_ALIGNMENT is inherited from BIGGEST_ALIGNMENT if it
	isnt specified. however, BIGGEST_ALIGNMENT on m68k is 16 bits by
	default and the a.out object file format is capable of more.

	you can see the following comment is varasm.c:
	/* Some object file formats have a maximum alignment which they support.
	   In particular, a.out format supports a maximum alignment of 4.  */

	@findex MAX_OFILE_ALIGNMENT
	@item MAX_OFILE_ALIGNMENT
	Biggest alignment supported by the object file format of this machine.  
	Use this macro to limit the alignment which can be specified using the
	@code{__attribute__ ((aligned (@var{n})))} construct.  If not defined,
	the default value is @code{BIGGEST_ALIGNMENT}.
	
	
>How-To-Repeat:
	try to copmile the following with egcs on m68k:

	struct foo {
		int a;
	}
	struct foo bar __attribute(aligned(4));

>Fix:
	increase/specify MAX_OFILE_ALIGNMENT?  4 would be a minimum, but
	possibly 8.

	perhaps, this should be specified elsewhere? m68k-aout.h?

diff -u /usr/src/gnu/dist/gcc/config/m68k/netbsd.h.000 /usr/src/gnu/dist/gcc/config/m68k/netbsd.h
--- netbsd.h.000        Thu Oct 15 15:30:49 1998
+++ netbsd.h    Thu Oct 15 15:32:48 1998
@@ -61,3 +61,6 @@
    and initialization stuff better.  */
 #define DWARF2_UNWIND_INFO 0
 
+#define MAX_OFILE_ALIGNMENT 32

>Audit-Trail:
>Unformatted: