diff --git a/src/bin/ld/main.c b/src/bin/ld/main.c index 4b88fb4..8c5a073 100644 --- a/src/bin/ld/main.c +++ b/src/bin/ld/main.c @@ -2,43 +2,26 @@ Copyright (c) 2002 The UbixOS Project All rights reserved. -Redistribution and use in source and binary forms, with or without modification, are -permitted provided that the following conditions are met: + Redistribution and use in source and binary forms, with or without modification, are + permitted provided that the following conditions are met: -Redistributions of source code must retain the above copyright notice, this list of -conditions, the following disclaimer and the list of authors. Redistributions in binary -form must reproduce the above copyright notice, this list of conditions, the following -disclaimer and the list of authors in the documentation and/or other materials provided -with the distribution. Neither the name of the UbixOS Project nor the names of its -contributors may be used to endorse or promote products derived from this software -without specific prior written permission. + Redistributions of source code must retain the above copyright notice, this list of + conditions, the following disclaimer and the list of authors. Redistributions in binary + form must reproduce the above copyright notice, this list of conditions, the following + disclaimer and the list of authors in the documentation and/or other materials provided + with the distribution. Neither the name of the UbixOS Project nor the names of its + contributors may be used to endorse or promote products derived from this software + without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT -OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR -TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - $Log$ - Revision 1.3 2004/06/16 13:52:51 reddawg - Start of userland LD - - Revision 1.2 2004/06/01 01:30:43 reddawg - No more warnings and organized make files - - Revision 1.1 2004/04/26 21:16:03 reddawg - Initial addition of the ubix LD - - Revision 1.2 2004/04/26 13:20:42 reddawg - Turn off muffin - - Revision 1.1 2004/04/26 13:13:25 reddawg - Initial Introduction of the UbixOS Format Utility into the source tree - + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. $Id$ @@ -87,7 +70,7 @@ FILE *binaryFd = 0x0; binaryFd = malloc(sizeof(FILE)); - binaryFd->fd = got2; + binaryFd->fd = (uInt32)got2; if (binaryHeader == 0x0) { fseek(binaryFd,0x0,0x0); @@ -192,36 +175,36 @@ fseek(linkerFd,linkerHeader->eShoff,0); fread(linkerSectionHeader,sizeof(elfSectionHeader),linkerHeader->eShnum,linkerFd); - if (linkerShStr == 0x0) { - linkerShStr = (char *)malloc(linkerSectionHeader[linkerHeader->eShstrndx].shSize); - fseek(linkerFd,linkerSectionHeader[linkerHeader->eShstrndx].shOffset,0); - fread(linkerShStr,linkerSectionHeader[linkerHeader->eShstrndx].shSize,1,linkerFd); - } - - for (i=0x0;ieShnum;i++) { - switch (linkerSectionHeader[i].shType) { - case 3: - if (!strcmp((linkerShStr + linkerSectionHeader[i].shName),".dynstr")) { - if (linkerDynStr == 0x0) { - linkerDynStr = (char *)malloc(linkerSectionHeader[i].shSize); - fseek(linkerFd,linkerSectionHeader[i].shOffset,0); - fread(linkerDynStr,linkerSectionHeader[i].shSize,1,linkerFd); - } - } - break; - case 9: - rel = i; - break; - case 11: - if (linkerRelSymTab == 0x0) { - linkerRelSymTab = (elfDynSym *)malloc(linkerSectionHeader[i].shSize); - fseek(linkerFd,linkerSectionHeader[i].shOffset,0); - fread(linkerRelSymTab,linkerSectionHeader[i].shSize,1,linkerFd); - sym = i; - } - break; + if (linkerShStr == 0x0) { + linkerShStr = (char *)malloc(linkerSectionHeader[linkerHeader->eShstrndx].shSize); + fseek(linkerFd,linkerSectionHeader[linkerHeader->eShstrndx].shOffset,0); + fread(linkerShStr,linkerSectionHeader[linkerHeader->eShstrndx].shSize,1,linkerFd); } - } + + for (i=0x0;ieShnum;i++) { + switch (linkerSectionHeader[i].shType) { + case 3: + if (!strcmp((linkerShStr + linkerSectionHeader[i].shName),".dynstr")) { + if (linkerDynStr == 0x0) { + linkerDynStr = (char *)malloc(linkerSectionHeader[i].shSize); + fseek(linkerFd,linkerSectionHeader[i].shOffset,0); + fread(linkerDynStr,linkerSectionHeader[i].shSize,1,linkerFd); + } + } + break; + case 9: + rel = i; + break; + case 11: + if (linkerRelSymTab == 0x0) { + linkerRelSymTab = (elfDynSym *)malloc(linkerSectionHeader[i].shSize); + fseek(linkerFd,linkerSectionHeader[i].shOffset,0); + fread(linkerRelSymTab,linkerSectionHeader[i].shSize,1,linkerFd); + sym = i; + } + break; + } + } } if (linkerElfRel == 0x0) { @@ -229,27 +212,25 @@ fseek(linkerFd,linkerSectionHeader[rel].shOffset,0x0); fread(linkerElfRel,linkerSectionHeader[rel].shSize,1,linkerFd); - for (i=0x0;i