[patch,v850] make sbrk -msda-proof

Jeff Johnston jjohnstn@redhat.com
Thu Oct 4 08:10:00 GMT 2012


Fine by me assuming you have tested it with and without the option 
specified.

-- Jeff J.

On 10/01/2012 05:44 PM, DJ Delorie wrote:
> The use of "extern char heap_start;" in sbrk triggers an addressing
> mode change with -msda=4, leading to link-time errors.  Changing it to
> an unspecified-sized array forces gcc to use the most pessimum
> addressing mode, which will always work with linker-defined symbols.
> Ok?
>
> 	* libc/sys/sysnecv850/sbrk.c (_sbrk): Change heap_start to be an
> 	array of undefined size, to avoid problems when compiled with
> 	-msda=4.
>
> 	* v850/sbrk.c (_sbrk): Change heap_start to be an array of
> 	undefined size, to avoid problems when compiled with -msda=4.
>
> Index: newlib/libc/sys/sysnecv850/sbrk.c
> ===================================================================
> RCS file: /cvs/src/src/newlib/libc/sys/sysnecv850/sbrk.c,v
> retrieving revision 1.2
> diff -p -U5 -r1.2  newlib/libc/sys/sysnecv850/sbrk.c
> --- newlib/libc/sys/sysnecv850/sbrk.c	27 May 2011 10:46:47 -0000	1.2
> +++ newlib/libc/sys/sysnecv850/sbrk.c	1 Oct 2012 21:36:29 -0000
> @@ -4,17 +4,17 @@
>   #include "sys/syscall.h"
>
>   caddr_t
>   _sbrk (int incr)
>   {
> -  extern char   heap_start;	/* Defined by the linker script.  */
> +  extern char   heap_start[];	/* Defined by the linker script.  */
>     static char * heap_end = NULL;
>     char *        prev_heap_end;
>     char *        sp = (char *) & sp;
>
>     if (heap_end == NULL)
> -    heap_end = & heap_start;
> +    heap_end = heap_start;
>
>     prev_heap_end = heap_end;
>
>     if (heap_end + incr > sp)
>       {
>
> Index: libgloss/v850/sbrk.c
> ===================================================================
> RCS file: /cvs/src/src/libgloss/v850/sbrk.c,v
> retrieving revision 1.2
> diff -p -U5 -r1.2  libgloss/v850/sbrk.c
> --- libgloss/v850/sbrk.c	27 May 2011 10:46:48 -0000	1.2
> +++ libgloss/v850/sbrk.c	1 Oct 2012 21:36:30 -0000
> @@ -4,17 +4,17 @@
>   #include "sys/syscall.h"
>
>   caddr_t
>   _sbrk (int incr)
>   {
> -  extern char   heap_start;		/* Defined by the linker script. */
> +  extern char   heap_start[];		/* Defined by the linker script. */
>     static char * heap_end = NULL;
>     char *        prev_heap_end;
>     char *        sp = (char *) & sp;
>
>     if (heap_end == NULL)
> -    heap_end = & heap_start;
> +    heap_end = heap_start;
>
>     prev_heap_end = heap_end;
>
>     if (heap_end + incr > sp)
>       {
>



More information about the Newlib mailing list