diff options
author | dim <dim@FreeBSD.org> | 2014-11-24 20:01:05 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2014-11-24 20:01:05 +0000 |
commit | ba7b4061981dcd43044c900f105e31ed99c4c76c (patch) | |
tree | e0f70f0c7a087e89e08fcf07fb1c4f29087f1dec | |
parent | acd4f874a56a9ad943bdc028c277fe39e64efe88 (diff) | |
download | FreeBSD-src-ba7b4061981dcd43044c900f105e31ed99c4c76c.zip FreeBSD-src-ba7b4061981dcd43044c900f105e31ed99c4c76c.tar.gz |
Ensure boot2 stays below the limit, by applying a patch from Roman
Divacky which shrinks the code, and by using the custom llvm option to
disable the Global Value Numbering optimization pass.
-rw-r--r-- | share/mk/bsd.sys.mk | 2 | ||||
-rw-r--r-- | sys/boot/i386/boot2/Makefile | 8 | ||||
-rw-r--r-- | sys/boot/i386/boot2/boot2.c | 23 |
3 files changed, 19 insertions, 14 deletions
diff --git a/share/mk/bsd.sys.mk b/share/mk/bsd.sys.mk index 635d428..af2c024 100644 --- a/share/mk/bsd.sys.mk +++ b/share/mk/bsd.sys.mk @@ -116,7 +116,7 @@ CWARNFLAGS+= -Wno-unknown-pragmas CLANG_NO_IAS= -no-integrated-as .endif CLANG_OPT_SMALL= -mstack-alignment=8 -mllvm -inline-threshold=3\ - -mllvm -enable-load-pre=false -mllvm -simplifycfg-dup-ret + -mllvm -simplifycfg-dup-ret -mllvm -enable-gvn=false CFLAGS.clang+= -Qunused-arguments .if ${MACHINE_CPUARCH} == "sparc64" # Don't emit .cfi directives, since we must use GNU as on sparc64, for now. diff --git a/sys/boot/i386/boot2/Makefile b/sys/boot/i386/boot2/Makefile index 40413e9..878fd15 100644 --- a/sys/boot/i386/boot2/Makefile +++ b/sys/boot/i386/boot2/Makefile @@ -22,8 +22,7 @@ BOOT2_UFS?= UFS1_AND_UFS2 #BOOT2_UFS?= UFS2_ONLY #BOOT2_UFS?= UFS1_ONLY -CFLAGS= -Os \ - -fomit-frame-pointer \ +CFLAGS= -fomit-frame-pointer \ -mrtd \ -mregparm=3 \ -DUSE_XREAD \ @@ -39,12 +38,13 @@ CFLAGS= -Os \ -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings \ -Winline -CFLAGS.gcc+= -fno-guess-branch-probability \ +CFLAGS.gcc+= -Os \ + -fno-guess-branch-probability \ -fno-unit-at-a-time \ -mno-align-long-strings \ --param max-inline-insns-single=100 -CFLAGS.clang+=${CLANG_OPT_SMALL} +CFLAGS.clang+= -Oz ${CLANG_OPT_SMALL} LD_FLAGS=-static -N --gc-sections diff --git a/sys/boot/i386/boot2/boot2.c b/sys/boot/i386/boot2/boot2.c index cd384e5..0383ea3 100644 --- a/sys/boot/i386/boot2/boot2.c +++ b/sys/boot/i386/boot2/boot2.c @@ -323,7 +323,8 @@ load(void) caddr_t p; ufs_ino_t ino; uint32_t addr; - int i, j; + uint8_t i, j; + int k; if (!(ino = lookup(kname))) { if (!ls) @@ -344,7 +345,7 @@ load(void) return; } else if (IS_ELF(hdr.eh)) { fs_off = hdr.eh.e_phoff; - for (j = i = 0; i < hdr.eh.e_phnum && j < 2; i++) { + for (j = k = 0; k < hdr.eh.e_phnum && j < 2; k++) { if (xfsread(ino, ep + j, sizeof(ep[0]))) return; if (ep[j].p_type == PT_LOAD) @@ -393,7 +394,9 @@ parse() char *ep, *p, *q; const char *cp; unsigned int drv; - int c, i, j; + uint8_t i; + int c, j; + size_t k; while ((c = *arg++)) { if (c == ' ' || c == '\t' || c == '\n') @@ -416,7 +419,7 @@ parse() #if SERIAL } else if (c == 'S') { j = 0; - while ((unsigned int)(i = *arg++ - '0') <= 9) + while ((i = *arg++ - '0') <= 9) j = j * 10 + i; if (j > 0 && i == -'0') { comspeed = j; @@ -479,10 +482,10 @@ parse() ? DRV_HARD : 0) + drv; dsk_meta = 0; } - if ((i = ep - arg)) { - if ((size_t)i >= sizeof(knamebuf)) + if (k = ep - arg) { + if (k >= sizeof(knamebuf)) return -1; - memcpy(knamebuf, arg, i + 1); + memcpy(knamebuf, arg, k + 1); kname = knamebuf; } } @@ -605,8 +608,10 @@ drvread(void *buf, unsigned lba, unsigned nblk) { static unsigned c = 0x2d5c7c2f; - if (!OPT_CHECK(RBX_QUIET)) - printf("%c\b", c = c << 8 | c >> 24); + if (!OPT_CHECK(RBX_QUIET)) { + xputc(c = c << 8 | c >> 24); + xputc('\b'); + } v86.ctl = V86_ADDR | V86_CALLF | V86_FLAGS; v86.addr = XREADORG; /* call to xread in boot1 */ v86.es = VTOPSEG(buf); |