blob: e0e7b85834cf5048dd14f20490081925e862e17f [file] [log] [blame]
Andrew Geissler062316f2020-05-15 14:19:14 -05001From e66a0be4fac135d67ab228a6fd1453b9e36a3644 Mon Sep 17 00:00:00 2001
2From: Changbin Du <changbin.du@gmail.com>
3Date: Tue, 28 Jan 2020 23:29:38 +0800
4Subject: [PATCH] perf: Make perf able to build with latest libbfd
5
6libbfd has changed the bfd_section_* macros to inline functions
7bfd_section_<field> since 2019-09-18. See below two commits:
8 o http://www.sourceware.org/ml/gdb-cvs/2019-09/msg00064.html
9 o https://www.sourceware.org/ml/gdb-cvs/2019-09/msg00072.html
10
11This fix make perf able to build with both old and new libbfd.
12
13Signed-off-by: Changbin Du <changbin.du@gmail.com>
14Acked-by: Jiri Olsa <jolsa@redhat.com>
15Cc: Peter Zijlstra <peterz@infradead.org>
16Link: http://lore.kernel.org/lkml/20200128152938.31413-1-changbin.du@gmail.com
17Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
18---
19 tools/perf/util/srcline.c | 16 +++++++++++++++-
20 1 file changed, 15 insertions(+), 1 deletion(-)
21
22diff --git a/tools/perf/util/srcline.c b/tools/perf/util/srcline.c
23index af3f9b9f1e8b..b8e77617fdc4 100644
24--- a/tools/perf/util/srcline.c
25+++ b/tools/perf/util/srcline.c
26@@ -191,16 +191,30 @@ static void find_address_in_section(bfd *abfd, asection *section, void *data)
27 bfd_vma pc, vma;
28 bfd_size_type size;
29 struct a2l_data *a2l = data;
30+ flagword flags;
31
32 if (a2l->found)
33 return;
34
35- if ((bfd_get_section_flags(abfd, section) & SEC_ALLOC) == 0)
36+#ifdef bfd_get_section_flags
37+ flags = bfd_get_section_flags(abfd, section);
38+#else
39+ flags = bfd_section_flags(section);
40+#endif
41+ if ((flags & SEC_ALLOC) == 0)
42 return;
43
44 pc = a2l->addr;
45+#ifdef bfd_get_section_vma
46 vma = bfd_get_section_vma(abfd, section);
47+#else
48+ vma = bfd_section_vma(section);
49+#endif
50+#ifdef bfd_get_section_size
51 size = bfd_get_section_size(section);
52+#else
53+ size = bfd_section_size(section);
54+#endif
55
56 if (pc < vma || pc >= vma + size)
57 return;