Okay, with some mucking around, there is now a /bin/id and it runs!

It statically links against everything in LibC that it needs.
This will work just fine for a long time to come!
This commit is contained in:
Andreas Kling 2018-10-22 14:41:54 +02:00
parent 38a621c721
commit befeabd8fe
Notes: sideshowbarker 2024-07-19 18:45:08 +09:00
4 changed files with 11 additions and 12 deletions

Binary file not shown.

View File

@ -150,14 +150,14 @@ static void init_stage2()
#ifdef TEST_ELF_LOADER
{
auto testExecutable = vfs->open("/_test.o");
auto testExecutable = vfs->open("/bin/id");
ASSERT(testExecutable);
auto testExecutableData = testExecutable->readEntireFile();
ASSERT(testExecutableData);
ExecSpace space;
space.loadELF(move(testExecutableData));
auto* elf_entry = space.symbolPtr("elf_entry");
auto* elf_entry = space.symbolPtr("_start");
ASSERT(elf_entry);
typedef int (*MainFunctionPtr)(void);

View File

@ -3,14 +3,13 @@
#include "types.h"
#include <Kernel/Syscall.h>
template<typename PutChFunc>
int printHex(PutChFunc putch, char*& bufptr, dword number, byte fields)
{
static const char h[] = {
'0','1','2','3','4','5','6','7',
'8','9','a','b','c','d','e','f'
};
#define ALWAYS_INLINE __attribute__ ((always_inline))
static const char h[] = { '0','1','2','3','4','5','6','7', '8','9','a','b','c','d','e','f' };
template<typename PutChFunc>
ALWAYS_INLINE int printHex(PutChFunc putch, char*& bufptr, dword number, byte fields)
{
int ret = 0;
byte shr_count = fields * 4;
while (shr_count) {
@ -22,7 +21,7 @@ int printHex(PutChFunc putch, char*& bufptr, dword number, byte fields)
}
template<typename PutChFunc>
int printNumber(PutChFunc putch, char*& bufptr, dword number)
ALWAYS_INLINE int printNumber(PutChFunc putch, char*& bufptr, dword number)
{
dword divisor = 1000000000;
char ch;
@ -49,7 +48,7 @@ int printNumber(PutChFunc putch, char*& bufptr, dword number)
}
template<typename PutChFunc>
static int printSignedNumber(PutChFunc putch, char*& bufptr, int number)
ALWAYS_INLINE int printSignedNumber(PutChFunc putch, char*& bufptr, int number)
{
if (number < 0) {
putch(bufptr, '-');

View File

@ -18,7 +18,7 @@ CXXFLAGS = $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(USERLAND_FLAGS) $(FLAVOR_FLA
CXX = g++
LD = ld
AR = ar
LDFLAGS = --strip-debug -melf_i386 --gc-sections --build-id=none -z norelro -z now
LDFLAGS = -r -static --strip-debug -melf_i386 --build-id=none -z norelro -z now -e _start
all: $(OBJS) $(APPS)