Re: boot2 overflow when building with clang

2012-03-09 Thread Jung-uk Kim
On Thursday 08 March 2012 07:16 pm, Dimitry Andric wrote:
 On 2012-03-07 05:51, 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.

 Please test the attached diff.  Since it modifies bsd.sys.mk,
 either run make install in share/mk, or use make buildenv
 before rebuilding sys/boot/i386/boot2.

 It would also be nice if you could test the actual installation of
 the bootstrap, and its proper operation.  However, be sure to have
 some way of recovering the first 16 sectors of your disk before you
 do so. :)

As jhb pointed out, it does not work because BSS for boot2 is not 
automatically cleared.  I fixed this in my branch:

http://svn.freebsd.org/changeset/base/232736
http://svn.freebsd.org/changeset/base/232737

Jung-uk Kim
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: boot2 overflow when building with clang

2012-03-09 Thread John Baldwin
On Thursday, March 08, 2012 7:16:52 pm Dimitry Andric wrote:
 On 2012-03-07 05:51, 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.
 
 Please test the attached diff.  Since it modifies bsd.sys.mk, either run
 make install in share/mk, or use make buildenv before rebuilding
 sys/boot/i386/boot2.
 
 It would also be nice if you could test the actual installation of the
 bootstrap, and its proper operation.  However, be sure to have some way
 of recovering the first 16 sectors of your disk before you do so. :)

The changes to boot2.c are all bugs unfortunately.  boot2's bss is not zero'd.


-- 
John Baldwin
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: boot2 overflow when building with clang

2012-03-08 Thread Peter Wemm
On Wed, Mar 7, 2012 at 4:18 PM, Jung-uk Kim j...@freebsd.org wrote:
 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

I think this should be committed.

If you're concerned about separating them, you can make this case
default for gcc.
There's glue in src/Makefile.inc1 that gives some hints about how this is done
.if ${MK_CLANG} != no  (${MK_CLANG_IS_CC} != no ||
${CC:T:Mclang} == clang)

eg: if building with clang, default to UFS2, else UFS1_AND_UFS2

But please commit something.  Personally I think we could use the
spare space in boot2 in any case.

-- 
Peter Wemm - pe...@wemm.org; pe...@freebsd.org; pe...@yahoo-inc.com; KI6FJV
All of this is for nothing if we don't go to the stars - JMS/B5
If Java had true garbage collection, most programs would delete
themselves upon execution. -- Robert Sewell
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: boot2 overflow when building with clang

2012-03-08 Thread John Baldwin
On Wednesday, March 07, 2012 7:18:56 pm Jung-uk Kim wrote:
 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

I would really rather not go this route.  That is going to cause a lot of pain 
and suffering for users.

-- 
John Baldwin
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: boot2 overflow when building with clang

2012-03-08 Thread Jung-uk Kim
On Thursday 08 March 2012 10:46 am, John Baldwin wrote:
 On Wednesday, March 07, 2012 7:18:56 pm Jung-uk Kim wrote:
  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

 I would really rather not go this route.  That is going to cause a
 lot of pain and suffering for users.

Well, I disagree but don't worrry, I won't commit it today. ;-)

Just in case, I updated the patch to build UFS1+UFS2 boot2 by default 
for GCC as Peter suggested.

Also, I have created a project branch on SVN to increase UFS2 boot 
block size.

http://svnweb.freebsd.org/base/projects/bigbb/

Jung-uk Kim
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: boot2 overflow when building with clang

2012-03-08 Thread Dimitry Andric
On 2012-03-07 05:51, 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.

Please test the attached diff.  Since it modifies bsd.sys.mk, either run
make install in share/mk, or use make buildenv before rebuilding
sys/boot/i386/boot2.

