From ef794f958c3ecb84c7a0351bebb4efb0c554c9ce Mon Sep 17 00:00:00 2001 From: fwsgonzo Date: Fri, 9 Sep 2016 21:46:47 +0200 Subject: [PATCH 1/2] elf: add branch hints in getsym --- src/kernel/elf.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/kernel/elf.cpp b/src/kernel/elf.cpp index 03b7bebec7..17c15e56ef 100644 --- a/src/kernel/elf.cpp +++ b/src/kernel/elf.cpp @@ -16,6 +16,7 @@ // limitations under the License. #include +#include #include #include #include @@ -72,14 +73,16 @@ class ElfTables func_offset getsym(Elf32_Addr addr) { // probably just a null pointer with ofs=addr - if (addr < 0x7c00) return {null_stringz, 0, addr}; + if (UNLIKELY(addr < 0x7c00)) + return {null_stringz, 0, addr}; // definitely in the bootloader - if (addr < 0x7e00) return {boot_stringz, 0x7c00, addr - 0x7c00}; + if (UNLIKELY(addr < 0x7e00)) + return {boot_stringz, 0x7c00, addr - 0x7c00}; // resolve manually from symtab auto* sym = getaddr(addr); // validate symbol address //assert(sym >= symtab.base && sym < symtab.base + symtab.entries); - if (sym) { + if (LIKELY(sym)) { auto base = sym->st_value; auto offset = addr - base; // return string name for symbol From 837d3d0025f2c0860bd3041028af6415e6f1e0bd Mon Sep 17 00:00:00 2001 From: Gonzo Date: Mon, 12 Sep 2016 15:56:37 +0200 Subject: [PATCH 2/2] make: Avoid using strip for all, use ld --strip-all instead --- src/seed/Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/seed/Makefile b/src/seed/Makefile index 8ff805bacb..30ec314228 100644 --- a/src/seed/Makefile +++ b/src/seed/Makefile @@ -50,8 +50,8 @@ INCLUDES = -I$(INC_LIBCXX) -I$(INSTALL)/api/sys -I$(INC_NEWLIB) -I$(INSTALL)/api all: CAPABS = $(CAPABS_COMMON) -O2 -DOS_TERMINATE_ON_CONTRACT_VIOLATION debug: CAPABS = $(CAPABS_COMMON) -O0 stripped: CAPABS = $(CAPABS_COMMON) -Os -# by default, remove debugging -STRIPPED=-S +# by default, don't use strip because it has caused us some problems +STRIPPED= CPPOPTS = $(CAPABS) $(WARNS) -c -m32 -std=c++14 $(INCLUDES) -D_LIBCPP_HAS_NO_THREADS=1 -D_GNU_SOURCE LDOPTS = -nostdlib -melf_i386 -N --eh-frame-hdr --script=$(INSTALL)/linker.ld --defsym _MAX_MEM_MIB_=$(MAX_MEM) --defsym=__stack_rand_ba=`date +%s` @@ -88,6 +88,7 @@ DEPS = $(OBJS:.o=.d) # - a "service", to be linked with OS-objects (OS included) .PHONY: all stripped debug debug-info debug-all memdisk service +all: LDOPTS += --strip-debug all: service stripped: LDOPTS += -s