Skip to content

Commit b9e45dc

Browse files
authored
Merge pull request #828 from fwsGonzo/dev
Avoid issue with strip, causing a single broken symbol entry
2 parents d5c9055 + 837d3d0 commit b9e45dc

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

src/kernel/elf.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
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

src/seed/Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ INCLUDES = -I$(INC_LIBCXX) -I$(INSTALL)/api/sys -I$(INC_NEWLIB) -I$(INSTALL)/api
5050
all: CAPABS = $(CAPABS_COMMON) -O2 -DOS_TERMINATE_ON_CONTRACT_VIOLATION
5151
debug: CAPABS = $(CAPABS_COMMON) -O0
5252
stripped: 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

5656
CPPOPTS = $(CAPABS) $(WARNS) -c -m32 -std=c++14 $(INCLUDES) -D_LIBCPP_HAS_NO_THREADS=1 -D_GNU_SOURCE
5757
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)
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
9192
all: service
9293

9394
stripped: LDOPTS += -s

0 commit comments

Comments
 (0)