Subject: port-pc532/17319: pc532 port depends on old toolchain
To: None <gnats-bugs@gnats.netbsd.org>
From: Ian Dall <Ian.Dall@dsto.defence.gov.au>
List: netbsd-bugs
Date: 06/19/2002 18:01:12
>Number:         17319
>Category:       port-pc532
>Synopsis:       pc532 port depends on old toolchain
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    port-pc532-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Jun 19 01:40:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Ian Dall
>Release:        NetBSD 1.5ZC
>Organization:
private
>Environment:
	
	
System: NetBSD gateway.beware.dropbear.id.au 1.5ZC NetBSD 1.5ZC (SIBYL) #2: Sat Jun 15 00:22:45 CST 2002 ian@sibyl.beware.dropbear.id.au:/usr1/local/src/netbsd/src/sys/arch/pc532/compile/SIBYL pc532
Architecture: ns32k
Machine: pc532
>Description:
	
The pc532 port depends on the old toolchain in a number of places.
>How-To-Repeat:
	
>Fix:
	
The following patch impliments the following fixes:

 o Don't use -z flag. It is the default anyway and is not recognized
   by the new ld.

 o The new ld defines the origin of the text segment differently, so the
   base must be adjusted up by 0x20

 o Define _BSD_VA_LIST_ properly for the new compiler

 o locore.s has illegal instructions in it. The old assembler didn't
   mind, but the new one does.

 o wind back the optimization to build stand/boot. -O3 triggers a
   compiler bug.

 o use ${STRIP} instead of strip and ${SIZE} instead of size to
   support cross building.

 o Include machine/intr.h from psl.h. I don't recall where this matters.

Index: netbsd/src/sys/arch/pc532/conf/Makefile.pc532
diff -c netbsd/src/sys/arch/pc532/conf/Makefile.pc532:1.1.1.2 netbsd/src/sys/arch/pc532/conf/Makefile.pc532:1.2
*** netbsd/src/sys/arch/pc532/conf/Makefile.pc532:1.1.1.2	Fri Jan  4 15:57:44 2002
--- netbsd/src/sys/arch/pc532/conf/Makefile.pc532	Mon Jun 17 22:30:19 2002
***************
*** 53,60 ****
  ##
  ## (5) link settings
  ##
! LINKFORMAT=	-z
! TEXTADDR?=	E0002000
  
  ##
  ## (6) port specific target dependencies
--- 53,67 ----
  ##
  ## (5) link settings
  ##
! 
! # The BFD based LD, defines the text start addess to be after the 32 byte
! # header. There is only a discrepency for ZMAGIC (the default).
! LINKFORMAT=
! .if defined(USE_NEW_TOOLCHAIN)
! TEXTADDR?=	0xe0002020
! .else
! TEXTADDR?=	0xe0002000
! .endif
  
  ##
  ## (6) port specific target dependencies
Index: netbsd/src/sys/arch/pc532/include/ansi.h
diff -c netbsd/src/sys/arch/pc532/include/ansi.h:1.1.1.1 netbsd/src/sys/arch/pc532/include/ansi.h:1.2
*** netbsd/src/sys/arch/pc532/include/ansi.h:1.1.1.1	Mon Nov 26 00:00:53 2001
--- netbsd/src/sys/arch/pc532/include/ansi.h	Fri Jun  7 16:42:47 2002
***************
*** 38,43 ****
--- 38,45 ----
  #ifndef	_ANSI_H_
  #define	_ANSI_H_
  
+ #include <sys/cdefs.h>
+ 
  #include <machine/int_types.h>
  
  /*
***************
*** 54,60 ****
--- 56,66 ----
  #define	_BSD_SIZE_T_		unsigned int	/* sizeof() */
  #define	_BSD_SSIZE_T_		int		/* byte count or error */
  #define	_BSD_TIME_T_		long		/* time() */
+ #if __GNUC_PREREQ__(2, 96)
+ #define	_BSD_VA_LIST_		__builtin_va_list /* GCC built-in type */
+ #else
  #define	_BSD_VA_LIST_		char *		/* va_list */
+ #endif
  #define	_BSD_CLOCKID_T_		int		/* clockid_t */
  #define	_BSD_TIMER_T_		int		/* timer_t */
  #define	_BSD_SUSECONDS_T_	int		/* suseconds_t */
Index: netbsd/src/sys/arch/pc532/include/psl.h
diff -c netbsd/src/sys/arch/pc532/include/psl.h:1.1.1.2 netbsd/src/sys/arch/pc532/include/psl.h:1.3
*** netbsd/src/sys/arch/pc532/include/psl.h:1.1.1.2	Wed Jun 12 12:16:22 2002
--- netbsd/src/sys/arch/pc532/include/psl.h	Wed Jun 12 15:01:07 2002
***************
*** 64,67 ****
--- 64,70 ----
  /* The PSR versions ... */
  #define PSR_USR PSL_USER
  
+ #ifdef _KERNEL
+ #include <machine/intr.h>
+ #endif /* _KERNEL */
  #endif /* _NS532_PSL_H_ */
