Date: Fri, 09 Mar 2012 01:16:52 +0100 From: Dimitry Andric <dim@FreeBSD.org> To: Jia-Shiun Li <jiashiun@gmail.com> Cc: freebsd-current@freebsd.org, Jung-uk Kim <jkim@FreeBSD.org>, John Baldwin <jhb@FreeBSD.org> Subject: Re: boot2 overflow when building with clang Message-ID: <4F594BF4.9060802@FreeBSD.org> In-Reply-To: <CAHNYxxM%2BJSVZZG9KGRa%2BVAEj2yzkHTFv%2BtBZioXJ9G-3L2vUUQ@mail.gmail.com> References: <CAHNYxxM%2BJSVZZG9KGRa%2BVAEj2yzkHTFv%2BtBZioXJ9G-3L2vUUQ@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format. --------------060704000108040704050100 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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. :) --------------060704000108040704050100 Content-Type: text/x-diff; name="boot2-shrink-1.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="boot2-shrink-1.diff" 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)); --------------060704000108040704050100--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4F594BF4.9060802>