summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org>2011-09-27 21:10:30 +0159
committerBernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org>2011-09-27 21:10:30 +0159
commit0513f4c3119ad2ca0b302eedefc58cc7f470d6de (patch)
treef57f3bcebf9404a845a7e76b13667e1e0c68bce6
parentafd53a34c99d33af4f9de4595b8b537c9a02e2d3 (diff)
downloadelfcopy-linaro_android_2.3.7.tar.gz
elfcopy: Add basic GNU-style hash supportlinaro_android_2.3.7linaro_android_2.3.5
This enables elfcopy to handle binaries linked with --hash-style=gnu Signed-off-by: Bernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org>
-rw-r--r--elfcopy.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/elfcopy.c b/elfcopy.c
index b7105aa..27458c3 100644
--- a/elfcopy.c
+++ b/elfcopy.c
@@ -34,6 +34,16 @@
*/
#define ELF_STRPTR_IS_BROKEN (1)
+/* Compatible for older elfutils.
+ elfutils support gnu-style hash since version 0.122
+*/
+#ifndef DT_GNU_HASH
+#define DT_GNU_HASH 0x6ffffef5
+#endif
+#ifndef SHT_GNU_HASH
+#define SHT_GNU_HASH 0x6ffffff6
+#endif
+
static void update_relocations_section_symbol_references(Elf *newelf, Elf *elf,
shdr_info_t *info, int info_len,
shdr_info_t *relsect_info,
@@ -744,7 +754,6 @@ void adjust_elf(Elf *elf, const char *elf_name,
FAILIF(shdr_info[cnt].shdr.sh_entsize != sizeof (Elf32_Word),
"Can't handle 64-bit ELF files!\n");
-
update_hash_table(newelf, /* new ELF */
elf, /* old ELF */
shdr_info[cnt].idx, /* hash table index */
@@ -846,7 +855,9 @@ void adjust_elf(Elf *elf, const char *elf_name,
} /* for each symbol... */
}
}
-
+ /* We don't support updating gnu-style hash tables for now! */
+ FAILIF(shdr_info[cnt].shdr.sh_type == SHT_GNU_HASH,
+ "Can't handle SHT_GNU_HASH!\n");
FAILIF(shdr_info[cnt].shdr.sh_type == SHT_GNU_versym,
"Can't handle SHT_GNU_versym!\n");
FAILIF(shdr_info[cnt].shdr.sh_type == SHT_GROUP,
@@ -1933,6 +1944,7 @@ static void adjust_dynamic_segment_offsets(Elf *elf, Ebl *oldebl,
case DT_PLTGOT:
case DT_HASH:
+ case DT_GNU_HASH:
case DT_SYMTAB:
(void)update_dyn_entry_address(elf, dyn, shdr_info, shdr_info_len);
break;
@@ -2581,6 +2593,7 @@ static int get_end_of_range(shdr_info_t *shdr_info,
(shdr_info[end].shdr.sh_type == SHT_INIT_ARRAY) ||
(shdr_info[end].shdr.sh_type == SHT_FINI_ARRAY) ||
(shdr_info[end].shdr.sh_type == SHT_PREINIT_ARRAY) ||
+ (shdr_info[end].shdr.sh_type == SHT_GNU_HASH) ||
(shdr_info[end].shdr.sh_type == SHT_NOBITS) ||
#ifdef ARM_SPECIFIC_HACKS
/* SHF_ALLOC sections with with names starting with ".ARM." are