Skip to contentSkip to conversation

perf: Make perf able to build with latest libbfd

PATCH Applied Changbin Du 8 participants 9 messages Jan 28, 2020 – Jul 16, 2020 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf: Make perf able to build with latest libbfd

libbfd has changed the bfd_section_* macros to inline functions bfd_section_<field> since 2019-09-18. See below two commits:
o http://www.sourceware.org/ml/gdb-cvs/2019-09/msg00064.html
o https://www.sourceware.org/ml/gdb-cvs/2019-09/msg00072.html

This fix make perf able to build with both old and new libbfd.

---
 tools/perf/util/srcline.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
tools/perf/util/srcline.c +15 -1
index 6ccf6f6d09df..5b7d6c16d33f 100644
@@ -193,16 +193,30 @@ static void find_address_in_section(bfd *abfd, asection *section, void *data)
 	bfd_vma pc, vma;
 	bfd_size_type size;
 	struct a2l_data *a2l = data;
+	flagword flags;
 
 	if (a2l->found)
 		return;
 
-	if ((bfd_get_section_flags(abfd, section) & SEC_ALLOC) == 0)
+#ifdef bfd_get_section_flags
+	flags = bfd_get_section_flags(abfd, section);
+#else
+	flags = bfd_section_flags(section);
+#endif
+	if ((flags & SEC_ALLOC) == 0)
 		return;
 
 	pc = a2l->addr;
+#ifdef bfd_get_section_vma
 	vma = bfd_get_section_vma(abfd, section);
+#else
+	vma = bfd_section_vma(section);
+#endif
+#ifdef bfd_get_section_size
 	size = bfd_get_section_size(section);
+#else
+	size = bfd_section_size(section);
+#endif
 
 	if (pc < vma || pc >= vma + size)
 		return;
Signature · 1 line
2.24.0
Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Changbin Du

libbfd has changed the bfd_section_* macros to inline functions bfd_section_<field> since 2019-09-18. See below two commits:
o http://www.sourceware.org/ml/gdb-cvs/2019-09/msg00064.html
o https://www.sourceware.org/ml/gdb-cvs/2019-09/msg00072.html

This fix make perf able to build with both old and new libbfd.

thanks,
jirka

Quoted 43 lines
---
 tools/perf/util/srcline.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
tools/perf/util/srcline.c +15 -1
index 6ccf6f6d09df..5b7d6c16d33f 100644
@@ -193,16 +193,30 @@ static void find_address_in_section(bfd *abfd, asection *section, void *data)
 	bfd_vma pc, vma;
 	bfd_size_type size;
 	struct a2l_data *a2l = data;
+	flagword flags;
 
 	if (a2l->found)
 		return;
 
-	if ((bfd_get_section_flags(abfd, section) & SEC_ALLOC) == 0)
+#ifdef bfd_get_section_flags
+	flags = bfd_get_section_flags(abfd, section);
+#else
+	flags = bfd_section_flags(section);
+#endif
+	if ((flags & SEC_ALLOC) == 0)
 		return;
 
 	pc = a2l->addr;
+#ifdef bfd_get_section_vma
 	vma = bfd_get_section_vma(abfd, section);
+#else
+	vma = bfd_section_vma(section);
+#endif
+#ifdef bfd_get_section_size
 	size = bfd_get_section_size(section);
+#else
+	size = bfd_section_size(section);
+#endif
 
 	if (pc < vma || pc >= vma + size)
 		return;
Signature · 1 line
2.24.0
#2 lore raw

Em Wed, Jan 29, 2020 at 08:58:29AM +0100, Jiri Olsa escreveu:

Quoted 11 lines · Changbin Du
Quoted 8 lines

libbfd has changed the bfd_section_* macros to inline functions bfd_section_<field> since 2019-09-18. See below two commits:
o http://www.sourceware.org/ml/gdb-cvs/2019-09/msg00064.html
o https://www.sourceware.org/ml/gdb-cvs/2019-09/msg00072.html

This fix make perf able to build with both old and new libbfd.

Thanks, applied.

- Arnaldo

Quoted 48 lines

thanks,
jirka

Quoted 43 lines
---
 tools/perf/util/srcline.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
tools/perf/util/srcline.c +15 -1
index 6ccf6f6d09df..5b7d6c16d33f 100644
@@ -193,16 +193,30 @@ static void find_address_in_section(bfd *abfd, asection *section, void *data)
 	bfd_vma pc, vma;
 	bfd_size_type size;
 	struct a2l_data *a2l = data;
+	flagword flags;
 
 	if (a2l->found)
 		return;
 
-	if ((bfd_get_section_flags(abfd, section) & SEC_ALLOC) == 0)
+#ifdef bfd_get_section_flags
+	flags = bfd_get_section_flags(abfd, section);
+#else
+	flags = bfd_section_flags(section);
+#endif
+	if ((flags & SEC_ALLOC) == 0)
 		return;
 
 	pc = a2l->addr;
+#ifdef bfd_get_section_vma
 	vma = bfd_get_section_vma(abfd, section);
+#else
+	vma = bfd_section_vma(section);
+#endif
+#ifdef bfd_get_section_size
 	size = bfd_get_section_size(section);
