File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1616// limitations under the License.
1717
1818#include < kernel/elf.hpp>
19+ #include < common>
1920#include < cassert>
2021#include < cstdio>
2122#include < string>
@@ -72,14 +73,16 @@ class ElfTables
7273 func_offset getsym (Elf32_Addr addr)
7374 {
7475 // probably just a null pointer with ofs=addr
75- if (addr < 0x7c00 ) return {null_stringz, 0 , addr};
76+ if (UNLIKELY (addr < 0x7c00 ))
77+ return {null_stringz, 0 , addr};
7678 // definitely in the bootloader
77- if (addr < 0x7e00 ) return {boot_stringz, 0x7c00 , addr - 0x7c00 };
79+ if (UNLIKELY (addr < 0x7e00 ))
80+ return {boot_stringz, 0x7c00 , addr - 0x7c00 };
7881 // resolve manually from symtab
7982 auto * sym = getaddr (addr);
8083 // validate symbol address
8184 // assert(sym >= symtab.base && sym < symtab.base + symtab.entries);
82- if (sym) {
85+ if (LIKELY ( sym) ) {
8386 auto base = sym->st_value ;
8487 auto offset = addr - base;
8588 // return string name for symbol
Original file line number Diff line number Diff line change @@ -50,8 +50,8 @@ INCLUDES = -I$(INC_LIBCXX) -I$(INSTALL)/api/sys -I$(INC_NEWLIB) -I$(INSTALL)/api
5050all : CAPABS = $(CAPABS_COMMON ) -O2 -DOS_TERMINATE_ON_CONTRACT_VIOLATION
5151debug : CAPABS = $(CAPABS_COMMON ) -O0
5252stripped : CAPABS = $(CAPABS_COMMON ) -Os
53- # by default, remove debugging
54- STRIPPED =-S
53+ # by default, don't use strip because it has caused us some problems
54+ STRIPPED =
5555
5656CPPOPTS = $(CAPABS ) $(WARNS ) -c -m32 -std=c++14 $(INCLUDES ) -D_LIBCPP_HAS_NO_THREADS=1 -D_GNU_SOURCE
5757LDOPTS = -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)
8888# - a "service", to be linked with OS-objects (OS included)
8989.PHONY : all stripped debug debug-info debug-all memdisk service
9090
91+ all : LDOPTS += --strip-debug
9192all : service
9293
9394stripped : LDOPTS += -s
Original file line number Diff line number Diff line change 1515// See the License for the specific language governing permissions and
1616// limitations under the License.
1717
18+ #include < iterator>
1819#include < statman>
1920
2021// Stat
@@ -76,15 +77,10 @@ Statman::Statman(uintptr_t start, Size_type num_bytes)
7677}
7778
7879Statman::Span_iterator Statman::last_used () {
79- int i = 0 ;
80-
81- for (auto it = stats_.begin (); it not_eq stats_.end (); ++it) {
82- if (i == next_available_)
83- return it;
84- i++;
85- }
86-
87- return stats_.end ();
80+ Expects (next_available_ <= stats_.size ());
81+ auto it = stats_.begin ();
82+ std::advance (it, next_available_);
83+ return it;
8884}
8985
9086Stat& Statman::create (const Stat::stat_type type, const std::string& name) {
You can’t perform that action at this time.
0 commit comments