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
AcessNative - Spawn in libacess-native (with AN_GETPATH syscall)
[tpg/acess2.git]
/
AcessNative
/
ld-acess_src
/
elf_load.c
diff --git
a/AcessNative/ld-acess_src/elf_load.c
b/AcessNative/ld-acess_src/elf_load.c
index
590da37
..
19a8c13
100644
(file)
--- a/
AcessNative/ld-acess_src/elf_load.c
+++ b/
AcessNative/ld-acess_src/elf_load.c
@@
-3,11
+3,12
@@
*
\r
* ELF Executable Loader Code
\r
*/
\r
*
\r
* ELF Executable Loader Code
\r
*/
\r
-#define DEBUG
1
\r
+#define DEBUG
0
\r
#include <stdlib.h>
\r
#include <stdio.h>
\r
#include <string.h>
\r
#include <unistd.h>
\r
#include <stdlib.h>
\r
#include <stdio.h>
\r
#include <string.h>
\r
#include <unistd.h>
\r
+#include <inttypes.h> // PRIx64
\r
#include "common.h"
\r
#include "elf32.h"
\r
#include "elf64.h"
\r
#include "common.h"
\r
#include "elf32.h"
\r
#include "elf64.h"
\r
@@
-41,7
+42,7
@@
void *Elf_Load(int FD)
Elf64_Ehdr hdr;
\r
\r
// Read ELF Header
\r
Elf64_Ehdr hdr;
\r
\r
// Read ELF Header
\r
- acess_
r
ead(FD, &hdr, sizeof(hdr));
\r
+ acess_
_SysR
ead(FD, &hdr, sizeof(hdr));
\r
\r
// Check the file type
\r
if(hdr.e_ident[0] != 0x7F || hdr.e_ident[1] != 'E' || hdr.e_ident[2] != 'L' || hdr.e_ident[3] != 'F') {
\r
\r
// Check the file type
\r
if(hdr.e_ident[0] != 0x7F || hdr.e_ident[1] != 'E' || hdr.e_ident[2] != 'L' || hdr.e_ident[3] != 'F') {
\r
@@
-88,8
+89,8
@@
void *Elf32Load(int FD, Elf32_Ehdr *hdr)
return NULL;
\r
}
\r
LOG("hdr.phoff = 0x%08x\n", hdr->phoff);
\r
return NULL;
\r
}
\r
LOG("hdr.phoff = 0x%08x\n", hdr->phoff);
\r
- acess_
s
eek(FD, hdr->phoff, ACESS_SEEK_SET);
\r
- acess_
r
ead(FD, phtab, sizeof(Elf32_Phdr) * hdr->phentcount);
\r
+ acess_
_SysS
eek(FD, hdr->phoff, ACESS_SEEK_SET);
\r
+ acess_
_SysR
ead(FD, phtab, sizeof(Elf32_Phdr) * hdr->phentcount);
\r
\r
// Count Pages
\r
iPageCount = 0;
\r
\r
// Count Pages
\r
iPageCount = 0;
\r
@@
-145,8
+146,8
@@
void *Elf32Load(int FD, Elf32_Ehdr *hdr)
char *tmp;
\r
//if(ret->Interpreter) continue;
\r
tmp = malloc(phtab[i].FileSize);
\r
char *tmp;
\r
//if(ret->Interpreter) continue;
\r
tmp = malloc(phtab[i].FileSize);
\r
- acess_
s
eek(FD, phtab[i].Offset, ACESS_SEEK_SET);
\r
- acess_
r
ead(FD, tmp, phtab[i].FileSize);
\r
+ acess_
_SysS
eek(FD, phtab[i].Offset, ACESS_SEEK_SET);
\r
+ acess_
_SysR
ead(FD, tmp, phtab[i].FileSize);
\r
//ret->Interpreter = Binary_RegInterp(tmp);
\r
LOG("Interpreter '%s'\n", tmp);
\r
free(tmp);
\r
//ret->Interpreter = Binary_RegInterp(tmp);
\r
LOG("Interpreter '%s'\n", tmp);
\r
free(tmp);
\r
@@
-167,8
+168,8
@@
void *Elf32Load(int FD, Elf32_Ehdr *hdr)
return NULL;
\r
}
\r
\r
return NULL;
\r
}
\r
\r
- acess_
s
eek(FD, phtab[i].Offset, ACESS_SEEK_SET);
\r
- acess_
r
ead(FD, PTRMK(void, addr), phtab[i].FileSize);
\r
+ acess_
_SysS
eek(FD, phtab[i].Offset, ACESS_SEEK_SET);
\r
+ acess_
_SysR
ead(FD, PTRMK(void, addr), phtab[i].FileSize);
\r
memset( PTRMK(char, addr) + phtab[i].FileSize, 0, phtab[i].MemSize - phtab[i].FileSize );
\r
}
\r
\r
memset( PTRMK(char, addr) + phtab[i].FileSize, 0, phtab[i].MemSize - phtab[i].FileSize );
\r
}
\r
\r
@@
-190,9
+191,9
@@
void *Elf64Load(int FD, Elf64_Ehdr *hdr)
\r
ENTER("iFD", FD);
\r
\r
\r
ENTER("iFD", FD);
\r
\r
- #if BITS <= 32
\r
- Warning("ELF64 being loaded in 32-bit env, this may not work");
\r
- #endif
\r
+ if( sizeof(void*) == 4) {
\r
+
Warning("ELF64 being loaded in 32-bit env, this may not work");
\r
+ }
\r
\r
// Check for a program header
\r
if(hdr->e_phoff == 0) {
\r
\r
// Check for a program header
\r
if(hdr->e_phoff == 0) {
\r
@@
-210,8
+211,8
@@
void *Elf64Load(int FD, Elf64_Ehdr *hdr)
return NULL;
\r
}
\r
LOG("hdr.phoff = 0x%08llx\n", (long long)hdr->e_phoff);
\r
return NULL;
\r
}
\r
LOG("hdr.phoff = 0x%08llx\n", (long long)hdr->e_phoff);
\r
- acess_
s
eek(FD, hdr->e_phoff, ACESS_SEEK_SET);
\r
- acess_
r
ead(FD, phtab, sizeof(Elf64_Phdr) * hdr->e_phnum);
\r
+ acess_
_SysS
eek(FD, hdr->e_phoff, ACESS_SEEK_SET);
\r
+ acess_
_SysR
ead(FD, phtab, sizeof(Elf64_Phdr) * hdr->e_phnum);
\r
\r
// Count Pages
\r
iPageCount = 0;
\r
\r
// Count Pages
\r
iPageCount = 0;
\r
@@
-269,8
+270,8
@@
void *Elf64Load(int FD, Elf64_Ehdr *hdr)
//if(ret->Interpreter) continue;
\r
tmp = malloc(phtab[i].p_filesz+1);
\r
tmp[ phtab[i].p_filesz ] = 0;
\r
//if(ret->Interpreter) continue;
\r
tmp = malloc(phtab[i].p_filesz+1);
\r
tmp[ phtab[i].p_filesz ] = 0;
\r
- acess_
s
eek(FD, phtab[i].p_offset, ACESS_SEEK_SET);
\r
- acess_
r
ead(FD, tmp, phtab[i].p_filesz);
\r
+ acess_
_SysS
eek(FD, phtab[i].p_offset, ACESS_SEEK_SET);
\r
+ acess_
_SysR
ead(FD, tmp, phtab[i].p_filesz);
\r
//ret->Interpreter = Binary_RegInterp(tmp);
\r
LOG("Interpreter '%s'\n", tmp);
\r
free(tmp);
\r
//ret->Interpreter = Binary_RegInterp(tmp);
\r
LOG("Interpreter '%s'\n", tmp);
\r
free(tmp);
\r
@@
-288,14
+289,14
@@
void *Elf64Load(int FD, Elf64_Ehdr *hdr)
addr = phtab[i].p_vaddr + baseDiff;
\r
\r
if( AllocateMemory( addr, phtab[i].p_memsz ) ) {
\r
addr = phtab[i].p_vaddr + baseDiff;
\r
\r
if( AllocateMemory( addr, phtab[i].p_memsz ) ) {
\r
- fprintf(stderr, "Elf_Load: Unable to map memory at %
llx (0x%llx
bytes)\n",
\r
- (
long long)addr, (long long
)phtab[i].p_memsz);
\r
+ fprintf(stderr, "Elf_Load: Unable to map memory at %
"PRIx64" (0x%"PRIx64"
bytes)\n",
\r
+ (
uint64_t)addr, (uint64_t
)phtab[i].p_memsz);
\r
free( phtab );
\r
return NULL;
\r
}
\r
\r
free( phtab );
\r
return NULL;
\r
}
\r
\r
- acess_
s
eek(FD, phtab[i].p_offset, ACESS_SEEK_SET);
\r
- acess_
r
ead(FD, PTRMK(void, addr), phtab[i].p_filesz);
\r
+ acess_
_SysS
eek(FD, phtab[i].p_offset, ACESS_SEEK_SET);
\r
+ acess_
_SysR
ead(FD, PTRMK(void, addr), phtab[i].p_filesz);
\r
memset( PTRMK(char, addr) + phtab[i].p_filesz, 0, phtab[i].p_memsz - phtab[i].p_filesz );
\r
}
\r
\r
memset( PTRMK(char, addr) + phtab[i].p_filesz, 0, phtab[i].p_memsz - phtab[i].p_filesz );
\r
}
\r
\r
UCC
git Repository :: git.ucc.asn.au