2020-01-28 15:31:16

by Changbin Du

[permalink] [raw]
Subject: [PATCH] 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.

Signed-off-by: Changbin Du <[email protected]>
---
tools/perf/util/srcline.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/srcline.c b/tools/perf/util/srcline.c
index 6ccf6f6d09df..5b7d6c16d33f 100644
--- a/tools/perf/util/srcline.c
+++ b/tools/perf/util/srcline.c
@@ -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;
--
2.24.0


2020-01-29 07:59:47

by Jiri Olsa

[permalink] [raw]
Subject: Re: [PATCH] perf: Make perf able to build with latest libbfd

On Tue, Jan 28, 2020 at 11:29:38PM +0800, Changbin Du wrote:
> 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.
>
> Signed-off-by: Changbin Du <[email protected]>

Acked-by: Jiri Olsa <[email protected]>

thanks,
jirka


> ---
> tools/perf/util/srcline.c | 16 +++++++++++++++-
> 1 file changed, 15 insertions(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/srcline.c b/tools/perf/util/srcline.c
> index 6ccf6f6d09df..5b7d6c16d33f 100644
> --- a/tools/perf/util/srcline.c
> +++ b/tools/perf/util/srcline.c
> @@ -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;
> --
> 2.24.0
>

2020-01-30 10:56:58

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: Re: [PATCH] perf: Make perf able to build with latest libbfd

Em Wed, Jan 29, 2020 at 08:58:29AM +0100, Jiri Olsa escreveu:
> On Tue, Jan 28, 2020 at 11:29:38PM +0800, Changbin Du wrote:
> > 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.
> >
> > Signed-off-by: Changbin Du <[email protected]>
>
> Acked-by: Jiri Olsa <[email protected]>

Thanks, applied.

- Arnaldo

> thanks,
> jirka
>
>
> > ---
> > tools/perf/util/srcline.c | 16 +++++++++++++++-
> > 1 file changed, 15 insertions(+), 1 deletion(-)
> >
> > diff --git a/tools/perf/util/srcline.c b/tools/perf/util/srcline.c
> > index 6ccf6f6d09df..5b7d6c16d33f 100644
> > --- a/tools/perf/util/srcline.c
> > +++ b/tools/perf/util/srcline.c
> > @@ -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;
> > --
> > 2.24.0
> >
>

--

- Arnaldo

Subject: [tip: perf/urgent] perf: Make perf able to build with latest libbfd

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.

Signed-off-by: Changbin Du <[email protected]>
Acked-by: Jiri Olsa <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lore.kernel.org/lkml/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/util/srcline.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/srcline.c b/tools/perf/util/srcline.c
index 6ccf6f6..5b7d6c1 100644
--- a/tools/perf/util/srcline.c
+++ b/tools/perf/util/srcline.c
@@ -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;

2020-02-16 23:25:43

by Stephen Rothwell

[permalink] [raw]
Subject: Re: [PATCH] perf: Make perf able to build with latest libbfd

Hi Arnaldo,

On Thu, 30 Jan 2020 11:55:48 +0100 Arnaldo Carvalho de Melo <[email protected]> wrote:
>
> Em Wed, Jan 29, 2020 at 08:58:29AM +0100, Jiri Olsa escreveu:
> > On Tue, Jan 28, 2020 at 11:29:38PM +0800, Changbin Du wrote:
> > > 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.
> > >
> > > Signed-off-by: Changbin Du <[email protected]>
> >
> > Acked-by: Jiri Olsa <[email protected]>
>
> Thanks, applied.

Just wondering if this should have been cc'd to stable?
--
Cheers,
Stephen Rothwell


Attachments:
(No filename) (499.00 B)
OpenPGP digital signature

2020-05-01 00:22:19

by Joel Stanley

[permalink] [raw]
Subject: Re: [PATCH] perf: Make perf able to build with latest libbfd

On Sun, 16 Feb 2020 at 23:25, Stephen Rothwell <[email protected]> wrote:
>
> Hi Arnaldo,
>
> On Thu, 30 Jan 2020 11:55:48 +0100 Arnaldo Carvalho de Melo <[email protected]> wrote:
> >
> > Em Wed, Jan 29, 2020 at 08:58:29AM +0100, Jiri Olsa escreveu:
> > > On Tue, Jan 28, 2020 at 11:29:38PM +0800, Changbin Du wrote:
> > > > 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.
> > > >
> > > > Signed-off-by: Changbin Du <[email protected]>
> > >
> > > Acked-by: Jiri Olsa <[email protected]>
> >
> > Thanks, applied.
>
> Just wondering if this should have been cc'd to stable?

Yes please. We hit this today.

Cheers,

Joel

2020-05-31 01:57:19

by Marek Vasut

[permalink] [raw]
Subject: Re: [PATCH] perf: Make perf able to build with latest libbfd

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

2020-06-01 16:52:50

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] perf: Make perf able to build with latest libbfd

On Sun, May 31, 2020 at 03:50:25AM +0200, Marek Vasut wrote:
> 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

2020-07-16 12:02:14

by Greg KH

[permalink] [raw]
Subject: Re: [PATCH] perf: Make perf able to build with latest libbfd

On Thu, Jul 16, 2020 at 10:07:15AM +0800, Jianmin Wang wrote:
> 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