On Tuesday 06 March 2012 11:51 pm, Jia-Shiun Li wrote:
> I am not familiar with boot2, but it looks like allocated size for
> boot2 is not enough to hold code generated by clang. Reverting
> r232570 fixes it.
>
> ===> sys/boot/i386/boot2 (all)
> objcopy -S -O binary boot1.out boot1
> dd if=/dev/zero of=boot2.ldr bs=512 count=1
> clang -Os  -fno-guess-branch-probability  -fomit-frame-pointer
> -fno-unit-at-a-time  -mno-align-long-strings  -mrtd  -mregparm=3
> -DUSE_XREAD  -DUFS1_AND_UFS2  -DFLAGS=0x80  -DSIOPRT=0x3f8
> -DSIOFMT=0x3  -DSIOSPD=9600
> -I/usr/src/sys/boot/i386/boot2/../../common
> -I/usr/src/sys/boot/i386/boot2/../btx/lib -I.  -Wall
> -Waggregate-return -Wbad-function-cast -Wcast-align
> -Wmissing-declarations -Wmissing-prototypes -Wnested-externs
> -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings 
> -Winline --param max-inline-insns-single=100  -mllvm
> -stack-alignment=8 -mllvm -inline-threshold=3  -mllvm
> -enable-load-pre=false -ffreestanding -mpreferred-stack-boundary=2 
> -mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 -msoft-float
> -std=gnu99    -S -o boot2.s.tmp
> /usr/src/sys/boot/i386/boot2/boot2.c
> sed -e '/align/d' -e '/nop/d' < boot2.s.tmp > boot2.s
> rm -f boot2.s.tmp
> clang  -c boot2.s
> clang -Os  -fno-guess-branch-probability  -fomit-frame-pointer
> -fno-unit-at-a-time  -mno-align-long-strings  -mrtd  -mregparm=3
> -DUSE_XREAD  -DUFS1_AND_UFS2  -DFLAGS=0x80  -DSIOPRT=0x3f8
> -DSIOFMT=0x3  -DSIOSPD=9600
> -I/usr/src/sys/boot/i386/boot2/../../common
> -I/usr/src/sys/boot/i386/boot2/../btx/lib -I.  -Wall
> -Waggregate-return -Wbad-function-cast -Wcast-align
> -Wmissing-declarations -Wmissing-prototypes -Wnested-externs
> -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings 
> -Winline --param max-inline-insns-single=100  -mllvm
> -stack-alignment=8 -mllvm -inline-threshold=3  -mllvm
> -enable-load-pre=false -ffreestanding -mpreferred-stack-boundary=2 
> -mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 -msoft-float
> -std=gnu99     -c
> /usr/src/sys/boot/i386/boot2/sio.S
> ld -static -N --gc-sections -nostdlib -Ttext 0x2000 -o boot2.out
> /usr/obj/usr/src/sys/boot/i386/boot2/../btx/lib/crt0.o boot2.o
> sio.o objcopy -S -O binary boot2.out boot2.bin
> btxld -v -E 0x2000 -f bin -b
> /usr/obj/usr/src/sys/boot/i386/boot2/../btx/btx/btx -l boot2.ldr 
> -o boot2.ld -P 1 boot2.bin
> kernel: ver=1.02 size=690 load=9000 entry=9010 map=16M pgctl=1:1
> client: fmt=bin size=15a1 text=0 data=0 bss=0 entry=0
> output: fmt=bin size=1e31 text=200 data=1c31 org=0 entry=0
> -49 bytes available
> *** [boot2] Error code 1
>
> Stop in /usr/src/sys/boot/i386/boot2.
> *** [all] Error code 1
>
> Stop in /usr/src/sys/boot/i386.
> *** [all] Error code 1
>
> Stop in /usr/src/sys/boot.
> *** [all] Error code 1
>
> Stop in /usr/src/sys.
> *** [sys.all__D] Error code 1
>
> Stop in /usr/src.
> *** [everything] Error code 1
>
> Stop in /usr/src.
> *** [buildworld] Error code 1
>
> Stop in /usr/src.

Here is a patch to work around the problem:

http://people.freebsd.org/~jkim/boot2.diff

Please note this patch creates two separate boot codes, one for UFS1 
and one for UFS2.  To generate previous boot code (i.e., UFS1+UFS2) 
with GCC, clean objects, add the following line to 
your /etc/make.conf, rebuild, and install:

BOOT2_UFS=UFS1_AND_UFS2

Cheers,

