aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ddb/db_elf.c26
-rw-r--r--include/mach/exec/elf.h36
2 files changed, 46 insertions, 16 deletions
diff --git a/ddb/db_elf.c b/ddb/db_elf.c
index 7b7eed73..5ccfdd59 100644
--- a/ddb/db_elf.c
+++ b/ddb/db_elf.c
@@ -63,8 +63,8 @@
struct db_symtab_elf {
int type;
- Elf32_Sym *start;
- Elf32_Sym *end;
+ Elf_Sym *start;
+ Elf_Sym *end;
char *strings;
char *map_pointer; /* symbols are for this map only,
if not null */
@@ -80,7 +80,7 @@ elf_db_sym_init (unsigned shdr_num,
char *name,
char *task_addr)
{
- Elf32_Shdr *shdr, *symtab, *strtab;
+ Elf_Shdr *shdr, *symtab, *strtab;
const char *shstrtab;
unsigned i;
@@ -90,7 +90,7 @@ elf_db_sym_init (unsigned shdr_num,
if (shdr_size != sizeof *shdr)
return FALSE;
- shdr = (Elf32_Shdr *) shdr_addr;
+ shdr = (Elf_Shdr *) shdr_addr;
if (shdr[shdr_shndx].sh_type != SHT_STRTAB)
return FALSE;
@@ -127,7 +127,7 @@ elf_db_sym_init (unsigned shdr_num,
(char *) phystokv (strtab->sh_addr),
task_addr)) {
db_printf ("Loaded ELF symbol table for %s (%d symbols)\n",
- name, symtab->sh_size / sizeof (Elf32_Sym));
+ name, symtab->sh_size / sizeof (Elf_Sym));
return TRUE;
}
@@ -142,7 +142,7 @@ elf_db_lookup (db_symtab_t *stab,
char *symstr)
{
struct db_symtab_elf *self = (struct db_symtab_elf *) stab;
- Elf32_Sym *s;
+ Elf_Sym *s;
for (s = self->start; s < self->end; s++)
if (strcmp (symstr, &self->strings[s->st_name]) == 0)
@@ -159,29 +159,29 @@ elf_db_search_symbol (db_symtab_t *stab,
{
struct db_symtab_elf *self = (struct db_symtab_elf *) stab;
unsigned long diff = *diffp;
- Elf32_Sym *s, *symp = NULL;
+ Elf_Sym *s, *symp = NULL;
for (s = self->start; s < self->end; s++) {
if (s->st_name == 0)
continue;
- if (strategy == DB_STGY_XTRN && (ELF32_ST_BIND(s->st_info) != STB_GLOBAL))
+ if (strategy == DB_STGY_XTRN && (ELF_ST_BIND(s->st_info) != STB_GLOBAL))
continue;
if (off >= s->st_value) {
- if (ELF32_ST_TYPE(s->st_info) != STT_FUNC)
+ if (ELF_ST_TYPE(s->st_info) != STT_FUNC)
continue;
if (off - s->st_value < diff) {
diff = off - s->st_value;
symp = s;
- if (diff == 0 && (ELF32_ST_BIND(s->st_info) == STB_GLOBAL))
+ if (diff == 0 && (ELF_ST_BIND(s->st_info) == STB_GLOBAL))
break;
} else if (off - s->st_value == diff) {
if (symp == NULL)
symp = s;
- else if ((ELF32_ST_BIND(symp->st_info) != STB_GLOBAL)
- && (ELF32_ST_BIND(s->st_info) == STB_GLOBAL))
+ else if ((ELF_ST_BIND(symp->st_info) != STB_GLOBAL)
+ && (ELF_ST_BIND(s->st_info) == STB_GLOBAL))
symp = s; /* pick the external symbol */
}
}
@@ -205,7 +205,7 @@ elf_db_symbol_values (db_symtab_t *stab,
db_expr_t *valuep)
{
struct db_symtab_elf *self = (struct db_symtab_elf *) stab;
- Elf32_Sym *s = (Elf32_Sym *) sym;
+ Elf_Sym *s = (Elf_Sym *) sym;
if (namep)
*namep = &self->strings[s->st_name];
diff --git a/include/mach/exec/elf.h b/include/mach/exec/elf.h
index f52e115d..409947c4 100644
--- a/include/mach/exec/elf.h
+++ b/include/mach/exec/elf.h
@@ -152,6 +152,19 @@ typedef struct {
Elf32_Word sh_entsize;
} Elf32_Shdr;
+typedef struct elf64_shdr {
+ Elf64_Word sh_name;
+ Elf64_Word sh_type;
+ Elf64_Xword sh_flags;
+ Elf64_Addr sh_addr;
+ Elf64_Off sh_offset;
+ Elf64_Xword sh_size;
+ Elf64_Word sh_link;
+ Elf64_Word sh_info;
+ Elf64_Xword sh_addralign;
+ Elf64_Xword sh_entsize;
+} Elf64_Shdr;
+
/* section types - page 4-15, figure 4-9 */
#define SHT_NULL 0
@@ -190,11 +203,28 @@ typedef struct
Elf32_Half st_shndx;
} Elf32_Sym;
+typedef struct elf64_sym {
+ Elf64_Word st_name;
+ unsigned char st_info;
+ unsigned char st_other;
+ Elf64_Half st_shndx;
+ Elf64_Addr st_value;
+ Elf64_Xword st_size;
+} Elf64_Sym;
+
+#ifdef __x86_64__
+#define Elf_Sym Elf64_Sym
+#define Elf_Shdr Elf64_Shdr
+#else
+#define Elf_Sym Elf32_Sym
+#define Elf_Shdr Elf32_Shdr
+#endif
+
/* symbol type and binding attributes - page 4-26 */
-#define ELF32_ST_BIND(i) ((i) >> 4)
-#define ELF32_ST_TYPE(i) ((i) & 0xf)
-#define ELF32_ST_INFO(b,t) (((b)<<4)+((t)&0xf))
+#define ELF_ST_BIND(i) ((i) >> 4)
+#define ELF_ST_TYPE(i) ((i) & 0xf)
+#define ELF_ST_INFO(b,t) (((b)<<4)+((t)&0xf))
/* symbol binding - page 4-26, figure 4-16 */