gptboot broken when compiled with clang 6 and WITHOUT_LOADER_GELI -- clang 5 is OK

Andre Albsmeier Andre.Albsmeier at
Mon Apr 30 09:51:15 UTC 2018

On Thu, 26-Apr-2018 at 11:55:19 +0200, Dimitry Andric wrote:
> On 25 Apr 2018, at 18:58, Andre Albsmeier <Andre.Albsmeier at> wrote:
> > 
> > I have set up a new system disk for an i386 11.2-PRERELEASE box. I did the
> > usual
> > 
> > gpart create -s gpt $disk
> > gpart add -t freebsd-boot -s 984 $disk
> > gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 $disk
> > ...
> > 
> > thing, just to notice that the box wouldn't boot. It seems to hang where
> > stage 2 should be run -- when the '\' should start spinning the screen
> > turns white and the box hangs (tested on two machines, an Asus P5W and a
> > Supermicro A2SAV).
> > 
> > So I replaced gptboot on the new disk by the one from an older machine
> > and everything was fine. I wanted to find out what is actually causing
> > the issue and recompiled /usr/src/stand after updating the old sources
> > in several steps.
> > 
> > Eventually it turned out that it depends on the compiler. When compiling
> > the latest /usr/src/stand with clang 5.0.1 the resulting gptboot works.
> > When using 6.0.0 it doesn't. To be exact, it's gptboot.o which is causing
> > the problems. When using a gptboot.o from a clang 5 system it is OK, when
> > using a gptboot.o from a clang 6 system it fails.
> > 
> > To add more confusion: I usually have WITHOUT_LOADER_GELI in my make.conf.
> > When removing this, the resulting gptboot works even when compiled with
> > clang 6...
> > 
> > I can reproduce this in case s.o. wants me to do some tests...
> I can't reproduce it on my end, unfortunately.  I downloaded the latest
> FreeBSD-11.2-PRERELEASE-i386-20180420-r332802 snapshot, installed it to
> a GPT partitioned disk, and it boots just fine.

It is clearly reproducible here with r333082 and with /etc/make.conf having
only WITHOUT_LOADER_GELI. The resulting gptboot is:

-rw-rw----  1 andre  wheel  20859 30 Apr 11:46 /usr/obj/src/src-11/stand/i386/gptboot/gptboot

Here are the logs, maybe something is hidden here:

