H8 related patches

law@redhat.com law@redhat.com
Wed Sep 5 06:16:00 GMT 2001


The stor-layout change causes the compiler to emit an error if it
encounters an array whose size can not be expressed in a size_t.

The second change just fixes up -p and -pg so that you can build
and link things with -p and -pg.  Nothing too radical.  Jason and I
had pondered moving this change into the generic elfos.h, but aren't
going to do that at this time.

Bootstrapped x86-linux.  No regressions.

        * stor-layout.c (layout_type): Complain if an array's size can
        not be represented in a size_t.

        * config/h8300/elf.h (ENDFILE_SPEC, STARTFILE_SPEC): Define.

Index: stor-layout.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/stor-layout.c,v
retrieving revision 1.103
diff -c -3 -p -r1.103 stor-layout.c
*** stor-layout.c	2001/08/22 14:35:48	1.103
--- stor-layout.c	2001/09/05 03:02:21
*************** layout_type (type)
*** 1442,1447 ****
--- 1442,1460 ----
  	    if (TYPE_SIZE_UNIT (element) != 0 && ! integer_onep (element_size))
  	      TYPE_SIZE_UNIT (type)
  		= size_binop (MULT_EXPR, TYPE_SIZE_UNIT (element), length);
+ 
+ 	    /* Complain if the user has requested an array too large to
+ 	       fit in size_t.  */
+ 	    if (TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST
+ 		&& TREE_OVERFLOW (TYPE_SIZE (type)))
+ 	      {
+ 		error ("requested array too large for target");
+ 
+ 		/* Avoid crashing later.  */
+ 		TYPE_SIZE (type) = element_size;
+ 		if (TYPE_SIZE_UNIT (type))
+ 		  TYPE_SIZE_UNIT (type) = TYPE_SIZE_UNIT (element);
+ 	      }
  	  }
  
  	/* Now round the alignment and size,
Index: config/h8300/elf.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/h8300/elf.h,v
retrieving revision 1.2
diff -c -3 -p -r1.2 elf.h
*** elf.h	2001/09/04 17:14:31	1.2
--- elf.h	2001/09/05 03:02:21
***************
*** 24,29 ****
--- 24,40 ----
  
  #include "elfos.h"
  
+ 
+ #undef  ENDFILE_SPEC
+ #define ENDFILE_SPEC "crtend.o%s %{pg:gcrtn.o%s}%{!pg:crtn.o%s}"
+ 
+ #undef	STARTFILE_SPEC
+ #define STARTFILE_SPEC "%{!shared: \
+ 			 %{!symbolic: \
+ 			  %{pg:gcrt0.o%s}%{!pg:%{p:mcrt0.o%s}%{!p:crt0.o%s}}}}\
+ 			%{pg:gcrti.o%s}%{!pg:crti.o%s} \
+ 			crtbegin.o%s"
+ 
  /* Output at beginning/end of assembler file.  */
  #undef ASM_FILE_START
  #define ASM_FILE_START(FILE)                            \







More information about the Gcc-patches mailing list