git.ucc.asn.au
/
tpg
/
acess2.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
818dd00
)
Kernel - Preparing for ELF64 support
author
John Hodge
<
[email protected]
>
Mon, 22 Aug 2011 08:05:35 +0000
(16:05 +0800)
committer
John Hodge
<
[email protected]
>
Mon, 22 Aug 2011 08:05:35 +0000
(16:05 +0800)
Kernel/bin/elf.c
patch
|
blob
|
history
diff --git
a/Kernel/bin/elf.c
b/Kernel/bin/elf.c
index
d04dbda
..
4feb6bc
100644
(file)
--- a/
Kernel/bin/elf.c
+++ b/
Kernel/bin/elf.c
@@
-11,6
+11,8
@@
\r
// === PROTOTYPES ===
\r
tBinary *Elf_Load(int fp);
\r
\r
// === PROTOTYPES ===
\r
tBinary *Elf_Load(int fp);
\r
+tBinary *Elf_Load32(Elf32_Ehdr *hdr, int fp);
\r
+//tBinary *Elf_Load64(int fp);
\r
int Elf_Relocate(void *Base);
\r
int Elf_GetSymbol(void *Base, const char *Name, Uint *ret);
\r
int Elf_Int_DoRelocate(Uint r_info, Uint32 *ptr, Uint32 addend, Elf32_Sym *symtab, Uint base);
\r
int Elf_Relocate(void *Base);
\r
int Elf_GetSymbol(void *Base, const char *Name, Uint *ret);
\r
int Elf_Int_DoRelocate(Uint r_info, Uint32 *ptr, Uint32 addend, Elf32_Sym *symtab, Uint base);
\r
@@
-27,13
+29,8
@@
tBinaryType gELF_Info = {
// === CODE ===
\r
tBinary *Elf_Load(int fp)
\r
{
\r
// === CODE ===
\r
tBinary *Elf_Load(int fp)
\r
{
\r
- tBinary *ret;
\r
Elf32_Ehdr hdr;
\r
Elf32_Ehdr hdr;
\r
- Elf32_Phdr *phtab;
\r
- int i, j, k;
\r
- int iPageCount;
\r
- int count;
\r
-
\r
+
\r
ENTER("xfp", fp);
\r
\r
// Read ELF Header
\r
ENTER("xfp", fp);
\r
\r
// Read ELF Header
\r
@@
-45,9
+42,27
@@
tBinary *Elf_Load(int fp)
LEAVE('n');
\r
return NULL;
\r
}
\r
LEAVE('n');
\r
return NULL;
\r
}
\r
-
\r
+
\r
+ switch( hdr.ident[4] )
\r
+ {
\r
+ case 1: // ELF32
\r
+ return Elf_Load32(&hdr, fp);
\r
+// case 2: // ELF64
\r
+// return ELf_Load64(fp);
\r
+ }
\r
+ return NULL;
\r
+}
\r
+
\r
+tBinary *Elf_Load32(Elf32_Ehdr *hdr, int fp)
\r
+{
\r
+ tBinary *ret;
\r
+ Elf32_Phdr *phtab;
\r
+ int i, j, k;
\r
+ int iPageCount;
\r
+ int count;
\r
+
\r
// Check for a program header
\r
// Check for a program header
\r
- if(hdr
.
phoff == 0) {
\r
+ if(hdr
->
phoff == 0) {
\r
#if DEBUG_WARN
\r
Log_Warning("ELF", "File does not contain a program header (phoff == 0)");
\r
#endif
\r
#if DEBUG_WARN
\r
Log_Warning("ELF", "File does not contain a program header (phoff == 0)");
\r
#endif
\r
@@
-56,19
+71,19
@@
tBinary *Elf_Load(int fp)
}
\r
\r
// Read Program Header Table
\r
}
\r
\r
// Read Program Header Table
\r
- phtab = malloc( sizeof(Elf32_Phdr) * hdr
.
phentcount );
\r
+ phtab = malloc( sizeof(Elf32_Phdr) * hdr
->
phentcount );
\r
if( !phtab ) {
\r
LEAVE('n');
\r
return NULL;
\r
}
\r
if( !phtab ) {
\r
LEAVE('n');
\r
return NULL;
\r
}
\r
- LOG("hdr
.phoff = 0x%08x", hdr.
phoff);
\r
- VFS_Seek(fp, hdr
.
phoff, SEEK_SET);
\r
- VFS_Read(fp, sizeof(Elf32_Phdr)*hdr
.
phentcount, phtab);
\r
+ LOG("hdr
->phoff = 0x%08x", hdr->
phoff);
\r
+ VFS_Seek(fp, hdr
->
phoff, SEEK_SET);
\r
+ VFS_Read(fp, sizeof(Elf32_Phdr)*hdr
->
phentcount, phtab);
\r
\r
// Count Pages
\r
iPageCount = 0;
\r
\r
// Count Pages
\r
iPageCount = 0;
\r
- LOG("hdr
.phentcount = %i", hdr.
phentcount);
\r
- for( i = 0; i < hdr
.
phentcount; i++ )
\r
+ LOG("hdr
->phentcount = %i", hdr->
phentcount);
\r
+ for( i = 0; i < hdr
->
phentcount; i++ )
\r
{
\r
// Ignore Non-LOAD types
\r
if(phtab[i].Type != PT_LOAD)
\r
{
\r
// Ignore Non-LOAD types
\r
if(phtab[i].Type != PT_LOAD)
\r
@@
-82,14
+97,14
@@
tBinary *Elf_Load(int fp)
// Allocate Information Structure
\r
ret = malloc( sizeof(tBinary) + sizeof(tBinaryPage)*iPageCount );
\r
// Fill Info Struct
\r
// Allocate Information Structure
\r
ret = malloc( sizeof(tBinary) + sizeof(tBinaryPage)*iPageCount );
\r
// Fill Info Struct
\r
- ret->Entry = hdr
.
entrypoint;
\r
+ ret->Entry = hdr
->
entrypoint;
\r
ret->Base = -1; // Set Base to maximum value
\r
ret->NumPages = iPageCount;
\r
ret->Interpreter = NULL;
\r
\r
// Load Pages
\r
j = 0;
\r
ret->Base = -1; // Set Base to maximum value
\r
ret->NumPages = iPageCount;
\r
ret->Interpreter = NULL;
\r
\r
// Load Pages
\r
j = 0;
\r
- for( i = 0; i < hdr
.
phentcount; i++ )
\r
+ for( i = 0; i < hdr
->
phentcount; i++ )
\r
{
\r
int lastSize;
\r
//LOG("phtab[%i].Type = 0x%x", i, phtab[i].Type);
\r
{
\r
int lastSize;
\r
//LOG("phtab[%i].Type = 0x%x", i, phtab[i].Type);
\r
UCC
git Repository :: git.ucc.asn.au