machine -> /src/src-11/sys/i386/include
x86 -> /src/src-11/sys/x86/include
gzip -cn /src/src-11/stand/i386/gptboot/gptboot.8 > gptboot.8.gz
cc -O2 -pipe   -I/src/src-11/stand/i386/btx/lib -nostdinc -I/usr/obj/src/src-11/stand/libsa -I/src/src-11/stand/libsa -D_STANDALONE -I/src/src-11/sys -Ddouble=jagged-little-pill -Dfloat=floaty-mcfloatface -DLOADER_DISK_SUPPORT -ffreestanding -mno-mmx -mno-sse -mno-avx -msoft-float -march=i386 -I. -DBOOTPROG=\"gptboot\"  -O1  -DGPT  -DUFS1_AND_UFS2  -DSIOPRT=0x3f8  -DSIOFMT=0x3  -DSIOSPD=9600  -I/src/src-11/stand/common  -I/src/src-11/stand/i386/common  -I/src/src-11/stand/i386/boot2  -Wall -Waggregate-return -Wbad-function-cast -Wno-cast-align  -Wmissing-declarations -Wmissing-prototypes -Wnested-externs  -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings  -Winline -Wno-pointer-sign -g -std=gnu99 -Wsystem-headers -Werror -Wno-pointer-sign -Wno-empty-body -Wno-string-plus-int -Wno-unused-const-variable -Wno-tautological-compare -Wno-unused-value -Wno-parentheses-equality -Wno-unused-function -Wno-enum-conversion -Wno-unused-local-typedef -Wno-address-of-packed-member -Wno-switch -Wno-switch-enum -Wno-knr-promoted-parameter -Wno-parentheses  -Qunused-arguments -no-integrated-as   -c /src/src-11/stand/i386/gptboot/gptldr.S -o gptldr.o
ld -static -N --gc-sections -e start -Ttext 0x7c00 -o gptldr.out gptldr.o
objcopy -S -O binary gptldr.out gptldr.bin
cc -O2 -pipe   -I/src/src-11/stand/i386/btx/lib -nostdinc -I/usr/obj/src/src-11/stand/libsa -I/src/src-11/stand/libsa -D_STANDALONE -I/src/src-11/sys -Ddouble=jagged-little-pill -Dfloat=floaty-mcfloatface -DLOADER_DISK_SUPPORT -ffreestanding -mno-mmx -mno-sse -mno-avx -msoft-float -march=i386 -I. -DBOOTPROG=\"gptboot\"  -O1  -DGPT  -DUFS1_AND_UFS2  -DSIOPRT=0x3f8  -DSIOFMT=0x3  -DSIOSPD=9600  -I/src/src-11/stand/common  -I/src/src-11/stand/i386/common  -I/src/src-11/stand/i386/boot2  -Wall -Waggregate-return -Wbad-function-cast -Wno-cast-align  -Wmissing-declarations -Wmissing-prototypes -Wnested-externs  -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings  -Winline -Wno-pointer-sign -g -std=gnu99 -Wsystem-headers -Werror -Wno-pointer-sign -Wno-empty-body -Wno-string-plus-int -Wno-unused-const-variable -Wno-tautological-compare -Wno-unused-value -Wno-parentheses-equality -Wno-unused-function -Wno-enum-conversion -Wno-unused-local-typedef -Wno-address-of-packed-member -Wno-switch -Wno-switch-enum -Wno-knr-promoted-parameter -Wno-parentheses  -Qunused-arguments  -c /src/src-11/stand/i386/gptboot/gptboot.c -o gptboot.o
cc -O2 -pipe   -I/src/src-11/stand/i386/btx/lib -nostdinc -I/usr/obj/src/src-11/stand/libsa -I/src/src-11/stand/libsa -D_STANDALONE -I/src/src-11/sys -Ddouble=jagged-little-pill -Dfloat=floaty-mcfloatface -DLOADER_DISK_SUPPORT -ffreestanding -mno-mmx -mno-sse -mno-avx -msoft-float -march=i386 -I. -DBOOTPROG=\"gptboot\"  -O1  -DGPT  -DUFS1_AND_UFS2  -DSIOPRT=0x3f8  -DSIOFMT=0x3  -DSIOSPD=9600  -I/src/src-11/stand/common  -I/src/src-11/stand/i386/common  -I/src/src-11/stand/i386/boot2  -Wall -Waggregate-return -Wbad-function-cast -Wno-cast-align  -Wmissing-declarations -Wmissing-prototypes -Wnested-externs  -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings  -Winline -Wno-pointer-sign -g -std=gnu99 -Wsystem-headers -Werror -Wno-pointer-sign -Wno-empty-body -Wno-string-plus-int -Wno-unused-const-variable -Wno-tautological-compare -Wno-unused-value -Wno-parentheses-equality -Wno-unused-function -Wno-enum-conversion -Wno-unused-local-typedef -Wno-address-of-packed-member -Wno-switch -Wno-switch-enum -Wno-knr-promoted-parameter -Wno-parentheses  -Qunused-arguments    -c /src/src-11/stand/i386/boot2/sio.S -o sio.o
cc -O2 -pipe   -I/src/src-11/stand/i386/btx/lib -nostdinc -I/usr/obj/src/src-11/stand/libsa -I/src/src-11/stand/libsa -D_STANDALONE -I/src/src-11/sys -Ddouble=jagged-little-pill -Dfloat=floaty-mcfloatface -DLOADER_DISK_SUPPORT -ffreestanding -mno-mmx -mno-sse -mno-avx -msoft-float -march=i386 -I. -DBOOTPROG=\"gptboot\"  -O1  -DGPT  -DUFS1_AND_UFS2  -DSIOPRT=0x3f8  -DSIOFMT=0x3  -DSIOSPD=9600  -I/src/src-11/stand/common  -I/src/src-11/stand/i386/common  -I/src/src-11/stand/i386/boot2  -Wall -Waggregate-return -Wbad-function-cast -Wno-cast-align  -Wmissing-declarations -Wmissing-prototypes -Wnested-externs  -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings  -Winline -Wno-pointer-sign -g -std=gnu99 -Wsystem-headers -Werror -Wno-pointer-sign -Wno-empty-body -Wno-string-plus-int -Wno-unused-const-variable -Wno-tautological-compare -Wno-unused-value -Wno-parentheses-equality -Wno-unused-function -Wno-enum-conversion -Wno-unused-local-typedef -Wno-address-of-packed-member -Wno-switch -Wno-switch-enum -Wno-knr-promoted-parameter -Wno-parentheses  -Qunused-arguments  -c /src/src-11/stand/libsa/crc32.c -o crc32.o
cc -O2 -pipe   -I/src/src-11/stand/i386/btx/lib -nostdinc -I/usr/obj/src/src-11/stand/libsa -I/src/src-11/stand/libsa -D_STANDALONE -I/src/src-11/sys -Ddouble=jagged-little-pill -Dfloat=floaty-mcfloatface -DLOADER_DISK_SUPPORT -ffreestanding -mno-mmx -mno-sse -mno-avx -msoft-float -march=i386 -I. -DBOOTPROG=\"gptboot\"  -O1  -DGPT  -DUFS1_AND_UFS2  -DSIOPRT=0x3f8  -DSIOFMT=0x3  -DSIOSPD=9600  -I/src/src-11/stand/common  -I/src/src-11/stand/i386/common  -I/src/src-11/stand/i386/boot2  -Wall -Waggregate-return -Wbad-function-cast -Wno-cast-align  -Wmissing-declarations -Wmissing-prototypes -Wnested-externs  -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings  -Winline -Wno-pointer-sign -g -std=gnu99 -Wsystem-headers -Werror -Wno-pointer-sign -Wno-empty-body -Wno-string-plus-int -Wno-unused-const-variable -Wno-tautological-compare -Wno-unused-value -Wno-parentheses-equality -Wno-unused-function -Wno-enum-conversion -Wno-unused-local-typedef -Wno-address-of-packed-member -Wno-switch -Wno-switch-enum -Wno-knr-promoted-parameter -Wno-parentheses  -Qunused-arguments  -c /src/src-11/stand/i386/common/drv.c -o drv.o
cc -O2 -pipe   -I/src/src-11/stand/i386/btx/lib -nostdinc -I/usr/obj/src/src-11/stand/libsa -I/src/src-11/stand/libsa -D_STANDALONE -I/src/src-11/sys -Ddouble=jagged-little-pill -Dfloat=floaty-mcfloatface -DLOADER_DISK_SUPPORT -ffreestanding -mno-mmx -mno-sse -mno-avx -msoft-float -march=i386 -I. -DBOOTPROG=\"gptboot\"  -O1  -DGPT  -DUFS1_AND_UFS2  -DSIOPRT=0x3f8  -DSIOFMT=0x3  -DSIOSPD=9600  -I/src/src-11/stand/common  -I/src/src-11/stand/i386/common  -I/src/src-11/stand/i386/boot2  -Wall -Waggregate-return -Wbad-function-cast -Wno-cast-align  -Wmissing-declarations -Wmissing-prototypes -Wnested-externs  -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings  -Winline -Wno-pointer-sign -g -std=gnu99 -Wsystem-headers -Werror -Wno-pointer-sign -Wno-empty-body -Wno-string-plus-int -Wno-unused-const-variable -Wno-tautological-compare -Wno-unused-value -Wno-parentheses-equality -Wno-unused-function -Wno-enum-conversion -Wno-unused-local-typedef -Wno-address-of-packed-member -Wno-switch -Wno-switch-enum -Wno-knr-promoted-parameter -Wno-parentheses  -Qunused-arguments  -c /src/src-11/stand/i386/common/cons.c -o cons.o
ld -static -N --gc-sections -Ttext 0x0 -o gptboot.out /usr/obj/src/src-11/stand/i386/btx/lib/crt0.o gptboot.o sio.o crc32.o drv.o cons.o  /usr/obj/src/src-11/stand/libsa/libsa.a
objcopy -S -O binary gptboot.out gptboot.bin
btxld -v -E 0x0 -f bin -b /usr/obj/src/src-11/stand/i386/btx/btx/btx -l gptldr.bin  -o gptboot gptboot.bin
kernel: ver=1.02 size=690 load=9000 entry=9010 map=16M pgctl=0:0
client: fmt=bin size=4a69 text=0 data=0 bss=0 entry=0
output: fmt=bin size=517b text=82 data=50f9 org=0 entry=0

More information about the freebsd-stable mailing list