diff --git a/src/bin/ld/addlibrary.c b/src/bin/ld/addlibrary.c index bc5acdd..b41efa3 100644 --- a/src/bin/ld/addlibrary.c +++ b/src/bin/ld/addlibrary.c @@ -72,33 +72,29 @@ } break; case 9: + tmpLib->linkerElfRel = (elfPltInfo *)malloc(tmpLib->linkerSectionHeader[i].shSize); + fseek(linkerFd,tmpLib->linkerSectionHeader[i].shOffset,0x0); + fread(tmpLib->linkerElfRel,tmpLib->linkerSectionHeader[i].shSize,1,linkerFd); - tmpLib->linkerElfRel = (elfPltInfo *)malloc(tmpLib->linkerSectionHeader[i].shSize); - fseek(linkerFd,tmpLib->linkerSectionHeader[i].shOffset,0x0); - fread(tmpLib->linkerElfRel,tmpLib->linkerSectionHeader[i].shSize,1,linkerFd); - - for (x=0x0;xlinkerSectionHeader[i].shSize/sizeof(elfPltInfo);x++) { - rel = ELF32_R_SYM(tmpLib->linkerElfRel[x].pltInfo); - reMap = (uInt32 *)((uInt32)tmpLib->output + tmpLib->linkerElfRel[x].pltOffset); - switch (ELF32_R_TYPE(tmpLib->linkerElfRel[x].pltInfo)) { - case R_386_32: - *reMap += ((uInt32)tmpLib->output + tmpLib->linkerRelSymTab[rel].dynValue); - break; - case R_386_PC32: - *reMap += ((uInt32)tmpLib->output + tmpLib->linkerRelSymTab[rel].dynValue) - (uInt32)reMap; - break; - case R_386_RELATIVE: - *reMap += (uInt32)tmpLib->output; - break; - default: - //printf("[0x%X][0x%X](%i)[%s]\n",elfRel[i].pltOffset,elfRel[i].pltInfo,x,elfGetRelType(ELF32_R_TYPE(elfRel[i].pltInfo))); - //printf("relTab [%s][0x%X][0x%X]\n",dynStr + relSymTab[x].dynName,relSymTab[x].dynValue,relSymTab[x].dynName); - printf("Unhandled sym\n"); - break; - } - } - free(tmpLib->linkerElfRel); - + for (x=0x0;xlinkerSectionHeader[i].shSize/sizeof(elfPltInfo);x++) { + rel = ELF32_R_SYM(tmpLib->linkerElfRel[x].pltInfo); + reMap = (uInt32 *)((uInt32)tmpLib->output + tmpLib->linkerElfRel[x].pltOffset); + switch (ELF32_R_TYPE(tmpLib->linkerElfRel[x].pltInfo)) { + case R_386_32: + *reMap += ((uInt32)tmpLib->output + tmpLib->linkerRelSymTab[rel].dynValue); + break; + case R_386_PC32: + *reMap += ((uInt32)tmpLib->output + tmpLib->linkerRelSymTab[rel].dynValue) - (uInt32)reMap; + break; + case R_386_RELATIVE: + *reMap += (uInt32)tmpLib->output; + break; + default: + printf("Unhandled sym\n"); + break; + } + } + free(tmpLib->linkerElfRel); break; case 11: if (tmpLib->linkerRelSymTab == 0x0) { diff --git a/src/sys/kernel/ld.c b/src/sys/kernel/ld.c index 5fcdec8..2f4852a 100644 --- a/src/sys/kernel/ld.c +++ b/src/sys/kernel/ld.c @@ -107,36 +107,30 @@ } break; case 9: - kprintf("rel: [%i]\n",i); + elfRel = (elfPltInfo *)kmalloc(sectionHeader[i].shSize); + fseek(ldFd,sectionHeader[i].shOffset,0x0); + fread(elfRel,sectionHeader[i].shSize,1,ldFd); - elfRel = (elfPltInfo *)kmalloc(sectionHeader[i].shSize); - fseek(ldFd,sectionHeader[i].shOffset,0x0); - fread(elfRel,sectionHeader[i].shSize,1,ldFd); - - kprintf("rel: [0x%X:0x%X]\n",sectionHeader[i].shSize,sizeof(elfPltInfo)); - - for (x=0x0;x