Index: netbsd/src/sys/arch/pc532/pc532/locore.s
diff -c netbsd/src/sys/arch/pc532/pc532/locore.s:1.1.1.2 netbsd/src/sys/arch/pc532/pc532/locore.s:1.2
*** netbsd/src/sys/arch/pc532/pc532/locore.s:1.1.1.2	Wed Jun 12 12:16:23 2002
--- netbsd/src/sys/arch/pc532/pc532/locore.s	Mon Jun 17 22:33:35 2002
***************
*** 154,160 ****
  	movqd	0,tos			/* Push a fake return address. */
  	movd	SYS___sigreturn14,r0
  	svc
! 	movd	0,0			/* Illegal instruction. */
  GLOBAL(esigcode)
  
  #if defined(PROF) || defined(GPROF) || defined(KGDB) || defined(DDB)
--- 154,162 ----
  	movqd	0,tos			/* Push a fake return address. */
  	movd	SYS___sigreturn14,r0
  	svc
! 	.word	0x0517,0		/* Pattern of Illegal Instruction
! 					   movd r0, 0 */
! /*	movd	0,0			/* Illegal instruction. */
  GLOBAL(esigcode)
  
  #if defined(PROF) || defined(GPROF) || defined(KGDB) || defined(DDB)
Index: netbsd/src/sys/arch/pc532/stand/Makefile.buildboot
diff -c netbsd/src/sys/arch/pc532/stand/Makefile.buildboot:1.1.1.2 netbsd/src/sys/arch/pc532/stand/Makefile.buildboot:1.2
*** netbsd/src/sys/arch/pc532/stand/Makefile.buildboot:1.1.1.2	Fri Jan  4 15:57:47 2002
--- netbsd/src/sys/arch/pc532/stand/Makefile.buildboot	Mon Jun 17 22:39:25 2002
***************
*** 12,18 ****
  CLEANFILES+=	${PROG}.sym ${PROG}
  
  CPPFLAGS+=	-I${.CURDIR}/../../.. -I${.CURDIR}/../../../..
! CFLAGS=		-O3 -fno-inline
  #CFLAGS+=	-Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-format
  
  # no lint here (yet?)
--- 12,19 ----
  CLEANFILES+=	${PROG}.sym ${PROG}
  
  CPPFLAGS+=	-I${.CURDIR}/../../.. -I${.CURDIR}/../../../..
! 
! CFLAGS=		-O2
  #CFLAGS+=	-Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-format
  
  # no lint here (yet?)
***************
*** 20,26 ****
  
  ${PROG}: ${PROG}.sym
  	cp ${PROG}.sym ${PROG}
! 	strip ${PROG}
  
  .include <bsd.prog.mk>
  
--- 21,27 ----
  
  ${PROG}: ${PROG}.sym
  	cp ${PROG}.sym ${PROG}
! 	${STRIP} ${PROG}
  
  .include <bsd.prog.mk>
  
***************
*** 45,50 ****
  	sh ${S}/conf/newvers_stand.sh ${.CURDIR}/version "pc532" ${NEWVERSWHAT}
  
  ${PROG}.sym: ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN}
! 	${LD} -Ttext ${RELOC} -z -e start -o ${PROG}.sym \
  	    ${OBJS} ${LIBSA} ${LIBZ} ${LIBSA} ${LIBKERN}
! 	@size ${PROG}.sym
--- 46,51 ----
  	sh ${S}/conf/newvers_stand.sh ${.CURDIR}/version "pc532" ${NEWVERSWHAT}
  
  ${PROG}.sym: ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN}
! 	${LD} -Ttext ${RELOC} -e start -o ${PROG}.sym \
  	    ${OBJS} ${LIBSA} ${LIBZ} ${LIBSA} ${LIBKERN}
! 	@${SIZE} ${PROG}.sym
Index: netbsd/src/sys/arch/pc532/stand/Makefile.inc
diff -c netbsd/src/sys/arch/pc532/stand/Makefile.inc:1.1.1.1 netbsd/src/sys/arch/pc532/stand/Makefile.inc:1.2
*** netbsd/src/sys/arch/pc532/stand/Makefile.inc:1.1.1.1	Mon Nov 26 00:00:53 2001
--- netbsd/src/sys/arch/pc532/stand/Makefile.inc	Mon Jun 17 22:40:53 2002
***************
*** 5,11 ****
  # Load at 0x260000 + 2800 * 512
  # That way the boot code will be at the correct address if the floppy
  # image is started from memory.
! RELOC=		3BE000
  
  CLEANFILES+=	${PROG}.sym ${PROG}
  
--- 5,18 ----
  # Load at 0x260000 + 2800 * 512
  # That way the boot code will be at the correct address if the floppy
  # image is started from memory.
! 
! # The BFD based LD, defines the text start addess to be after the 32 byte
! # header. There is only a discrepency for ZMAGIC (the default).
! .if defined(USE_NEW_TOOLCHAIN)
! RELOC=		0x3be020
! .else
! RELOC=		0x3be000
! .endif
  
  CLEANFILES+=	${PROG}.sym ${PROG}
  

>Release-Note:
>Audit-Trail:
>Unformatted: