Last active
December 16, 2015 18:49
-
-
Save MrVan/5480364 to your computer and use it in GitHub Desktop.
A basic patch now.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 0f541ee952030aae37d2214cd26a09c61c6be16f Mon Sep 17 00:00:00 2001 | |
From: Peng Fan <van.freenix@gmail.com> | |
Date: Wed, 1 May 2013 13:09:11 +0800 | |
Subject: [PATCH] Arm && Mips | |
--- | |
.gitignore | 1 + | |
elftoolchain/libelf/elf_data.c | 26 ++++++++++++++++++++++++++ | |
rld-files.cpp | 3 ++- | |
rld-rap.cpp | 18 ++++++++++++++++-- | |
4 files changed, 45 insertions(+), 3 deletions(-) | |
diff --git a/.gitignore b/.gitignore | |
index c80a859..99e0316 100644 | |
--- a/.gitignore | |
+++ b/.gitignore | |
@@ -2,3 +2,4 @@ | |
build-* | |
*.rap | |
*.pyc | |
+test.c | |
diff --git a/elftoolchain/libelf/elf_data.c b/elftoolchain/libelf/elf_data.c | |
index 5ac6453..f1016ad 100644 | |
--- a/elftoolchain/libelf/elf_data.c | |
+++ b/elftoolchain/libelf/elf_data.c | |
@@ -87,6 +87,31 @@ elf_getdata(Elf_Scn *s, Elf_Data *d) | |
return (NULL); | |
} | |
+ if (s->s_elf->e_u.e_elf.e_ehdr.e_ehdr32->e_machine == EM_ARM) { | |
+ if (sh_type == 0x70000003 || sh_type == 0x70000001) { | |
+ //printf("arm sh_type 0x%x\n", sh_type); | |
+ // freenix | |
+ if ((d = _libelf_allocate_data(s)) == NULL) | |
+ return (NULL); | |
+ d->d_buf = 0; | |
+ d->d_size = 0; | |
+ return (d); | |
+ } | |
+ } | |
+ if (s->s_elf->e_u.e_elf.e_ehdr.e_ehdr32->e_machine == EM_MIPS) { | |
+ if ((sh_type == 0x70000006) || (sh_type == 0x7000001e) || | |
+ (sh_type == 0x6ffffff5)) { | |
+ //printf("mips sh_type 0x%x\n", sh_type); | |
+ //freenix not sure whether this is right | |
+ if ((d = _libelf_allocate_data(s)) == NULL) | |
+ return (NULL); | |
+ d->d_buf = 0; | |
+ d->d_size = 0; | |
+ return (d); | |
+ } | |
+ } | |
+ //printf("freenix %x %x\n", (sh_type), ELF_T_FIRST); | |
+ | |
if ((elftype = _libelf_xlate_shtype(sh_type)) < ELF_T_FIRST || | |
elftype > ELF_T_LAST || (sh_type != SHT_NOBITS && | |
sh_offset + sh_size > (uint64_t) e->e_rawsize)) { | |
@@ -101,6 +126,7 @@ elf_getdata(Elf_Scn *s, Elf_Data *d) | |
} | |
if (sh_size % fsz) { | |
+ printf("2222\n"); | |
LIBELF_SET_ERROR(SECTION, 0); | |
return (NULL); | |
} | |
diff --git a/rld-files.cpp b/rld-files.cpp | |
index 9887e48..4693594 100644 | |
--- a/rld-files.cpp | |
+++ b/rld-files.cpp | |
@@ -1514,7 +1514,8 @@ namespace rld | |
object* obj = (*oi).second; | |
obj->open (); | |
obj->begin (); | |
- obj->load_symbols (symbols, local); | |
+ //obj->load_symbols (symbols, local); //freenix | |
+ obj->load_symbols (symbols, true); //freenix | |
obj->end (); | |
obj->close (); | |
} | |
diff --git a/rld-rap.cpp b/rld-rap.cpp | |
index 8b3bbcb..e9263b1 100644 | |
--- a/rld-rap.cpp | |
+++ b/rld-rap.cpp | |
@@ -931,12 +931,26 @@ namespace rld | |
++ei) | |
{ | |
const symbols::symbol& sym = *(*ei); | |
+ std::string debug_sym; | |
- if ((sym.type () == STT_OBJECT) || (sym.type () == STT_FUNC)) | |
+ /* remove debug related symbols */ | |
+ debug_sym = obj.obj.get_section(sym.section_index()).name; | |
+ if (debug_sym.find("debug") != -1) | |
+ continue; | |
+ | |
+ if ((sym.type () == STT_OBJECT) || (sym.type () == STT_FUNC) || | |
+ ((elf::object_machine_type () == EM_MIPS) && | |
+ (sym.type ()== STT_NOTYPE)&& (sym.binding () == STB_LOCAL))) | |
{ | |
- if ((sym.binding () == STB_GLOBAL) || (sym.binding () == STB_WEAK)) | |
+ if ((sym.binding () == STB_GLOBAL) || (sym.binding () == STB_WEAK) || | |
+ ((elf::object_machine_type () == EM_MIPS) && | |
+ (sym.type ()== STT_NOTYPE)&& (sym.binding () == STB_LOCAL))) | |
{ | |
+ std::cout << "collect_symbols: " << sym.name() <<std::endl; | |
+ std::cout << "type: " << sym.type() <<" binding: " <<sym.binding()<<std::endl; | |
int symsec = sym.section_index (); | |
+ if (symsec == 0) | |
+ continue; //ignore the first null section [freenix] | |
sections rap_sec = obj.find (symsec); | |
section& sec = obj.secs[rap_sec]; | |
std::size_t name; | |
-- | |
1.7.10.4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment