summaryrefslogtreecommitdiffstats
path: root/libebl
diff options
context:
space:
mode:
authorMark Wielaard <mjw@redhat.com>2013-12-18 11:05:54 +0100
committerMark Wielaard <mjw@redhat.com>2013-12-20 10:09:49 +0100
commit159ac52b061c60947a943c102298cd692223274f (patch)
treed3d3a07d249704f95424072064e160df4ae4c156 /libebl
parent565149d564cfe9da3b5cd94c9387ee0473d0704a (diff)
libdwfl: Introduce dwfl_module_getsym_info and dwfl_module_addrinfo.
Some arches like ppc64 use function descriptor values instead of function addresses causing matching of names and addresses to fail when using dwfl_module_getsym or dwfl_module_addrsym. Add ebl hook to resolve any function descriptor values found in non-ET_REL modules. The new function dwfl_module_getsym_info doesn't adjust the symbol value in any way, but returns the adjusted and/or resolved address associated with the symbol separately. The new function dwfl_module_addrinfo resolves against both the address associated with the symbol (which could be the function entry address) value and the adjusted st_value. So that it is easy to resolve and match either function descriptors and/or function entry addresses. Since these new functions also return more information they replace the dwfl_module_getsym_elf and dwfl_module_addrsym_elf functions that never made it into a released elfutils version. addr2line and readelf now use the new functions when looking up functions names. addr2line will now also display the section the address was found in when given -x. Extra testcases were added for both addr2line and the dwflsyms testscase. Signed-off-by: Mark Wielaard <mjw@redhat.com>
Diffstat (limited to 'libebl')
-rw-r--r--libebl/ChangeLog9
-rw-r--r--libebl/Makefile.am2
-rw-r--r--libebl/ebl-hooks.h5
-rw-r--r--libebl/eblresolvesym.c43
-rw-r--r--libebl/libebl.h6
-rw-r--r--libebl/libeblP.h5
6 files changed, 69 insertions, 1 deletions
diff --git a/libebl/ChangeLog b/libebl/ChangeLog
index f1aa242b..fc6bdd56 100644
--- a/libebl/ChangeLog
+++ b/libebl/ChangeLog
@@ -1,3 +1,12 @@
+2013-12-18 Mark Wielaard <mjw@redhat.com>
+
+ * Makefile.am (gen_SOURCES): Add eblresolvesym.c.
+ * ebl-hooks.h (resolve_sym_value): New entry.
+ * eblresolvesym.c: New file.
+ * libebl.h (ebl_resolve_sym_value): New definition.
+ * libeblP.h (fd_addr): New field.
+ (fd_data): Likewise.
+
2013-12-18 Jan Kratochvil <jan.kratochvil@redhat.com>
unwinder: s390 and s390x
diff --git a/libebl/Makefile.am b/libebl/Makefile.am
index fc4f1b6f..916af72a 100644
--- a/libebl/Makefile.am
+++ b/libebl/Makefile.am
@@ -55,7 +55,7 @@ gen_SOURCES = eblopenbackend.c eblclosebackend.c eblstrtab.c \
eblsysvhashentrysize.c eblauxvinfo.c eblcheckobjattr.c \
ebl_check_special_section.c ebl_syscall_abi.c eblabicfi.c \
eblstother.c eblinitreg.c ebldwarftoregno.c eblnormalizepc.c \
- eblunwind.c
+ eblunwind.c eblresolvesym.c
libebl_a_SOURCES = $(gen_SOURCES)
diff --git a/libebl/ebl-hooks.h b/libebl/ebl-hooks.h
index 22438953..bfb7f4a9 100644
--- a/libebl/ebl-hooks.h
+++ b/libebl/ebl-hooks.h
@@ -183,5 +183,10 @@ bool EBLHOOK(unwind) (Ebl *ebl, Dwarf_Addr pc, ebl_tid_registers_t *setfunc,
ebl_pid_memory_read_t *readfunc, void *arg,
bool *signal_framep);
+/* Returns true if the value can be resolved to an address in an
+ allocated section, which will be returned in *SHNDXP.
+ (e.g. function descriptor resolving) */
+bool EBLHOOK(resolve_sym_value) (Ebl *ebl, GElf_Addr *addr);
+
/* Destructor for ELF backend handle. */
void EBLHOOK(destr) (struct ebl *);
diff --git a/libebl/eblresolvesym.c b/libebl/eblresolvesym.c
new file mode 100644
index 00000000..470f6f06
--- /dev/null
+++ b/libebl/eblresolvesym.c
@@ -0,0 +1,43 @@
+/* Resolve a symbol value to an allocated section of the Elf file.
+ Copyright (C) 2013 Red Hat, Inc.
+ This file is part of elfutils.
+
+ This file is free software; you can redistribute it and/or modify
+ it under the terms of either
+
+ * the GNU Lesser General Public License as published by the Free
+ Software Foundation; either version 3 of the License, or (at
+ your option) any later version
+
+ or
+
+ * the GNU General Public License as published by the Free
+ Software Foundation; either version 2 of the License, or (at
+ your option) any later version
+
+ or both in parallel, as here.
+
+ elfutils is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received copies of the GNU General Public License and
+ the GNU Lesser General Public License along with this program. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <libeblP.h>
+#include <assert.h>
+
+bool
+ebl_resolve_sym_value (Ebl *ebl, GElf_Addr *addr)
+{
+ if (ebl == NULL || ebl->resolve_sym_value == NULL)
+ return false;
+
+ return ebl->resolve_sym_value (ebl, addr);
+}
diff --git a/libebl/libebl.h b/libebl/libebl.h
index 84c2f4cd..50d6baab 100644
--- a/libebl/libebl.h
+++ b/libebl/libebl.h
@@ -439,6 +439,12 @@ extern bool ebl_unwind (Ebl *ebl, Dwarf_Addr pc, ebl_tid_registers_t *setfunc,
bool *signal_framep)
__nonnull_attribute__ (1, 3, 4, 5, 7);
+/* Returns true if the value can be resolved to an address in an
+ allocated section, which will be returned in *ADDR
+ (e.g. function descriptor resolving) */
+extern bool ebl_resolve_sym_value (Ebl *ebl, GElf_Addr *addr)
+ __nonnull_attribute__ (2);
+
#ifdef __cplusplus
}
#endif
diff --git a/libebl/libeblP.h b/libebl/libeblP.h
index 4f4137d5..f91c2a0d 100644
--- a/libebl/libeblP.h
+++ b/libebl/libeblP.h
@@ -64,6 +64,11 @@ struct ebl
Ebl architecture can unwind iff FRAME_NREGS > 0. */
size_t frame_nregs;
+ /* Function descriptor load address and table as used by
+ ebl_resolve_sym_value if available for this arch. */
+ GElf_Addr fd_addr;
+ Elf_Data *fd_data;
+
/* Internal data. */
void *dlhandle;
};