Jung-uk Kim
Index: sys/boot/i386/Makefile
===================================================================
--- sys/boot/i386/Makefile      (revision 232670)
+++ sys/boot/i386/Makefile      (working copy)
@@ -2,8 +2,8 @@
 
 .include <bsd.own.mk>
 
-SUBDIR=                mbr pmbr boot0 boot0sio btx boot2 cdboot gptboot kgzldr 
\
-               libi386 libfirewire loader
+SUBDIR=                mbr pmbr boot0 boot0sio btx boot2 boot2ufs1 cdboot 
gptboot \
+               kgzldr libi386 libfirewire loader
 
 # special boot programs, 'self-extracting boot2+loader'
 SUBDIR+=       pxeldr
Index: sys/boot/i386/boot2/Makefile
===================================================================
--- sys/boot/i386/boot2/Makefile        (revision 232670)
+++ sys/boot/i386/boot2/Makefile        (working copy)
@@ -2,8 +2,10 @@
 
 .include <bsd.own.mk>
 
-FILES=         boot boot1 boot2
+FILES=         boot${BOOT_SUFFIX} boot2${BOOT2_SUFFIX}
 
+SRCDIR=                ${.CURDIR}/../boot2
+
 NM?=           nm
 
 # A value of 0x80 enables LBA support.
@@ -18,10 +20,22 @@ ORG1=       0x7c00
 ORG2=  0x2000
 
 # Decide level of UFS support.
-BOOT2_UFS?=    UFS1_AND_UFS2
-#BOOT2_UFS?=   UFS2_ONLY
-#BOOT2_UFS?=   UFS1_ONLY
+BOOT2_UFS?=    UFS2_ONLY
+#BOOT2_UFS?=   UFS1_AND_UFS2
 
+.if ${BOOT2_UFS} != UFS1_ONLY
+FILES+=                boot1
+.endif
+.if ${BOOT2_UFS} == UFS1_ONLY
+BOOT_SUFFIX=   .ufs1
+BOOT2_SUFFIX=  ufs1
+.elif ${BOOT2_UFS} == UFS2_ONLY
+BOOT_SUFFIX=   .ufs2
+BOOT2_SUFFIX=  ufs2
+LINKS=         ${BINDIR}/boot${BOOT_SUFFIX} ${BINDIR}/boot \
+               ${BINDIR}/boot2${BOOT2_SUFFIX} ${BINDIR}/boot2
+.endif
+
 CFLAGS=        -Os \
        -fno-guess-branch-probability \
        -fomit-frame-pointer \
@@ -50,8 +64,8 @@ LDFLAGS=-static -N --gc-sections
 
 CLEANFILES=    boot
 
-boot: boot1 boot2
-       cat boot1 boot2 > boot
+boot${BOOT_SUFFIX}: boot1 boot2${BOOT2_SUFFIX}
+       cat ${.ALLSRC} > ${.TARGET}
 
 CLEANFILES+=   boot1 boot1.out boot1.o
 
@@ -64,7 +78,7 @@ boot1.out: boot1.o
 CLEANFILES+=   boot2 boot2.ld boot2.ldr boot2.bin boot2.out boot2.o \
                boot2.s boot2.s.tmp boot2.h sio.o
 
-boot2: boot2.ld
+boot2${BOOT2_SUFFIX}: boot2.ld
        @set -- `ls -l boot2.ld`; x=$$((7680-$$5)); \
            echo "$$x bytes available"; test $$x -ge 0
        dd if=boot2.ld of=${.TARGET} obs=7680 conv=osync
@@ -88,7 +102,7 @@ boot2.o: boot2.s
 SRCS=  boot2.c boot2.h
 
 boot2.s: boot2.c boot2.h ${.CURDIR}/../../common/ufsread.c
-       ${CC} ${CFLAGS} -S -o boot2.s.tmp ${.CURDIR}/boot2.c
+       ${CC} ${CFLAGS} -S -o boot2.s.tmp ${SRCDIR}/boot2.c
        sed -e '/align/d' -e '/nop/d' < boot2.s.tmp > boot2.s
        rm -f boot2.s.tmp
 
Index: sys/boot/i386/boot2ufs1/Makefile
===================================================================
--- sys/boot/i386/boot2ufs1/Makefile    (revision 0)
+++ sys/boot/i386/boot2ufs1/Makefile    (working copy)
@@ -0,0 +1,7 @@
+# $FreeBSD$
+
+.PATH: ${.CURDIR}/../boot2
+
+BOOT2_UFS=     UFS1_ONLY
+
+.include "${.CURDIR}/../boot2/Makefile"

Property changes on: sys/boot/i386/boot2ufs1/Makefile
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+FreeBSD=%H
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "[email protected]"

Reply via email to