+#else
+	size = bfd_section_size(section);
+#endif
 
 	if (pc < vma || pc >= vma + size)
 		return;
Signature · 1 line
2.24.0
Signature · 1 line
- Arnaldo
#3 lore raw

Hi Arnaldo,

Quoted 8 lines · On Thu, 30 Jan 2020 11:55:48 +0100 Arnaldo Carvalho de Melo…

Em Wed, Jan 29, 2020 at 08:58:29AM +0100, Jiri Olsa escreveu:

Quoted 6 lines · Changbin Du
Quoted 5 lines

libbfd has changed the bfd_section_* macros to inline functions bfd_section_<field> since 2019-09-18. See below two commits:
o http://www.sourceware.org/ml/gdb-cvs/2019-09/msg00064.html
o https://www.sourceware.org/ml/gdb-cvs/2019-09/msg00072.html

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

This fix make perf able to build with both old and new libbfd.

Thanks, applied.

Just wondering if this should have been cc'd to stable?

Signature · 2 lines
Cheers,
Stephen Rothwell
#4 lore raw
Quoted 14 lines · Stephen Rothwell

Hi Arnaldo,

Quoted 10 lines · On Thu, 30 Jan 2020 11:55:48 +0100 Arnaldo Carvalho de Melo…

Em Wed, Jan 29, 2020 at 08:58:29AM +0100, Jiri Olsa escreveu:

Quoted 8 lines · Changbin Du
Quoted 7 lines

libbfd has changed the bfd_section_* macros to inline functions bfd_section_<field> since 2019-09-18. See below two commits:
o http://www.sourceware.org/ml/gdb-cvs/2019-09/msg00064.html
o https://www.sourceware.org/ml/gdb-cvs/2019-09/msg00072.html

This fix make perf able to build with both old and new libbfd.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Thanks, applied.

Just wondering if this should have been cc'd to stable?

Yes please. We hit this today.

Cheers,

Joel

merge bot Applied
#5 lore raw
In reply to Changbin Du
The following commit has been merged into the perf/urgent branch of tip:

The following commit has been merged into the perf/urgent branch of tip:

Commit-ID:     0ada120c883d4f1f6aafd01cf0fbb10d8bbba015
Gitweb:        https://git.kernel.org/tip/0ada120c883d4f1f6aafd01cf0fbb10d8bbba015
Author:        Changbin Du <[email protected]>
AuthorDate:    Tue, 28 Jan 2020 23:29:38 +08:00
Committer:     Arnaldo Carvalho de Melo <[email protected]>
CommitterDate: Thu, 30 Jan 2020 11:55:26 +01:00

perf: Make perf able to build with latest libbfd

libbfd has changed the bfd_section_* macros to inline functions bfd_section_<field> since 2019-09-18. See below two commits:
o http://www.sourceware.org/ml/gdb-cvs/2019-09/msg00064.html
o https://www.sourceware.org/ml/gdb-cvs/2019-09/msg00072.html

This fix make perf able to build with both old and new libbfd.

---
 tools/perf/util/srcline.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
tools/perf/util/srcline.c +15 -1
index 6ccf6f6..5b7d6c1 100644
@@ -193,16 +193,30 @@ static void find_address_in_section(bfd *abfd, asection *section, void *data)
 	bfd_vma pc, vma;
 	bfd_size_type size;
 	struct a2l_data *a2l = data;
+	flagword flags;
 
 	if (a2l->found)
 		return;
 
-	if ((bfd_get_section_flags(abfd, section) & SEC_ALLOC) == 0)
+#ifdef bfd_get_section_flags
+	flags = bfd_get_section_flags(abfd, section);
+#else
+	flags = bfd_section_flags(section);
+#endif
+	if ((flags & SEC_ALLOC) == 0)
 		return;
 
 	pc = a2l->addr;
+#ifdef bfd_get_section_vma
 	vma = bfd_get_section_vma(abfd, section);
+#else
+	vma = bfd_section_vma(section);
+#endif
+#ifdef bfd_get_section_size
 	size = bfd_get_section_size(section);
+#else
+	size = bfd_section_size(section);
+#endif
 
 	if (pc < vma || pc >= vma + size)
 		return;
#6 lore raw
In reply to Changbin Du

Hi,

since commit
0ada120c883d ("perf: Make perf able to build with latest libbfd") is in master, can it be backported to stable as well? I keep hitting this with too new binutils on Linux 5.4.y and I have to keep cherry-picking this commit to fix it.

Thanks

#7 lore raw
Quoted 7 lines · Marek Vasut

Hi,

since commit
0ada120c883d ("perf: Make perf able to build with latest libbfd") is in master, can it be backported to stable as well? I keep hitting this with too new binutils on Linux 5.4.y and I have to keep cherry-picking this commit to fix it.

Now applied, thanks.

greg k-h

A message that is not in the archive (sent off-list or not yet received): [email protected]

#9 lore raw
Quoted 8 lines · Jianmin Wang

Hi, Greg KH,

There is the same problem found on Linux 4.19.y, while compiling linux 4.19.y with binutils 2.34.

Can the follow commit be backported to stable branch 4.19.y as well?

Commit id: 0ada120c883d ("perf: Make perf able to build with latest libbfd")

Now queued up, thanks.

greg k-h