git.ucc.asn.au
/
tpg
/
acess2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Kernel - Gitignore for build numbers
[tpg/acess2.git]
/
Kernel
/
bin
/
elf.c
diff --git
a/Kernel/bin/elf.c
b/Kernel/bin/elf.c
index
c524cf8
..
d04dbda
100644
(file)
--- a/
Kernel/bin/elf.c
+++ b/
Kernel/bin/elf.c
@@
-12,9
+12,9
@@
// === PROTOTYPES ===
\r
tBinary *Elf_Load(int fp);
\r
int Elf_Relocate(void *Base);
\r
// === PROTOTYPES ===
\r
tBinary *Elf_Load(int fp);
\r
int Elf_Relocate(void *Base);
\r
- int Elf_GetSymbol(void *Base, char *Name, Uint *ret);
\r
+ int Elf_GetSymbol(void *Base, c
onst c
har *Name, Uint *ret);
\r
int Elf_Int_DoRelocate(Uint r_info, Uint32 *ptr, Uint32 addend, Elf32_Sym *symtab, Uint base);
\r
int Elf_Int_DoRelocate(Uint r_info, Uint32 *ptr, Uint32 addend, Elf32_Sym *symtab, Uint base);
\r
-Uint Elf_Int_HashString(char *str);
\r
+Uint Elf_Int_HashString(c
onst c
har *str);
\r
\r
// === GLOBALS ===
\r
tBinaryType gELF_Info = {
\r
\r
// === GLOBALS ===
\r
tBinaryType gELF_Info = {
\r
@@
-41,7
+41,7
@@
tBinary *Elf_Load(int fp)
\r
// Check the file type
\r
if(hdr.ident[0] != 0x7F || hdr.ident[1] != 'E' || hdr.ident[2] != 'L' || hdr.ident[3] != 'F') {
\r
\r
// Check the file type
\r
if(hdr.ident[0] != 0x7F || hdr.ident[1] != 'E' || hdr.ident[2] != 'L' || hdr.ident[3] != 'F') {
\r
-
Warning("Non-ELF File was passed to the ELF loader\n
");
\r
+
Log_Warning("ELF", "Non-ELF File was passed to the ELF loader
");
\r
LEAVE('n');
\r
return NULL;
\r
}
\r
LEAVE('n');
\r
return NULL;
\r
}
\r
@@
-49,7
+49,7
@@
tBinary *Elf_Load(int fp)
// Check for a program header
\r
if(hdr.phoff == 0) {
\r
#if DEBUG_WARN
\r
// Check for a program header
\r
if(hdr.phoff == 0) {
\r
#if DEBUG_WARN
\r
-
Warning("ELF File does not contain a program header\n
");
\r
+
Log_Warning("ELF", "File does not contain a program header (phoff == 0)
");
\r
#endif
\r
LEAVE('n');
\r
return NULL;
\r
#endif
\r
LEAVE('n');
\r
return NULL;
\r
@@
-222,7
+222,7
@@
tBinary *Elf_Load(int fp)
// Reallocate
\r
ret = realloc( ret, sizeof(tBinary) + 3*sizeof(Uint)*j );
\r
if(!ret) {
\r
// Reallocate
\r
ret = realloc( ret, sizeof(tBinary) + 3*sizeof(Uint)*j );
\r
if(!ret) {
\r
- Warning("BIN", "ElfLoad: Unable to reallocate return structure");
\r
+
Log_
Warning("BIN", "ElfLoad: Unable to reallocate return structure");
\r
return NULL;
\r
}
\r
ret->NumPages = j;
\r
return NULL;
\r
}
\r
ret->NumPages = j;
\r
@@
-285,7
+285,7
@@
int Elf_Relocate(void *Base)
ENTER("pBase", Base);
\r
\r
// Parse Program Header to get Dynamic Table
\r
ENTER("pBase", Base);
\r
\r
// Parse Program Header to get Dynamic Table
\r
- phtab =
Base + hdr->phoff
;
\r
+ phtab =
(void *)( (tVAddr)Base + hdr->phoff )
;
\r
iSegmentCount = hdr->phentcount;
\r
for(i = 0; i < iSegmentCount; i ++ )
\r
{
\r
iSegmentCount = hdr->phentcount;
\r
for(i = 0; i < iSegmentCount; i ++ )
\r
{
\r
@@
-347,6
+347,10
@@
int Elf_Relocate(void *Base)
}
\r
}
\r
\r
}
\r
}
\r
\r
+ if( !dynsymtab && iSymCount > 0 ) {
\r
+ Log_Warning("ELF", "Elf_Relocate: No Dynamic symbol table, but count >0");
\r
+ return 0;
\r
+ }
\r
\r
// Alter Symbols to true base
\r
for(i = 0; i < iSymCount; i ++)
\r
\r
// Alter Symbols to true base
\r
for(i = 0; i < iSymCount; i ++)
\r
@@
-409,7
+413,7
@@
int Elf_Relocate(void *Base)
for( i = 0; i < j; i++ )
\r
{
\r
ptr = (void*)(iBaseDiff + rela[i].r_offset);
\r
for( i = 0; i < j; i++ )
\r
{
\r
ptr = (void*)(iBaseDiff + rela[i].r_offset);
\r
- if( !Elf_Int_DoRelocate(rel[i].r_info, ptr, rela[i].r_addend, dynsymtab, (Uint)Base) ) {
\r
+ if( !Elf_Int_DoRelocate(rel
a
[i].r_info, ptr, rela[i].r_addend, dynsymtab, (Uint)Base) ) {
\r
bFailed = 1;
\r
}
\r
}
\r
bFailed = 1;
\r
}
\r
}
\r
@@
-451,8
+455,8
@@
int Elf_Relocate(void *Base)
return 0;
\r
}
\r
\r
return 0;
\r
}
\r
\r
- LEAVE('x',
hdr->entrypoint
);
\r
- return
hdr->entrypoint
;
\r
+ LEAVE('x',
1
);
\r
+ return
1
;
\r
}
\r
\r
/**
\r
}
\r
\r
/**
\r
@@
-528,10
+532,10
@@
int Elf_Int_DoRelocate(Uint r_info, Uint32 *ptr, Uint32 addend, Elf32_Sym *symta
}
\r
\r
/**
\r
}
\r
\r
/**
\r
- * \fn int Elf_GetSymbol(void *Base, char *name, Uint *ret)
\r
+ * \fn int Elf_GetSymbol(void *Base, c
onst c
har *name, Uint *ret)
\r
* \brief Get a symbol from the loaded binary
\r
*/
\r
* \brief Get a symbol from the loaded binary
\r
*/
\r
-int Elf_GetSymbol(void *Base, char *Name, Uint *ret)
\r
+int Elf_GetSymbol(void *Base, c
onst c
har *Name, Uint *ret)
\r
{
\r
Elf32_Ehdr *hdr = (void*)Base;
\r
Elf32_Sym *symtab;
\r
{
\r
Elf32_Ehdr *hdr = (void*)Base;
\r
Elf32_Sym *symtab;
\r
@@
-581,7
+585,7
@@
int Elf_GetSymbol(void *Base, char *Name, Uint *ret)
* \param str String to hash
\r
* \return Hash value
\r
*/
\r
* \param str String to hash
\r
* \return Hash value
\r
*/
\r
-Uint Elf_Int_HashString(char *str)
\r
+Uint Elf_Int_HashString(c
onst c
har *str)
\r
{
\r
Uint h = 0, g;
\r
while(*str)
\r
{
\r
Uint h = 0, g;
\r
while(*str)
\r
UCC
git Repository :: git.ucc.asn.au