summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValtteri Rahkonen <valtteri@rahkonen.fi>2006-12-30 00:12:47 +0200
committerLauri Leukkunen <lleukkun@leka.rahina.org>2006-12-30 00:56:30 +0200
commitb52a720f08401dc3eb8ac45ec47486db36e49468 (patch)
treeb8d00444b7695c6a86da017d842473a1d60d9de7
parent13859ab9690119a35fbb3a4b8befb4beb9a08226 (diff)
lua_bindings.c: - x86_64 system call support i.e. use __NR_stat instead of __NR_stat64 and __NR_lstat instead of __NR_lstat64
-rw-r--r--lua/lua_bindings.c14
-rw-r--r--preload/libsb2.c25
2 files changed, 35 insertions, 4 deletions
diff --git a/lua/lua_bindings.c b/lua/lua_bindings.c
index 4accec4..cb59d75 100644
--- a/lua/lua_bindings.c
+++ b/lua/lua_bindings.c
@@ -269,7 +269,11 @@ static int insert_sb2cache(const char *binary_name, const char *func_name, const
*wrk = '\0';
//DBGOUT("checking path: %s\n", dcopy);
+#ifdef __x86_64__
+ if (syscall(__NR_stat, dcopy, &s) < 0) {
+#else
if (syscall(__NR_stat64, dcopy, &s) < 0) {
+#endif
if (errno == ENOENT || errno == ENOTDIR) {
/* create the dir */
if (syscall(__NR_mkdir, dcopy, S_IRWXU) < 0) {
@@ -361,8 +365,11 @@ static int sb_followsymlink(lua_State *l)
path = strdup(lua_tostring(l, 1));
//printf("C thinks path is: %s\n", path);
-
+#ifdef __x86_64__
+ if (syscall(__NR_lstat, path, &s) < 0) {
+#else
if (syscall(__NR_lstat64, path, &s) < 0) {
+#endif
/* didn't work
* TODO: error handling
*/
@@ -734,8 +741,11 @@ __sb2_realpath (const char *name, char *resolved)
dest = mempcpy (dest, start, end - start);
*dest = '\0';
-
+#ifdef __x86_64__
+ if (syscall(__NR_lstat, rpath, &st) < 0)
+#else
if (syscall(__NR_lstat64, rpath, &st) < 0)
+#endif
goto error;
if (S_ISLNK (st.st_mode))
diff --git a/preload/libsb2.c b/preload/libsb2.c
index 3e624cf..468f0e8 100644
--- a/preload/libsb2.c
+++ b/preload/libsb2.c
@@ -662,11 +662,16 @@ static enum binary_type inspect_binary(const char *filename)
int fd, phnum, j;
struct stat status;
char *region;
- int reloc0;
unsigned int ph_base, ph_frag;
+#ifdef __x86_64__
+ uint64_t reloc0;
+ Elf64_Ehdr *ehdr;
+ Elf64_Phdr *phdr;
+#else
+ int reloc0;
Elf32_Ehdr *ehdr;
Elf32_Phdr *phdr;
-
+#endif
retval = BIN_NONE;
fd = syscall(__NR_open, filename, O_RDONLY, 0);
@@ -689,7 +694,11 @@ static enum binary_type inspect_binary(const char *filename)
goto _out_close;
}
+#ifdef __x86_64__
+ ehdr = (Elf64_Ehdr *) region;
+#else
ehdr = (Elf32_Ehdr *) region;
+#endif
switch (ehdr->e_machine) {
case EM_ARM:
@@ -717,7 +726,11 @@ static enum binary_type inspect_binary(const char *filename)
ph_base = ehdr->e_phoff & PAGE_MASK;
ph_frag = ehdr->e_phoff - ph_base;
+#ifdef __x86_64__
+ phdr = (Elf64_Phdr *) (region + ph_base + ph_frag);
+#else
phdr = (Elf32_Phdr *) (region + ph_base + ph_frag);
+#endif
for (j = phnum; --j >= 0; ++phdr) {
if (PT_LOAD == phdr->p_type && ~0 == reloc0) {
@@ -730,7 +743,11 @@ static enum binary_type inspect_binary(const char *filename)
for (j = phnum; --j >= 0; ++phdr) {
int szDyn;
unsigned int pt_base, pt_frag;
+#ifdef __x86_64__
+ Elf64_Dyn *dp_rpath, *dp_strsz, *dp_strtab, *dp;
+#else
Elf32_Dyn *dp_rpath, *dp_strsz, *dp_strtab, *dp;
+#endif
if (PT_DYNAMIC != phdr->p_type) {
continue;
@@ -746,7 +763,11 @@ static enum binary_type inspect_binary(const char *filename)
dp_strsz = NULL;
dp_strtab = NULL;
+#ifdef __x86_64__
+ dp = (Elf64_Dyn *) ((char *) region + pt_base + pt_frag);
+#else
dp = (Elf32_Dyn *) ((char *) region + pt_base + pt_frag);
+#endif
for (; 0 <= (szDyn -= sizeof (*dp)); ++dp) {
if (DT_RPATH == dp->d_tag) {