Date: Thu, 8 Mar 2012 10:43:28 -0800 From: Peter Wemm <peter@wemm.org> To: Jung-uk Kim <jkim@freebsd.org> Cc: freebsd-current@freebsd.org, Jia-Shiun Li <jiashiun@gmail.com> Subject: Re: boot2 overflow when building with clang Message-ID: <CAGE5yCrXOaTY0XVcAVbNpPwYqevKmeLvZyootySHjrCCRuyOjg@mail.gmail.com> In-Reply-To: <201203071919.01511.jkim@FreeBSD.org> References: <CAHNYxxM%2BJSVZZG9KGRa%2BVAEj2yzkHTFv%2BtBZioXJ9G-3L2vUUQ@mail.gmail.com> <201203071919.01511.jkim@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Mar 7, 2012 at 4:18 PM, Jung-uk Kim <jkim@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. >> >> =3D=3D=3D> sys/boot/i386/boot2 (all) >> objcopy -S -O binary boot1.out boot1 >> dd if=3D/dev/zero of=3Dboot2.ldr bs=3D512 count=3D1 >> clang -Os =A0-fno-guess-branch-probability =A0-fomit-frame-pointer >> -fno-unit-at-a-time =A0-mno-align-long-strings =A0-mrtd =A0-mregparm=3D3 >> -DUSE_XREAD =A0-DUFS1_AND_UFS2 =A0-DFLAGS=3D0x80 =A0-DSIOPRT=3D0x3f8 >> -DSIOFMT=3D0x3 =A0-DSIOSPD=3D9600 >> -I/usr/src/sys/boot/i386/boot2/../../common >> -I/usr/src/sys/boot/i386/boot2/../btx/lib -I. =A0-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=3D100 =A0-mllvm >> -stack-alignment=3D8 -mllvm -inline-threshold=3D3 =A0-mllvm >> -enable-load-pre=3Dfalse -ffreestanding -mpreferred-stack-boundary=3D2 >> -mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 -msoft-float >> -std=3Dgnu99 =A0 =A0-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 =A0-c boot2.s >> clang -Os =A0-fno-guess-branch-probability =A0-fomit-frame-pointer >> -fno-unit-at-a-time =A0-mno-align-long-strings =A0-mrtd =A0-mregparm=3D3 >> -DUSE_XREAD =A0-DUFS1_AND_UFS2 =A0-DFLAGS=3D0x80 =A0-DSIOPRT=3D0x3f8 >> -DSIOFMT=3D0x3 =A0-DSIOSPD=3D9600 >> -I/usr/src/sys/boot/i386/boot2/../../common >> -I/usr/src/sys/boot/i386/boot2/../btx/lib -I. =A0-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=3D100 =A0-mllvm >> -stack-alignment=3D8 -mllvm -inline-threshold=3D3 =A0-mllvm >> -enable-load-pre=3Dfalse -ffreestanding -mpreferred-stack-boundary=3D2 >> -mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 -msoft-float >> -std=3Dgnu99 =A0 =A0 -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=3D1.02 size=3D690 load=3D9000 entry=3D9010 map=3D16M pgctl= =3D1:1 >> client: fmt=3Dbin size=3D15a1 text=3D0 data=3D0 bss=3D0 entry=3D0 >> output: fmt=3Dbin size=3D1e31 text=3D200 data=3D1c31 org=3D0 entry=3D0 >> -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. =A0To 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=3DUFS1_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 d= one .if ${MK_CLANG} !=3D "no" && (${MK_CLANG_IS_CC} !=3D "no" || ${CC:T:Mclang} =3D=3D "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. --=20 Peter Wemm - peter@wemm.org; peter@FreeBSD.org; peter@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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAGE5yCrXOaTY0XVcAVbNpPwYqevKmeLvZyootySHjrCCRuyOjg>