mirror of
https://github.com/ianlancetaylor/libbacktrace.git
synced 2026-03-25 19:49:07 +08:00
libbacktrace: support FDPIC
Based on patch by Max Filippov. * internal.h: If FDPIC, #include <link.h> and/or <sys/link.h>. (libbacktrace_using_fdpic): Define. (struct libbacktrace_base_address): Define. (libbacktrace_add_base): Define. (backtrace_dwarf_add): Change base_address to struct libbacktrace_base_address. * dwarf.c (struct dwarf_data): Change base_address to struct libbacktrace_base_address. (add_ranges, find_address_ranges, build_ddress_map): Likewise. (build_dwarf_data, build_dwarf_add): Likewise. (add_low_high_range): Change base_address to struct libbacktrace_base_address. Use libbacktrace_add_base. (add_ranges_from_ranges, add_ranges_from_rnglists): Likewise. (add_line): Use libbacktrace_add_base. * elf.c (elf_initialize_syminfo): Change base_address to struct libbacktrace_base_address. Use libbacktrace_add_base. (elf_add): Change base_address to struct libbacktrace_base_address. (phdr_callback): Likewise. Initialize base_address.m. (backtrace_initialize): If using FDPIC, don't call elf_add with main executable; always use dl_iterate_phdr. * macho.c (macho_add_symtab): Change base_address to struct libbacktrace_base_address. Use libbacktrace_add_base. (macho_syminfo): Change base_address to struct libbacktrace_base_address. (macho_add_fat, macho_add_dsym, macho_add): Likewise. (backtrace_initialize): Likewise. Initialize base_address.m. * pecoff.c (coff_initialize_syminfo): Change base_address to struct libbacktrace_base_address. Use libbacktrace_add_base. (coff_add): Change base_address to struct libbacktrace_base_address. Initialize base_address.m.
This commit is contained in:
36
internal.h
36
internal.h
@@ -323,10 +323,44 @@ struct dwarf_sections
|
||||
|
||||
struct dwarf_data;
|
||||
|
||||
/* The load address mapping. */
|
||||
|
||||
#if defined(__FDPIC__) && defined(HAVE_DL_ITERATE_PHDR) && (defined(HAVE_LINK_H) || defined(HAVE_SYS_LINK_H))
|
||||
|
||||
#ifdef HAVE_LINK_H
|
||||
#include <link.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_LINK_H
|
||||
#include <sys/link.h>
|
||||
#endif
|
||||
|
||||
#define libbacktrace_using_fdpic() (1)
|
||||
|
||||
struct libbacktrace_base_address
|
||||
{
|
||||
struct elf32_fdpic_loadaddr m;
|
||||
};
|
||||
|
||||
#define libbacktrace_add_base(pc, base) \
|
||||
((uintptr_t) (__RELOC_POINTER ((pc), (base).m)))
|
||||
|
||||
#else /* not _FDPIC__ */
|
||||
|
||||
#define libbacktrace_using_fdpic() (0)
|
||||
|
||||
struct libbacktrace_base_address
|
||||
{
|
||||
uintptr_t m;
|
||||
};
|
||||
|
||||
#define libbacktrace_add_base(pc, base) ((pc) + (base).m)
|
||||
|
||||
#endif /* not _FDPIC__ */
|
||||
|
||||
/* Add file/line information for a DWARF module. */
|
||||
|
||||
extern int backtrace_dwarf_add (struct backtrace_state *state,
|
||||
uintptr_t base_address,
|
||||
struct libbacktrace_base_address base_address,
|
||||
const struct dwarf_sections *dwarf_sections,
|
||||
int is_bigendian,
|
||||
struct dwarf_data *fileline_altlink,
|
||||
|
||||
Reference in New Issue
Block a user