diff options
author | Tim-Philipp Müller <tim@centricular.com> | 2021-02-23 11:36:24 +0000 |
---|---|---|
committer | Tim-Philipp Müller <tim@centricular.com> | 2021-02-23 12:29:58 +0000 |
commit | e30259f6237571c61992433c110bc6e1ef900244 (patch) | |
tree | fe0cb239f38091c71be79822d675297bbadb6b6e | |
parent | d6c1787ac1a705f129f3d56b6058f02129535796 (diff) | |
download | cairo-e30259f6237571c61992433c110bc6e1ef900244.tar.gz |
cairo-trace: fix build with newer versions of bfd
And update configure/meson checks to check for the new function.
Drop libiberty.h check since it's only needed by backtrace-symbols.c
which we're about to remove.
Closes #391, #460
-rw-r--r-- | Makefile.am | 1 | ||||
-rw-r--r-- | configure.ac | 8 | ||||
-rw-r--r-- | meson-cc-tests/bfd-section-flags.c | 9 | ||||
-rw-r--r-- | meson.build | 11 | ||||
-rw-r--r-- | util/cairo-trace/lookup-symbol.c | 7 |
5 files changed, 26 insertions, 10 deletions
diff --git a/Makefile.am b/Makefile.am index 2caa7352f..1b7c59bf0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -71,6 +71,7 @@ EXTRA_DIST += \ util/cairo-trace/meson.build \ util/meson.build \ meson-cc-tests/atomic-ops-cxx11.c \ + meson-cc-tests/bfd-section-flags.c \ meson-cc-tests/ipc_rmid_deferred_release.c \ meson-cc-tests/ft_has_color.c \ meson-cc-tests/mkdir-variant-1.c \ diff --git a/configure.ac b/configure.ac index 18e4a305f..6444a3da3 100644 --- a/configure.ac +++ b/configure.ac @@ -826,7 +826,13 @@ CAIRO_ENABLE(interpreter, cairo-script-interpreter, yes, [ AC_CHECK_LIB(bfd, bfd_openr, [AC_CHECK_HEADER(bfd.h, [have_bfd=yes], [have_bfd=no])], [have_bfd=no]) -AC_CHECK_HEADER(libiberty.h,, [have_bfd=no]) +dnl bfd_section_flags is an inline func so we don't bother with linking the lib in +AC_LINK_IFELSE([AC_LANG_PROGRAM([ + #include <bfd.h> + asection *s; +],[ + return bfd_section_flags(s) == 0; +])],[],[have_bfd=no]) if test "x$have_bfd" = "xyes"; then AC_DEFINE([HAVE_BFD], [1], [Define to 1 if you have the binutils development files installed]) BFD_LIBS=-lbfd diff --git a/meson-cc-tests/bfd-section-flags.c b/meson-cc-tests/bfd-section-flags.c new file mode 100644 index 000000000..b58118d06 --- /dev/null +++ b/meson-cc-tests/bfd-section-flags.c @@ -0,0 +1,9 @@ +#include <bfd.h> + +int +f (asection *s) +{ + return bfd_section_flags(s) == 0; +} + +int main (void) { return 0; } diff --git a/meson.build b/meson.build index 5cbeda913..52945db52 100644 --- a/meson.build +++ b/meson.build @@ -673,15 +673,16 @@ if zlib_dep.found() and png_dep.found() }] endif -# Untested, libiberty.h is in a libiberty subfolder for me -# Also, the bfd API seems to have changed at some point -bfd_dep = cc.find_library('bfd', has_headers: ['bfd.h', 'libiberty.h'], required: get_option('symbol-lookup')) -if bfd_dep.found() and cc.has_function('bfd_openr', dependencies: [bfd_dep]) +bfd_dep = cc.find_library('bfd', has_headers: ['bfd.h'], required: get_option('symbol-lookup')) +if bfd_dep.found() and \ + cc.has_function('bfd_openr', dependencies: [bfd_dep]) and \ + cc.links(files('meson-cc-tests/bfd-section-flags.c'), name: 'bfd_section_flags', dependencies: bfd_dep) conf.set('HAVE_BFD', 1) deps += [bfd_dep] +elif get_option('symbol-lookup').enabled() + error('symbol lookup via bfd was enabled via options but is not available (bfd might be too old)') endif -# Untested, see above if conf.get('HAVE_BFD', 0) == 1 conf.set('CAIRO_HAS_SYMBOL_LOOKUP', 1) endif diff --git a/util/cairo-trace/lookup-symbol.c b/util/cairo-trace/lookup-symbol.c index f9665b36f..9af0b5944 100644 --- a/util/cairo-trace/lookup-symbol.c +++ b/util/cairo-trace/lookup-symbol.c @@ -65,7 +65,6 @@ #if HAVE_BFD #include <bfd.h> -#include <libiberty.h> struct symtab { bfd *bfd; @@ -145,14 +144,14 @@ find_address_in_section (bfd *abfd, if (symbol->found) return; - if ((bfd_get_section_flags (symtab->bfd, section) & SEC_ALLOC) == 0) + if ((bfd_section_flags (section) & SEC_ALLOC) == 0) return; - vma = bfd_get_section_vma (symtab->bfd, section); + vma = bfd_section_vma (section); if (symbol->pc < vma) return; - size = bfd_section_size (symtab->bfd, section); + size = bfd_section_size (section); if (symbol->pc >= vma + size) return; |