From e785cf0b01276ae9ebbb018dae2fe83d11e77701 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Fri, 6 Jun 2014 23:41:28 +0800 Subject: [PATCH] Usermode/syscalls - Add SysDebugHex syscall (Debug_HexDump) - Also disable assertion on STB_WEAK locals --- KernelLand/Kernel/GenSyscalls.pl | 1 + KernelLand/Kernel/include/syscalls.h | 1 + KernelLand/Kernel/syscalls.c | 5 +++++ Usermode/Libraries/ld-acess.so_src/arch/syscalls.s.h | 2 ++ Usermode/Libraries/ld-acess.so_src/elf.c | 6 +++--- Usermode/Libraries/ld-acess.so_src/include_exp/acess/sys.h | 1 + 6 files changed, 13 insertions(+), 3 deletions(-) diff --git a/KernelLand/Kernel/GenSyscalls.pl b/KernelLand/Kernel/GenSyscalls.pl index fdf33e91..442921ff 100755 --- a/KernelLand/Kernel/GenSyscalls.pl +++ b/KernelLand/Kernel/GenSyscalls.pl @@ -47,6 +47,7 @@ foreach my $call (@calls) print HEADER " #define NUM_SYSCALLS ",$i," #define SYS_DEBUG 0x100 +#define SYS_DEBUGHEX 0x101 #if !defined(__ASSEMBLER__) && !defined(NO_SYSCALL_STRS) static const char *cSYSCALL_NAMES[] = { diff --git a/KernelLand/Kernel/include/syscalls.h b/KernelLand/Kernel/include/syscalls.h index 9916458f..b040fc92 100644 --- a/KernelLand/Kernel/include/syscalls.h +++ b/KernelLand/Kernel/include/syscalls.h @@ -72,6 +72,7 @@ #define NUM_SYSCALLS 88 #define SYS_DEBUG 0x100 +#define SYS_DEBUGHEX 0x101 #if !defined(__ASSEMBLER__) && !defined(NO_SYSCALL_STRS) static const char *cSYSCALL_NAMES[] = { diff --git a/KernelLand/Kernel/syscalls.c b/KernelLand/Kernel/syscalls.c index d2f91858..6b970d6a 100644 --- a/KernelLand/Kernel/syscalls.c +++ b/KernelLand/Kernel/syscalls.c @@ -388,6 +388,11 @@ void SyscallHandler(tSyscallRegs *Regs) Regs->Arg2, Regs->Arg3, Regs->Arg4, Regs->Arg5, Regs->Arg6); LogF("\r\n"); break; + case SYS_DEBUGHEX: + CHECK_STR_NONULL( (char*)Regs->Arg1 ); + CHECK_NUM_NONULL( (void*)Regs->Arg2, Regs->Arg3 ); + Debug_HexDump( (const char*)Regs->Arg1, (void*)Regs->Arg2, Regs->Arg3 ); + break; //#endif // -- Default (Return Error) diff --git a/Usermode/Libraries/ld-acess.so_src/arch/syscalls.s.h b/Usermode/Libraries/ld-acess.so_src/arch/syscalls.s.h index 14ee2da3..aa09b3ba 100644 --- a/Usermode/Libraries/ld-acess.so_src/arch/syscalls.s.h +++ b/Usermode/Libraries/ld-acess.so_src/arch/syscalls.s.h @@ -39,6 +39,8 @@ SYSCALL1(_SysLoadModule, SYS_LOADMOD) SYSCALL6(_ZN4_sys5debugEPKcz, 0x100) SYSCALL6(_SysDebug, 0x100) +SYSCALL2(_SysDebugHex, 0x101) + SYSCALL1(_SysGetPhys, SYS_GETPHYS) // uint64_t _SysGetPhys(uint addr) SYSCALL1(_SysAllocate, SYS_ALLOCATE) // uint64_t _SysAllocate(uint addr) SYSCALL3(_SysSetMemFlags, SYS_SETFLAGS) // uint32_t SysSetMemFlags(uint addr, uint flags, uint mask) diff --git a/Usermode/Libraries/ld-acess.so_src/elf.c b/Usermode/Libraries/ld-acess.so_src/elf.c index 236983c3..bcf66ccd 100644 --- a/Usermode/Libraries/ld-acess.so_src/elf.c +++ b/Usermode/Libraries/ld-acess.so_src/elf.c @@ -346,8 +346,8 @@ void *Elf32Relocate(void *Base, char **envp, const char *Filename) if( ELF32_ST_BIND(sym->st_info) == STB_WEAK ) { WARNING("TODO: Weak bound local symbols '%s'", name); - assert(ELF32_ST_BIND(sym->st_info) != STB_WEAK); - return NULL; + //assert(ELF32_ST_BIND(sym->st_info) != STB_WEAK); + //return NULL; } TRACE("Sym %i'%s' %p += 0x%x", i, name, sym->st_value, iBaseDiff); sym->st_value += iBaseDiff; @@ -445,7 +445,7 @@ void *Elf32Relocate(void *Base, char **envp, const char *Filename) { // Handled previously // TODO: What about weak locally-defined symbols? - assert( ELF32_ST_BIND(sym->st_info) != STB_WEAK ); + //assert( ELF32_ST_BIND(sym->st_info) != STB_WEAK ); } } if( fail ) { diff --git a/Usermode/Libraries/ld-acess.so_src/include_exp/acess/sys.h b/Usermode/Libraries/ld-acess.so_src/include_exp/acess/sys.h index d32f8c33..21b575fb 100644 --- a/Usermode/Libraries/ld-acess.so_src/include_exp/acess/sys.h +++ b/Usermode/Libraries/ld-acess.so_src/include_exp/acess/sys.h @@ -51,6 +51,7 @@ extern int _errno; // === FUNCTIONS === extern void _SysDebug(const char *format, ...); +extern void _SysDebugHex(const char *Label, const void *Data, size_t Size); // --- Proc --- extern void _exit(int status) __attribute__((noreturn)); extern int _SysKill(int pid, int sig); -- 2.20.1