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, 0x10000) - __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"

Reply via email to