backtrace: The BFD API changed in newer versions
This commit is contained in:
@@ -1271,6 +1271,11 @@ if test x$bfd_backtraces = xtrue; then
|
|||||||
AC_CHECK_LIB([bfd],[bfd_init],[LIBS="$LIBS"],[AC_MSG_ERROR([binutils libbfd not found!])],[])
|
AC_CHECK_LIB([bfd],[bfd_init],[LIBS="$LIBS"],[AC_MSG_ERROR([binutils libbfd not found!])],[])
|
||||||
AC_CHECK_HEADER([bfd.h],[AC_DEFINE([HAVE_BFD_H],,[have binutils bfd.h])],
|
AC_CHECK_HEADER([bfd.h],[AC_DEFINE([HAVE_BFD_H],,[have binutils bfd.h])],
|
||||||
[AC_MSG_ERROR([binutils bfd.h header not found!])])
|
[AC_MSG_ERROR([binutils bfd.h header not found!])])
|
||||||
|
AC_CHECK_DECLS(
|
||||||
|
[bfd_section_flags, bfd_get_section_flags,
|
||||||
|
bfd_section_vma, bfd_get_section_vma,
|
||||||
|
bfd_section_size, bfd_get_section_size], [], [],
|
||||||
|
[[#include <bfd.h>]])
|
||||||
BFDLIB="-lbfd"
|
BFDLIB="-lbfd"
|
||||||
AC_SUBST(BFDLIB)
|
AC_SUBST(BFDLIB)
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -144,6 +144,32 @@ void backtrace_deinit()
|
|||||||
#include <collections/hashtable.h>
|
#include <collections/hashtable.h>
|
||||||
#include <threading/mutex.h>
|
#include <threading/mutex.h>
|
||||||
|
|
||||||
|
/* interface changes for newer BFD versions, note that older versions declared
|
||||||
|
* some of the new functions as macros but with different arguments */
|
||||||
|
#if HAVE_DECL_BFD_GET_SECTION_FLAGS
|
||||||
|
#define get_section_flags(a, s) bfd_get_section_flags(a, s)
|
||||||
|
#elif HAVE_DECL_BFD_SECTION_FLAGS
|
||||||
|
#define get_section_flags(a, s) bfd_section_flags(s)
|
||||||
|
#else
|
||||||
|
#error Unknown BFD API
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if HAVE_DECL_BFD_GET_SECTION_VMA
|
||||||
|
#define get_section_vma(a, s) bfd_get_section_vma(a, s)
|
||||||
|
#elif HAVE_DECL_BFD_SECTION_VMA
|
||||||
|
#define get_section_vma(a, s) bfd_section_vma(s)
|
||||||
|
#else
|
||||||
|
#error Unknown BFD API
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if HAVE_DECL_BFD_GET_SECTION_SIZE
|
||||||
|
#define get_section_size bfd_get_section_size
|
||||||
|
#elif HAVE_DECL_BFD_SECTION_SIZE
|
||||||
|
#define get_section_size bfd_section_size
|
||||||
|
#else
|
||||||
|
#error Unknown BFD API
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hashtable-cached bfd handle
|
* Hashtable-cached bfd handle
|
||||||
*/
|
*/
|
||||||
@@ -248,12 +274,12 @@ static void find_addr(bfd *abfd, asection *section, bfd_find_data_t *data)
|
|||||||
char fbuf[512] = "", sbuf[512] = "";
|
char fbuf[512] = "", sbuf[512] = "";
|
||||||
u_int line;
|
u_int line;
|
||||||
|
|
||||||
if (!data->found || (bfd_get_section_flags(abfd, section) & SEC_ALLOC) != 0)
|
if (!data->found || (get_section_flags(abfd, section) & SEC_ALLOC) != 0)
|
||||||
{
|
{
|
||||||
vma = bfd_get_section_vma(abfd, section);
|
vma = get_section_vma(abfd, section);
|
||||||
if (data->vma >= vma)
|
if (data->vma >= vma)
|
||||||
{
|
{
|
||||||
size = bfd_get_section_size(section);
|
size = get_section_size(section);
|
||||||
if (data->vma < vma + size)
|
if (data->vma < vma + size)
|
||||||
{
|
{
|
||||||
data->found = bfd_find_nearest_line(abfd, section,
|
data->found = bfd_find_nearest_line(abfd, section,
|
||||||
|
|||||||
Reference in New Issue
Block a user