mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 00:08:11 +00:00
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:
parent
38a621c721
commit
befeabd8fe
4 changed files with 11 additions and 12 deletions
Binary file not shown.
|
@ -150,14 +150,14 @@ static void init_stage2()
|
||||||
|
|
||||||
#ifdef TEST_ELF_LOADER
|
#ifdef TEST_ELF_LOADER
|
||||||
{
|
{
|
||||||
auto testExecutable = vfs->open("/_test.o");
|
auto testExecutable = vfs->open("/bin/id");
|
||||||
ASSERT(testExecutable);
|
ASSERT(testExecutable);
|
||||||
auto testExecutableData = testExecutable->readEntireFile();
|
auto testExecutableData = testExecutable->readEntireFile();
|
||||||
ASSERT(testExecutableData);
|
ASSERT(testExecutableData);
|
||||||
|
|
||||||
ExecSpace space;
|
ExecSpace space;
|
||||||
space.loadELF(move(testExecutableData));
|
space.loadELF(move(testExecutableData));
|
||||||
auto* elf_entry = space.symbolPtr("elf_entry");
|
auto* elf_entry = space.symbolPtr("_start");
|
||||||
ASSERT(elf_entry);
|
ASSERT(elf_entry);
|
||||||
|
|
||||||
typedef int (*MainFunctionPtr)(void);
|
typedef int (*MainFunctionPtr)(void);
|
||||||
|
|
|
@ -3,14 +3,13 @@
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include <Kernel/Syscall.h>
|
#include <Kernel/Syscall.h>
|
||||||
|
|
||||||
template<typename PutChFunc>
|
#define ALWAYS_INLINE __attribute__ ((always_inline))
|
||||||
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'
|
|
||||||
};
|
|
||||||
|
|
||||||
|
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;
|
int ret = 0;
|
||||||
byte shr_count = fields * 4;
|
byte shr_count = fields * 4;
|
||||||
while (shr_count) {
|
while (shr_count) {
|
||||||
|
@ -22,7 +21,7 @@ int printHex(PutChFunc putch, char*& bufptr, dword number, byte fields)
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename PutChFunc>
|
template<typename PutChFunc>
|
||||||
int printNumber(PutChFunc putch, char*& bufptr, dword number)
|
ALWAYS_INLINE int printNumber(PutChFunc putch, char*& bufptr, dword number)
|
||||||
{
|
{
|
||||||
dword divisor = 1000000000;
|
dword divisor = 1000000000;
|
||||||
char ch;
|
char ch;
|
||||||
|
@ -49,7 +48,7 @@ int printNumber(PutChFunc putch, char*& bufptr, dword number)
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename PutChFunc>
|
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) {
|
if (number < 0) {
|
||||||
putch(bufptr, '-');
|
putch(bufptr, '-');
|
||||||
|
|
|
@ -18,7 +18,7 @@ CXXFLAGS = $(WARNING_FLAGS) $(OPTIMIZATION_FLAGS) $(USERLAND_FLAGS) $(FLAVOR_FLA
|
||||||
CXX = g++
|
CXX = g++
|
||||||
LD = ld
|
LD = ld
|
||||||
AR = ar
|
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)
|
all: $(OBJS) $(APPS)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue