diff --git a/src/bin/ld/Makefile b/src/bin/ld/Makefile index 77d3e6a..ed49852 100644 --- a/src/bin/ld/Makefile +++ b/src/bin/ld/Makefile @@ -22,7 +22,7 @@ # Link The Binary $(OUTPUT) : $(OBJS) - $(CC) -nostdlib -shared -Wl,-soname,$(OUTPUT) -o $(OUTPUT) $(OBJS) $(LIBRARIES) $(SUBS) + $(CC) -nostdlib -shared -Wl,-soname,$(OUTPUT) -e _ld -o $(OUTPUT) $(OBJS) $(LIBRARIES) $(SUBS) strip $(OUTPUT) # Compile the source files diff --git a/src/bin/ld/addlibrary.c b/src/bin/ld/addlibrary.c index 1d34271..3486ac4 100644 --- a/src/bin/ld/addlibrary.c +++ b/src/bin/ld/addlibrary.c @@ -116,6 +116,10 @@ tmpLib->prev = 0x0; tmpLib->next = libs; libs = tmpLib; + + if (linkerFd) { + fclose(linkerFd); + } return(tmpLib); } diff --git a/src/bin/ld/ld.h b/src/bin/ld/ld.h index 3ffaa34..cce5126 100644 --- a/src/bin/ld/ld.h +++ b/src/bin/ld/ld.h @@ -19,13 +19,15 @@ extern ldLibrary *libs; -void _ld(); uInt32 ldFindFunc(char *,char *); ldLibrary *ldFindLibrary(char *); ldLibrary *ldAddLibrary(char *); /*** $Log$ + Revision 1.2 2004/06/17 01:52:54 reddawg + Maybe? + Revision 1.1 2004/06/16 23:11:34 reddawg ld.so: now adds librarys it is a little more efficient does the lazy binding diff --git a/src/bin/ld/main.c b/src/bin/ld/main.c index 2320e1f..5ccb425 100644 --- a/src/bin/ld/main.c +++ b/src/bin/ld/main.c @@ -34,13 +34,12 @@ void _ld(); asm( - ".globl _ld \n" - "_ld: \n" - " call ld \n" - " pop %ecx \n" - " pop %ecx \n" - " push %eax \n" - " ret \n" + ".globl _ld \n" + "_ld: \n" + " call ld \n" + " add $8,%esp\n" + " push %eax \n" + " ret \n" ); ldLibrary *libs = 0x0; @@ -59,34 +58,26 @@ uInt32 *reMap = 0x0; FILE *binaryFd = 0x0; - binaryFd = malloc(sizeof(FILE)); - binaryFd->fd = (uInt32)got2; - - printf("A"); if (binaryHeader == 0x0) { + binaryFd = malloc(sizeof(FILE)); + binaryFd->fd = (uInt32)got2; fseek(binaryFd,0x0,0x0); binaryHeader = (elfHeader *)malloc(sizeof(elfHeader)); fread(binaryHeader,sizeof(elfHeader),1,binaryFd); } - printf("B"); - if (binarySectionHeader == 0x0) { binarySectionHeader = (elfSectionHeader *)malloc(sizeof(elfSectionHeader)*binaryHeader->eShnum); fseek(binaryFd,binaryHeader->eShoff,0); fread(binarySectionHeader,sizeof(elfSectionHeader),binaryHeader->eShnum,binaryFd); - printf("C"); - if (binaryShStr == 0x0) { binaryShStr = (char *)malloc(binarySectionHeader[binaryHeader->eShstrndx].shSize); fseek(binaryFd,binarySectionHeader[binaryHeader->eShstrndx].shOffset,0); fread(binaryShStr,binarySectionHeader[binaryHeader->eShstrndx].shSize,1,binaryFd); } - printf("D"); - for (i=0x0;ieShnum;i++) { switch (binarySectionHeader[i].shType) { case 3: @@ -112,30 +103,30 @@ } } - printf("E"); - if (binaryElfRel == 0x0) { fseek(binaryFd,binarySectionHeader[rel].shOffset,0x0); binaryElfRel = (elfPltInfo *)malloc(binarySectionHeader[rel].shSize); fread(binaryElfRel,binarySectionHeader[rel].shSize,1,binaryFd); } - printf("F"); - 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)); - free(binaryFd); - - printf("G"); + + if (binaryFd) { + fclose(binaryFd); + } return(*reMap); } /*** $Log$ + Revision 1.7 2004/06/17 01:09:24 reddawg + TCA: cvs update make and give me output + Revision 1.6 2004/06/16 23:11:34 reddawg ld.so: now adds librarys it is a little more efficient does the lazy binding diff --git a/src/bin/ls/main.c b/src/bin/ls/main.c index 826a790..d743265 100644 --- a/src/bin/ls/main.c +++ b/src/bin/ls/main.c @@ -73,9 +73,6 @@ } dirEntry = (struct directoryEntry *)malloc(fd->size); fread(dirEntry,fd->size,1,fd); - if (!fclose(fd)) { - printf("Error Closing Directory\n"); - } pwd[0] = '/'; for (i=0;i<(fd->size/sizeof(struct directoryEntry));i++) { if ((dirEntry[i].fileName[0] > 0) && (dirEntry[i].fileName[0] != ':')) { @@ -117,10 +114,8 @@ next: } } - /* - for (i=0;itss.io_map = 0x8000; _current->state = READY; - /* Set up the defaault stack to be used by this new process */ - /* - - Some bug here let me figure it out 05/19/2004 + /* Set up the defaault stack to be used by this new process */ - asm volatile( + /* + asm volatile( "pusha \n" "movl %%esp,%%edx \n" "movl %2,%%ecx \n" @@ -308,11 +306,12 @@ fclose(tmpFd); /* Switch Back To The Kernels VM Space */ - asm( + asm volatile( "movl %0,%%eax \n" "movl %%eax,%%cr3 \n" : : "d" ((uInt32 *)(kernelPageDirectory)) ); + /* Finally Return */ return; } @@ -420,6 +419,7 @@ tmp = (uInt32 *)elfDynamicS[i].dynPtr; tmp[2] = (uInt32)ldAddr; tmp[1] = (uInt32)tmpFd; + break; } } @@ -430,7 +430,6 @@ kfree(binaryHeader); kfree(programHeader); - kprintf("dong: [0x%X]\n",eStart); /* Jump To Start Of New Binary */ asm volatile( "pushl %1 \n" @@ -443,6 +442,9 @@ /*** $Log$ + Revision 1.34 2004/06/17 02:19:29 reddawg + Cleaning out dead code + Revision 1.32 2004/06/17 02:00:53 reddawg Test diff --git a/src/sys/kernel/ld.c b/src/sys/kernel/ld.c index 5c7e61f..00600f0 100644 --- a/src/sys/kernel/ld.c +++ b/src/sys/kernel/ld.c @@ -53,40 +53,28 @@ elfDynSym *relSymTab = 0x0; elfPltInfo *elfRel = 0x0; - kprintf("1"); - ldFd = fopen("ld.so","rb"); if (ldFd == 0x0) { kprintf("Can not open ld.so\n"); } - kprintf("2"); - fseek(ldFd,0x0,0x0); binaryHeader = (elfHeader *)kmalloc(sizeof(elfHeader)); fread(binaryHeader,sizeof(elfHeader),1,ldFd); - kprintf("3"); - programHeader = (elfProgramHeader *)kmalloc(sizeof(elfProgramHeader)*binaryHeader->ePhnum); fseek(ldFd,binaryHeader->ePhoff,0); fread(programHeader,sizeof(elfSectionHeader),binaryHeader->ePhnum,ldFd); - kprintf("4"); - sectionHeader = (elfSectionHeader *)kmalloc(sizeof(elfSectionHeader)*binaryHeader->eShnum); fseek(ldFd,binaryHeader->eShoff,0); fread(sectionHeader,sizeof(elfSectionHeader),binaryHeader->eShnum,ldFd); - kprintf("5"); - shStr = (char *)kmalloc(sectionHeader[binaryHeader->eShstrndx].shSize); fseek(ldFd,sectionHeader[binaryHeader->eShstrndx].shOffset,0); fread(shStr,sectionHeader[binaryHeader->eShstrndx].shSize,1,ldFd); - kprintf("6"); - for (i=0;iePhnum;i++) { switch (programHeader[i].phType) { case 1: @@ -109,8 +97,6 @@ } } - kprintf("7"); - for (i=0x0;ieShnum;i++) { switch (sectionHeader[i].shType) { case 3: @@ -132,14 +118,10 @@ } } - kprintf("8"); - elfRel = (elfPltInfo *)kmalloc(sectionHeader[rel].shSize); fseek(ldFd,sectionHeader[rel].shOffset,0x0); fread(elfRel,sectionHeader[rel].shSize,1,ldFd); - kprintf("9"); - for (i=0x0;ieEntry + LD_START; - kprintf("11"); - fclose(ldFd); kfree(dynStr); kfree(shStr); @@ -175,13 +153,14 @@ kfree(programHeader); kfree(binaryHeader); - kprintf("LD: [0x%X]\n",i); - return((uInt32)i); } /*** $Log$ + Revision 1.17 2004/06/17 02:19:29 reddawg + Cleaning out dead code + Revision 1.16 2004/06/17 01:52:54 reddawg Maybe? @@ -217,6 +196,7 @@ Revision 1.3 2004/05/15 02:30:28 reddawg Lots of changes + END ***/