It would also be nice if you could test the actual installation of the
bootstrap, and its proper operation.  However, be sure to have some way
of recovering the first 16 sectors of your disk before you do so. :)
diff --git a/share/mk/bsd.sys.mk b/share/mk/bsd.sys.mk
index 401e671..a8770cc 100644
--- a/share/mk/bsd.sys.mk
+++ b/share/mk/bsd.sys.mk
@@ -100,8 +100,10 @@ CWARNFLAGS	+=	-Wno-unknown-pragmas
 
 .if ${MK_CLANG_IS_CC} != no || ${CC:T:Mclang} == clang
 CLANG_NO_IAS	=	-no-integrated-as
-CLANG_OPT_SMALL	=	-mllvm -stack-alignment=8 -mllvm -inline-threshold=3 \
-			-mllvm -enable-load-pre=false
+CLANG_OPT_SMALL	=	-mllvm -stack-alignment=8 \
+			-mllvm -inline-threshold=3 \
+			-mllvm -enable-load-pre=false \
+			-mllvm -simplifycfg-dup-ret
 .endif
 
 .if ${MK_SSP} != no  ${MACHINE_CPUARCH} != ia64  \
diff --git a/sys/boot/i386/boot2/Makefile b/sys/boot/i386/boot2/Makefile
index 68e49ed..5cec4b5 100644
--- a/sys/boot/i386/boot2/Makefile
+++ b/sys/boot/i386/boot2/Makefile
@@ -26,6 +26,8 @@ CFLAGS=	-Os \
 	-fno-guess-branch-probability \
 	-fomit-frame-pointer \
 	-fno-unit-at-a-time \
+	-ffunction-sections \
+	-fdata-sections \
 	-mno-align-long-strings \
 	-mrtd \
 	-mregparm=3 \
diff --git a/sys/boot/i386/boot2/boot2.c b/sys/boot/i386/boot2/boot2.c
index 8291249..37314f1 100644
--- a/sys/boot/i386/boot2/boot2.c
+++ b/sys/boot/i386/boot2/boot2.c
@@ -148,8 +148,8 @@ static int xputc(int);
 static int xgetc(int);
 static inline int getc(int);
 
-static void memcpy(void *, const void *, int);
-static void
+static __noinline void memcpy(void *, const void *, int);
+static __noinline void
 memcpy(void *dst, const void *src, int len)
 {
 const char *s = src;
@@ -223,10 +223,7 @@ main(void)
 {
 uint8_t autoboot;
 ino_t ino;
-size_t nbyte;
 
-opts = 0;
-kname = NULL;
 dmadat = (void *)(roundup2(__base + (int32_t)_end, 0x1) - __base);
 v86.ctl = V86_FLAGS;
 v86.efl = PSL_RESERVED_DEFAULT | PSL_I;
@@ -242,10 +239,8 @@ main(void)
 autoboot = 1;
 
 if ((ino = lookup(PATH_CONFIG)) ||
-(ino = lookup(PATH_DOTCONFIG))) {
-	nbyte = fsread(ino, cmd, sizeof(cmd) - 1);
-	cmd[nbyte] = '\0';
-}
+(ino = lookup(PATH_DOTCONFIG)))
+	fsread(ino, cmd, sizeof(cmd) - 1);
 
 if (*cmd) {
 	memcpy(cmddup, cmd, sizeof(cmd));
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org

Re: boot2 overflow when building with clang

2012-03-07 Thread Derek Tattersall
From sources csup'ed this morning, I have the same problem.
Is there a fix for folks that don't use SVN?
-- 
Best regards,
Derek Tattersall
d...@mebtel.net dlt...@yahoo.com dtatt...@gmail.com
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: boot2 overflow when building with clang

2012-03-07 Thread Dimitry Andric
On 2012-03-07 20:36, Derek Tattersall wrote:
From sources csup'ed this morning, I have the same problem.
 Is there a fix for folks that don't use SVN?

Assuming you are using CVS, use: cvs up -r 1.99 sys/boot/i386/boot2/boot2.c
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: boot2 overflow when building with clang

2012-03-07 Thread Jung-uk Kim
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 @@ 

boot2 overflow when building with clang

2012-03-06 Thread Jia-Shiun Li
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.


Jia-Shiun.
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org