git.ucc.asn.au
/
tpg
/
acess2.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
9eadc33
)
Usermode/ld-acess - Clean up loadlib.c, improved debug
author
John Hodge
<
[email protected]
>
Tue, 17 Feb 2015 03:29:21 +0000
(11:29 +0800)
committer
John Hodge
<
[email protected]
>
Tue, 17 Feb 2015 03:30:24 +0000
(11:30 +0800)
Usermode/Libraries/ld-acess.so_src/common.h
patch
|
blob
|
history
Usermode/Libraries/ld-acess.so_src/export.c
patch
|
blob
|
history
Usermode/Libraries/ld-acess.so_src/loadlib.c
patch
|
blob
|
history
diff --git
a/Usermode/Libraries/ld-acess.so_src/common.h
b/Usermode/Libraries/ld-acess.so_src/common.h
index
e0620c2
..
af620be
100644
(file)
--- a/
Usermode/Libraries/ld-acess.so_src/common.h
+++ b/
Usermode/Libraries/ld-acess.so_src/common.h
@@
-18,6
+18,8
@@
typedef uint8_t Uint8;
typedef uint16_t Uint16;
typedef uint32_t Uint32;
typedef uint16_t Uint16;
typedef uint32_t Uint32;
+#define ASSERT(cnd) do { if( !(cnd) ) { _SysDebug("ASSERT: "#cnd" failed"); *(volatile int*)1 = 123; } } while(0)
+
// HACK: Replace with underscored
#define SysDebug _SysDebug
// HACK: Replace with underscored
#define SysDebug _SysDebug
@@
-32,6
+34,11
@@
typedef struct {
char *Name;
} tLoadedLib;
char *Name;
} tLoadedLib;
+typedef struct {
+ void *Value;
+ const char *Name;
+} tLocalExport;
+
// === GLOBALS ===
extern tLoadedLib gLoadedLibraries[MAX_LOADED_LIBRARIES];
// === GLOBALS ===
extern tLoadedLib gLoadedLibraries[MAX_LOADED_LIBRARIES];
diff --git
a/Usermode/Libraries/ld-acess.so_src/export.c
b/Usermode/Libraries/ld-acess.so_src/export.c
index
e40dd8e
..
5a7e6e0
100644
(file)
--- a/
Usermode/Libraries/ld-acess.so_src/export.c
+++ b/
Usermode/Libraries/ld-acess.so_src/export.c
@@
-26,10
+26,7
@@
extern void _ZN4_sys5debugEPKcz(const char *,...); // C++ "_sys::debug" used by
#define SYSCALL6(name,num) EXP(name),
// === CONSTANTS ===
#define SYSCALL6(name,num) EXP(name),
// === CONSTANTS ===
-const struct {
- void *Value;
- char *Name;
-} caLocalExports[] = {
+const tLocalExport caLocalExports[] = {
EXP(gLoadedLibraries),
EXP(_errno),
EXP(ldacess_DumpLoadedLibraries),
EXP(gLoadedLibraries),
EXP(_errno),
EXP(ldacess_DumpLoadedLibraries),
@@
-44,14
+41,6
@@
const struct {
{0, "__cxa_type_match"},
{0, "__cxa_begin_cleanup"},
#endif
{0, "__cxa_type_match"},
{0, "__cxa_begin_cleanup"},
#endif
-#if 0
- EXP(__umoddi3),
- EXP(__udivdi3),
- EXP(__divsi3),
- EXP(__modsi3),
- EXP(__udivsi3),
- EXP(__umodsi3)
-#endif
};
const int ciNumLocalExports = sizeof(caLocalExports)/sizeof(caLocalExports[0]);
};
const int ciNumLocalExports = sizeof(caLocalExports)/sizeof(caLocalExports[0]);
diff --git
a/Usermode/Libraries/ld-acess.so_src/loadlib.c
b/Usermode/Libraries/ld-acess.so_src/loadlib.c
index
31dcbd8
..
2a08303
100644
(file)
--- a/
Usermode/Libraries/ld-acess.so_src/loadlib.c
+++ b/
Usermode/Libraries/ld-acess.so_src/loadlib.c
@@
-18,10
+18,7
@@
#define MAX_QUEUED_ENTRYPOINTS 8
// === IMPORTS ===
#define MAX_QUEUED_ENTRYPOINTS 8
// === IMPORTS ===
-extern const struct {
- void *Value;
- char *Name;
-} caLocalExports[];
+extern const tLocalExport caLocalExports[];
extern const int ciNumLocalExports;
extern char **gEnvP;
extern char gLinkedBase[];
extern const int ciNumLocalExports;
extern char **gEnvP;
extern char gLinkedBase[];
@@
-48,11
+45,9
@@
void ldacess_DumpLoadedLibraries(void)
{
for( int i = 0; i < MAX_LOADED_LIBRARIES; i ++ )
{
{
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 tLoadedLib* ll = &gLoadedLibraries[i];
+ if(ll->Base == 0) break; // Last entry has Base set to NULL
+ _SysDebug("%p: %s", ll->Base, ll->Name);
}
}
}
}
@@
-150,7
+145,6
@@
void *LoadLibrary(const char *SoName, const char *SearchDir, char **envp)
*/
void *IsFileLoaded(const char *file)
{
*/
void *IsFileLoaded(const char *file)
{
- int i;
DEBUGS("IsFileLoaded: (file='%s')", file);
// Applications link against either libld-acess.so or ld-acess.so
DEBUGS("IsFileLoaded: (file='%s')", file);
// Applications link against either libld-acess.so or ld-acess.so
@@
-161,7
+155,7
@@
void *IsFileLoaded(const char *file)
return &gLinkedBase;
}
return &gLinkedBase;
}
- for( i = 0; i < MAX_LOADED_LIBRARIES; i++ )
+ for( i
nt i
= 0; i < MAX_LOADED_LIBRARIES; i++ )
{
if(gLoadedLibraries[i].Base == 0) break; // Last entry has Base set to NULL
DEBUGS(" strcmp('%s', '%s')", gLoadedLibraries[i].Name, file);
{
if(gLoadedLibraries[i].Base == 0) break; // Last entry has Base set to NULL
DEBUGS(" strcmp('%s', '%s')", gLoadedLibraries[i].Name, file);
@@
-216,7
+210,6
@@
void AddLoaded(const char *File, void *base)
*/
void Unload(void *Base)
{
*/
void Unload(void *Base)
{
- int i, j;
int id;
char *str;
for( id = 0; id < MAX_LOADED_LIBRARIES; id++ )
int id;
char *str;
for( id = 0; id < MAX_LOADED_LIBRARIES; id++ )
@@
-231,8
+224,8
@@
void Unload(void *Base)
str = gLoadedLibraries[id].Name;
// Compact Loaded List
str = gLoadedLibraries[id].Name;
// Compact Loaded List
- j = id;
- for( i = j + 1; i < MAX_LOADED_LIBRARIES; i++, j++ )
+
int
j = id;
+ for( i
nt i
= j + 1; i < MAX_LOADED_LIBRARIES; i++, j++ )
{
if(gLoadedLibraries[i].Base == 0) break;
// Compact String
{
if(gLoadedLibraries[i].Base == 0) break;
// Compact String
@@
-256,14
+249,18
@@
void Unload(void *Base)
*/
int GetSymbol(const char *name, void **Value, size_t *Size, void *IgnoreBase)
{
*/
int GetSymbol(const char *name, void **Value, size_t *Size, void *IgnoreBase)
{
+ ASSERT(name);
+ ASSERT(Value);
+ ASSERT(Size);
//SysDebug("GetSymbol: (%s)");
for( int i = 0; i < ciNumLocalExports; i ++ )
{
//SysDebug("GetSymbol: (%s)");
for( int i = 0; i < ciNumLocalExports; i ++ )
{
- if( strcmp(caLocalExports[i].Name, name) == 0 ) {
- *Value = caLocalExports[i].Value;
+ const tLocalExport* le = &caLocalExports[i];
+ if( strcmp(le->Name, name) == 0 ) {
+ *Value = le->Value;
if(Size)
*Size = 0;
if(Size)
*Size = 0;
-
//SysDebug("GetSymbol: Local %p+0x%x", *
Value, 0);
+
DEBUGS("'%s' = Local %p+%#x", name, le->
Value, 0);
return 1;
}
}
return 1;
}
}
@@
-271,31
+268,34
@@
int GetSymbol(const char *name, void **Value, size_t *Size, void *IgnoreBase)
bool have_weak = false;
for(int i = 0; i < MAX_LOADED_LIBRARIES && gLoadedLibraries[i].Base != 0; i ++)
{
bool have_weak = false;
for(int i = 0; i < MAX_LOADED_LIBRARIES && gLoadedLibraries[i].Base != 0; i ++)
{
+ const tLoadedLib* ll = &gLoadedLibraries[i];
// Allow ignoring the current module
// Allow ignoring the current module
- if(
gLoadedLibraries[i].
Base == IgnoreBase ) {
+ if(
ll->
Base == IgnoreBase ) {
//SysDebug("GetSymbol: Ignore %p", gLoadedLibraries[i].Base);
continue ;
}
//SysDebug("GetSymbol: Ignore %p", gLoadedLibraries[i].Base);
continue ;
}
- //SysDebug(" GetSymbol: Trying 0x%x, '%s'",
- // gLoadedLibraries[i].Base, gLoadedLibraries[i].Name);
+ //SysDebug(" GetSymbol: Trying 0x%x, '%s'", ll->Base, ll->Name);
void *tmpval;
size_t tmpsize;
void *tmpval;
size_t tmpsize;
- int rv = GetSymbolFromBase(
gLoadedLibraries[i].
Base, name, &tmpval, &tmpsize);
+ int rv = GetSymbolFromBase(
ll->
Base, name, &tmpval, &tmpsize);
if(rv)
{
*Value = tmpval;
*Size = tmpsize;
if( rv == 1 ) {
if(rv)
{
*Value = tmpval;
*Size = tmpsize;
if( rv == 1 ) {
+ DEBUGS("'%s' = %p '%s' Strong %p+%#x", name, ll->Base, ll->Name, *Value, *Size);
return 1;
}
have_weak = true;
}
}
if(have_weak) {
return 1;
}
have_weak = true;
}
}
if(have_weak) {
+ DEBUGS("'%s' = Weak %p+%#x", name, *Value, *Size);
return 2;
}
else {
return 2;
}
else {
+ DEBUGS("'%s' = ?", name);
return 0;
}
}
return 0;
}
}
UCC
git Repository :: git.ucc.asn.au