X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Kernel%2Fbin%2Felf.c;h=2f43eee85904159fce69b7fd3eae637bf7749d74;hb=f3d0d7fcf0496a63625c92e5ab95471e202e958e;hp=731d151456cc8bd5bb7a967fd97258f1a9121446;hpb=30e30d7bc325852a8677819d11a47373b08d6271;p=tpg%2Facess2.git diff --git a/Kernel/bin/elf.c b/Kernel/bin/elf.c index 731d1514..2f43eee8 100644 --- a/Kernel/bin/elf.c +++ b/Kernel/bin/elf.c @@ -9,13 +9,12 @@ #define DEBUG_WARN 1 - // === PROTOTYPES === tBinary *Elf_Load(int fp); int Elf_Relocate(void *Base); - int Elf_GetSymbol(void *Base, char *Name, Uint *ret); + int Elf_GetSymbol(void *Base, const char *Name, Uint *ret); int Elf_Int_DoRelocate(Uint r_info, Uint32 *ptr, Uint32 addend, Elf32_Sym *symtab, Uint base); -Uint Elf_Int_HashString(char *str); +Uint Elf_Int_HashString(const char *str); // === GLOBALS === tBinaryType gELF_Info = { @@ -35,7 +34,7 @@ tBinary *Elf_Load(int fp) int iPageCount; int count; - ENTER("ifp", fp); + ENTER("xfp", fp); // Read ELF Header VFS_Read(fp, sizeof(hdr), &hdr); @@ -126,13 +125,15 @@ tBinary *Elf_Load(int fp) LOG("phtab[%i] = {VAddr:0x%x,Offset:0x%x,FileSize:0x%x}", i, phtab[i].VAddr, phtab[i].Offset, phtab[i].FileSize); - if( (phtab[i].FileSize & 0xFFF) < 0x1000 - (phtab[i].VAddr & 0xFFF) ) - lastSize = phtab[i].FileSize; - else + //if( (phtab[i].FileSize & 0xFFF) < 0x1000 - (phtab[i].VAddr & 0xFFF) ) + // lastSize = phtab[i].FileSize; + //else lastSize = (phtab[i].FileSize & 0xFFF) + (phtab[i].VAddr & 0xFFF); - lastSize &= 0xFFF; + //lastSize &= 0xFFF; + + //LOG("lastSize = 0x%x", lastSize); - LOG("lastSize = 0x%x", lastSize); + lastSize = phtab[i].FileSize; // Get Pages count = ( (phtab[i].VAddr&0xFFF) + phtab[i].FileSize + 0xFFF) >> 12; @@ -152,6 +153,7 @@ tBinary *Elf_Load(int fp) ret->Pages[j+k].Size = 4096; LOG("ret->Pages[%i].Size = 0x%x", j+k, ret->Pages[j+k].Size); ret->Pages[j+k].Flags = 0; + lastSize -= ret->Pages[j+k].Size; } count = (phtab[i].MemSize + 0xFFF) >> 12; for(;kphoff; + phtab = (void *)( (tVAddr)Base + hdr->phoff ); iSegmentCount = hdr->phentcount; for(i = 0; i < iSegmentCount; i ++ ) { @@ -526,10 +528,10 @@ int Elf_Int_DoRelocate(Uint r_info, Uint32 *ptr, Uint32 addend, Elf32_Sym *symta } /** - * \fn int Elf_GetSymbol(void *Base, char *name, Uint *ret) + * \fn int Elf_GetSymbol(void *Base, const char *name, Uint *ret) * \brief Get a symbol from the loaded binary */ -int Elf_GetSymbol(void *Base, char *Name, Uint *ret) +int Elf_GetSymbol(void *Base, const char *Name, Uint *ret) { Elf32_Ehdr *hdr = (void*)Base; Elf32_Sym *symtab; @@ -579,7 +581,7 @@ int Elf_GetSymbol(void *Base, char *Name, Uint *ret) * \param str String to hash * \return Hash value */ -Uint Elf_Int_HashString(char *str) +Uint Elf_Int_HashString(const char *str) { Uint h = 0, g; while(*str)