From 14db35933b2b8dd74147e01be7710d99f12f0731 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Sat, 7 Sep 2013 23:00:42 +0800 Subject: [PATCH] Usermode/ld-acess - Added exported function to dump loaded libraries to kernel log --- Usermode/Libraries/ld-acess.so_src/Makefile | 2 +- Usermode/Libraries/ld-acess.so_src/_stublib.c | 1 + Usermode/Libraries/ld-acess.so_src/export.c | 2 ++ Usermode/Libraries/ld-acess.so_src/loadlib.c | 12 ++++++++++++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Usermode/Libraries/ld-acess.so_src/Makefile b/Usermode/Libraries/ld-acess.so_src/Makefile index 831d0940..4dc881c0 100644 --- a/Usermode/Libraries/ld-acess.so_src/Makefile +++ b/Usermode/Libraries/ld-acess.so_src/Makefile @@ -11,7 +11,7 @@ EXTRABIN := libld-acess.so EXTRACLEAN = $(_OBJPREFIX)_stublib.o INCFILES := sys/sys.h -CFLAGS = -g -Wall -fno-builtin -fno-stack-protector -fPIC +CFLAGS = -g -Wall -fno-builtin -fno-stack-protector -fPIC -std=c99 # -fno-leading-underscore CFLAGS += $(CPPFLAGS) LDFLAGS = -g -T arch/$(ARCHDIR).ld -Map map.txt --export-dynamic diff --git a/Usermode/Libraries/ld-acess.so_src/_stublib.c b/Usermode/Libraries/ld-acess.so_src/_stublib.c index 69a392dd..e01722b6 100644 --- a/Usermode/Libraries/ld-acess.so_src/_stublib.c +++ b/Usermode/Libraries/ld-acess.so_src/_stublib.c @@ -27,4 +27,5 @@ uint32_t __umodsi3(uint32_t Num, uint32_t Den){return 0;} void *_crt0_exit_handler; void abort(void){} +void ldacess_DumpLoadedLibraries(void){} diff --git a/Usermode/Libraries/ld-acess.so_src/export.c b/Usermode/Libraries/ld-acess.so_src/export.c index 586078a0..10c5c5cd 100644 --- a/Usermode/Libraries/ld-acess.so_src/export.c +++ b/Usermode/Libraries/ld-acess.so_src/export.c @@ -10,6 +10,7 @@ extern int32_t __divsi3(int32_t Num, int32_t Den); extern int32_t __modsi3(int32_t Num, int32_t Den); extern uint32_t __udivsi3(uint32_t Num, uint32_t Den); extern uint32_t __umodsi3(uint32_t Num, uint32_t Den); +extern void ldacess_DumpLoadedLibraries(void); #define _STR(x) #x #define STR(x) _STR(x) @@ -30,6 +31,7 @@ const struct { } caLocalExports[] = { EXP(gLoadedLibraries), EXP(_errno), + EXP(ldacess_DumpLoadedLibraries), #define __ASSEMBLER__ #include "arch/syscalls.s.h" diff --git a/Usermode/Libraries/ld-acess.so_src/loadlib.c b/Usermode/Libraries/ld-acess.so_src/loadlib.c index 53073019..88aafc31 100644 --- a/Usermode/Libraries/ld-acess.so_src/loadlib.c +++ b/Usermode/Libraries/ld-acess.so_src/loadlib.c @@ -33,6 +33,18 @@ char *gsNextAvailString = gsLoadedStrings; //tLoadLib *gpLoadedLibraries = NULL; // === CODE === +void ldacess_DumpLoadedLibraries(void) +{ + for( int i = 0; i < MAX_LOADED_LIBRARIES; i ++ ) + { + if(gLoadedLibraries[i].Base == 0) break; // Last entry has Base set to NULL + _SysDebug("%p: %s", + gLoadedLibraries[i].Base, + gLoadedLibraries[i].Name + ); + } +} + const char *FindLibrary(char *DestBuf, const char *SoName, const char *ExtraSearchDir) { // -- #1: Executable Specified -- 2.20.1