diff --git a/src/bin/ld/addlibrary.c b/src/bin/ld/addlibrary.c index 2e6059e..0713b93 100644 --- a/src/bin/ld/addlibrary.c +++ b/src/bin/ld/addlibrary.c @@ -119,8 +119,12 @@ case R_386_RELATIVE: *reMap += (uInt32)tmpLib->output; break; + case R_386_GLOB_DAT: + case R_386_JMP_SLOT: + *reMap += (uInt32)tmpLib->output; + break; default: - printf("Unhandled sym\n"); + printf("Unhandled sym: [0x%X]\n", ELF32_R_TYPE(tmpLib->linkerElfRel[x].pltInfo)); break; } } diff --git a/src/bin/ld/elf.h b/src/bin/ld/elf.h index 919bf80..1499bf1 100644 --- a/src/bin/ld/elf.h +++ b/src/bin/ld/elf.h @@ -146,6 +146,7 @@ uInt32 dynPtr; } elfDynamic; + char *elfGetShType(int); char *elfGetPhType(int); char *elfGetRelType(int); @@ -154,5 +155,32 @@ #define ELF32_R_TYPE(i) ((unsigned char)(i)) #define ELF32_R_INFO(s, t) ((s)<<8+(unsigned char)(t)) +/* New Stuff */ +#define SHT_NULL 0 +#define SHT_PROGBITS 1 +#define SHT_SYMTAB 2 +#define SHT_STRTAB 3 +#define SHT_RELA 4 +#define SHT_HASH 5 +#define SHT_DYNAMIC 6 +#define SHT_NOTE 7 +#define SHT_NOBITS 8 +#define SHT_REL 9 +#define SHT_SHLIB 10 +#define SHT_DYNSYM 11 +#define SHT_LOPROC 0x70000000 +#define SHT_HIPROC 0x7fffffff +#define SHT_LOUSER 0x80000000 +#define SHT_HIUSER 0xffffffff + +typedef struct { + long d_tag; + union { + uInt32 d_val; + uInt32 d_ptr; + } d_un; + } Elf32_Dyn; + + #endif diff --git a/src/bin/ld/findfunc.c b/src/bin/ld/findfunc.c index 74794ee..dd85313 100644 --- a/src/bin/ld/findfunc.c +++ b/src/bin/ld/findfunc.c @@ -4,21 +4,29 @@ uInt32 ldFindFunc(const char *func,const char *lib) { int i = 0x0; + int x = 0x0; uInt32 *funcPtr = 0x0; ldLibrary *libPtr = 0x0; - - libPtr = ldFindLibrary(lib); - if (libPtr == 0x0) { - libPtr = ldAddLibrary(lib); - } - for (i=0x0;ilinkerSectionHeader[libPtr->sym].shSize/sizeof(elfDynSym);i++) { - if (!strcmp(func,(libPtr->linkerDynStr + libPtr->linkerRelSymTab[i].dynName))) { - funcPtr = (uInt32 *)((uInt32)(libPtr->linkerRelSymTab[i].dynValue) + (uInt32)libPtr->output); - break; + for (x = 0; x < lib_c;x++) { + libPtr = ldFindLibrary(lib + lib_s[x]); + if (libPtr == 0x0) { + libPtr = ldAddLibrary(lib + lib_s[x]); + } + + for (i=0x0;ilinkerSectionHeader[libPtr->sym].shSize/sizeof(elfDynSym);i++) { + if (!strcmp(func,(libPtr->linkerDynStr + libPtr->linkerRelSymTab[i].dynName))) { + funcPtr = (uInt32 *)((uInt32)(libPtr->linkerRelSymTab[i].dynValue) + (uInt32)libPtr->output); + if (funcPtr == 0x0) { + printf("[%s]\n",func); + } + return((uInt32)funcPtr); + break; + } } } - return((uInt32)funcPtr); + printf("ERROR COULDN'T FIND FUNCTION\n"); + return(0x0); } diff --git a/src/bin/ld/ld.h b/src/bin/ld/ld.h index bffa854..deedd86 100644 --- a/src/bin/ld/ld.h +++ b/src/bin/ld/ld.h @@ -18,6 +18,8 @@ } ldLibrary; extern ldLibrary *libs; +extern int lib_c; +extern int lib_s[10]; uInt32 ldFindFunc(const char *,const char *); ldLibrary *ldFindLibrary(const char *); @@ -25,6 +27,9 @@ /*** $Log$ + Revision 1.1.1.1 2006/06/01 12:46:09 reddawg + ubix2 + Revision 1.2 2005/10/12 00:13:28 reddawg Removed diff --git a/src/bin/ld/main.c b/src/bin/ld/main.c index 79de15c..d1d3a70 100644 --- a/src/bin/ld/main.c +++ b/src/bin/ld/main.c @@ -33,6 +33,8 @@ #include "ld.h" ldLibrary *libs = 0x0; +int lib_c = 0x0; +int lib_s[10]; static elfHeader *binaryHeader = 0x0; static elfSectionHeader *binarySectionHeader = 0x0; @@ -40,6 +42,7 @@ static char *binaryDynStr = 0x0; static elfDynSym *binaryRelSymTab = 0x0; static elfPltInfo *binaryElfRel = 0x0; +static Elf32_Dyn *binaryElf32_Dyn = 0x0; uInt32 ld(uInt32 got2,uInt32 entry) { int i = 0x0; @@ -78,6 +81,17 @@ } } break; + case SHT_DYNAMIC: + binaryElf32_Dyn = (Elf32_Dyn *)malloc(binarySectionHeader[i].shSize); + fseek(binaryFd,binarySectionHeader[i].shOffset,0); + fread(binaryElf32_Dyn,binarySectionHeader[i].shSize,1,binaryFd); + for (x = 0;x < binarySectionHeader[i].shSize / sizeof(Elf32_Dyn);x++) { + if (binaryElf32_Dyn[x].d_tag == 1) { + lib_s[lib_c] = binaryElf32_Dyn[x].d_un.d_ptr; + lib_c++; + } + } + break; case 9: rel = i; break; @@ -101,7 +115,8 @@ i = (entry/sizeof(elfPltInfo)); x = ELF32_R_SYM(binaryElfRel[i].pltInfo); reMap = (uInt32 *)binaryElfRel[i].pltOffset; - *reMap = ldFindFunc(binaryDynStr + binaryRelSymTab[x].dynName,(char *)(binaryDynStr + 1)); + *reMap = ldFindFunc(binaryDynStr + binaryRelSymTab[x].dynName,binaryDynStr); + //*reMap = ldFindFunc(binaryDynStr + binaryRelSymTab[x].dynName,(char *)(binaryDynStr + 1)); if (binaryFd) { fclose(binaryFd); @@ -112,6 +127,9 @@ /*** $Log$ + Revision 1.1.1.1 2006/06/01 12:46:09 reddawg + ubix2 + Revision 1.2 2005/10/12 00:13:28 reddawg Removed