#include <binary.h>\r
\r
#define _COMMON_H\r
-#define SysDebug(...) LOG(v)\r
+#define SysDebug(v...) LOG(v)\r
#define DISABLE_ELF64\r
void *GetSymbol(const char *Name, size_t *Size);\r
void *GetSymbol(const char *Name, size_t *Size) { Uint val; Binary_GetSymbol(Name, &val); if(Size)*Size=0; return (void*)val; };\r
* elf.c
* - ELF32/ELF64 relocation
*/
-#define DEBUG 0
+#ifndef DEBUG // This code is #include'd from the kernel, so DEBUG may already be defined
+# define DEBUG 0
+#endif
#include "common.h"
#include <stdint.h>
return 0;
}
+ // ... ok... maybe they haven't been relocated
+ if( (uintptr_t)symtab < (uintptr_t)Base )
+ {
+ symtab = (void*)( (uintptr_t)symtab + iBaseDiff );
+ pBuckets = (void*)( (uintptr_t)pBuckets + iBaseDiff );
+ dynstrtab = (void*)( (uintptr_t)dynstrtab + iBaseDiff );
+ SysDebug("Executable not yet relocated");
+ }
+
nbuckets = pBuckets[0];
// iSymCount = pBuckets[1];
pBuckets = &pBuckets[2];
pChains = &pBuckets[ nbuckets ];
-
+
// Get hash
iNameHash = ElfHashString(Name);
iNameHash %= nbuckets;