aboutsummaryrefslogtreecommitdiff
path: root/libbacktrace
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2013-11-18 17:15:07 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2013-11-18 17:15:07 +0000
commit02dc92c7309e295c75cc2a54b59a3b3d4b540e82 (patch)
tree1f27ce16eebea2f380be6c423498e1f3d32d8c58 /libbacktrace
parentbcddbfd588212678cdc3de05ab7e6cde1c338a9d (diff)
* elf.c (SHN_UNDEF): Define.
(elf_initialize_syminfo): Add base_address argument. Ignore symbols with st_shndx == SHN_UNDEF. Add base_address to address fields. (elf_add): Adjust caller. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@204975 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libbacktrace')
-rw-r--r--libbacktrace/ChangeLog5
-rw-r--r--libbacktrace/elf.c12
2 files changed, 14 insertions, 3 deletions
diff --git a/libbacktrace/ChangeLog b/libbacktrace/ChangeLog
index b7169da6108..c06194df3e4 100644
--- a/libbacktrace/ChangeLog
+++ b/libbacktrace/ChangeLog
@@ -1,5 +1,10 @@
2013-11-18 Jakub Jelinek <jakub@redhat.com>
+ * elf.c (SHN_UNDEF): Define.
+ (elf_initialize_syminfo): Add base_address argument. Ignore symbols
+ with st_shndx == SHN_UNDEF. Add base_address to address fields.
+ (elf_add): Adjust caller.
+
* elf.c (phdr_callback): Process info->dlpi_addr == 0 normally.
2013-11-16 Ian Lance Taylor <iant@google.com>
diff --git a/libbacktrace/elf.c b/libbacktrace/elf.c
index 9a0fd70aed0..659b349f73b 100644
--- a/libbacktrace/elf.c
+++ b/libbacktrace/elf.c
@@ -98,6 +98,7 @@ dl_iterate_phdr (int (*callback) (struct dl_phdr_info *,
#undef EV_CURRENT
#undef SHN_LORESERVE
#undef SHN_XINDEX
+#undef SHN_UNDEF
#undef SHT_SYMTAB
#undef SHT_STRTAB
#undef SHT_DYNSYM
@@ -183,6 +184,7 @@ typedef struct {
b_elf_wxword sh_entsize; /* Entry size if section holds table */
} b_elf_shdr; /* Elf_Shdr. */
+#define SHN_UNDEF 0x0000 /* Undefined section */
#define SHN_LORESERVE 0xFF00 /* Begin range of reserved indices */
#define SHN_XINDEX 0xFFFF /* Section index is held elsewhere */
@@ -342,6 +344,7 @@ elf_symbol_search (const void *vkey, const void *ventry)
static int
elf_initialize_syminfo (struct backtrace_state *state,
+ uintptr_t base_address,
const unsigned char *symtab_data, size_t symtab_size,
const unsigned char *strtab, size_t strtab_size,
backtrace_error_callback error_callback,
@@ -365,7 +368,8 @@ elf_initialize_syminfo (struct backtrace_state *state,
int info;
info = sym->st_info & 0xf;
- if (info == STT_FUNC || info == STT_OBJECT)
+ if ((info == STT_FUNC || info == STT_OBJECT)
+ && sym->st_shndx != SHN_UNDEF)
++elf_symbol_count;
}
@@ -385,6 +389,8 @@ elf_initialize_syminfo (struct backtrace_state *state,
info = sym->st_info & 0xf;
if (info != STT_FUNC && info != STT_OBJECT)
continue;
+ if (sym->st_shndx == SHN_UNDEF)
+ continue;
if (sym->st_name >= strtab_size)
{
error_callback (data, "symbol string index out of range", 0);
@@ -393,7 +399,7 @@ elf_initialize_syminfo (struct backtrace_state *state,
return 0;
}
elf_symbols[j].name = (const char *) strtab + sym->st_name;
- elf_symbols[j].address = sym->st_value;
+ elf_symbols[j].address = sym->st_value + base_address;
elf_symbols[j].size = sym->st_size;
++j;
}
@@ -733,7 +739,7 @@ elf_add (struct backtrace_state *state, int descriptor, uintptr_t base_address,
if (sdata == NULL)
goto fail;
- if (!elf_initialize_syminfo (state,
+ if (!elf_initialize_syminfo (state, base_address,
symtab_view.data, symtab_shdr->sh_size,
strtab_view.data, strtab_shdr->sh_size,
error_callback, data, sdata))