bfd: Change num_group to unsigned int

Message ID 20200324115602.402141-1-hjl.tools@gmail.com
State New
Headers show
Series
  • bfd: Change num_group to unsigned int
Related show

Commit Message

H.J. Lu via Binutils March 24, 2020, 11:56 a.m.
elf.c failed with to with GCC 10 as of

commit 906b3eb9df6c577d3f6e9c3ea5c9d7e4d1e90536
Author: Martin Liska <mliska@suse.cz>
Date:   Tue Mar 24 11:40:10 2020 +0100

    Improve endianess detection.

            PR lto/94249
            * plugin-api.h: Add more robust endianess detection.

binutils-gdb/bfd/elf.c: In function ‘setup_group’:
binutils-gdb/bfd/elf.c:740:35: error: overflow in conversion from ‘unsigned int’ to ‘int’ changes value from ‘num_group = 4294967295’ to ‘-1’ [-Werror=overflow]
  740 |     elf_tdata (abfd)->num_group = num_group = -1;
      |                                   ^~~~~~~~~
cc1: all warnings being treated as errors
make[2]: *** [Makefile:1608: elf.lo] Error 1

Change num_group in elf_obj_tdata to unsigned int to compile with GCC 10.

	PR binutils/25717
	* elf-bfd.h (elf_obj_tdata): Change num_group to unsigned int.
---
 bfd/ChangeLog | 5 +++++
 bfd/elf-bfd.h | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

-- 
2.25.1

Comments

H.J. Lu via Binutils March 24, 2020, 12:09 p.m. | #1
On Tue, Mar 24, 2020 at 4:56 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>

> elf.c failed with to with GCC 10 as of

>

> commit 906b3eb9df6c577d3f6e9c3ea5c9d7e4d1e90536

> Author: Martin Liska <mliska@suse.cz>

> Date:   Tue Mar 24 11:40:10 2020 +0100

>

>     Improve endianess detection.

>

>             PR lto/94249

>             * plugin-api.h: Add more robust endianess detection.

>

> binutils-gdb/bfd/elf.c: In function ‘setup_group’:

> binutils-gdb/bfd/elf.c:740:35: error: overflow in conversion from ‘unsigned int’ to ‘int’ changes value from ‘num_group = 4294967295’ to ‘-1’ [-Werror=overflow]

>   740 |     elf_tdata (abfd)->num_group = num_group = -1;

>       |                                   ^~~~~~~~~

> cc1: all warnings being treated as errors

> make[2]: *** [Makefile:1608: elf.lo] Error 1

>

> Change num_group in elf_obj_tdata to unsigned int to compile with GCC 10.

>

>         PR binutils/25717

>         * elf-bfd.h (elf_obj_tdata): Change num_group to unsigned int.

> ---

>  bfd/ChangeLog | 5 +++++

>  bfd/elf-bfd.h | 2 +-

>  2 files changed, 6 insertions(+), 1 deletion(-)

>

> diff --git a/bfd/ChangeLog b/bfd/ChangeLog

> index 7cc34c1bb9..8ec3782d9f 100644

> --- a/bfd/ChangeLog

> +++ b/bfd/ChangeLog

> @@ -1,3 +1,8 @@

> +2020-03-24  H.J. Lu  <hongjiu.lu@intel.com>

> +

> +       PR binutils/25717

> +       * elf-bfd.h (elf_obj_tdata): Change num_group to unsigned int.

> +

>  2020-03-24  H.J. Lu  <hongjiu.lu@intel.com>

>

>         PR binutils/25708

> diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h

> index c546b583b8..5f3a5cc04b 100644

> --- a/bfd/elf-bfd.h

> +++ b/bfd/elf-bfd.h

> @@ -1953,7 +1953,7 @@ struct elf_obj_tdata

>    struct sdt_note *sdt_note_head;

>

>    Elf_Internal_Shdr **group_sect_ptr;

> -  int num_group;

> +  unsigned int num_group;

>

>    /* Index into group_sect_ptr, updated by setup_group when finding a

>       section's group.  Used to optimize subsequent group searches.  */

> --

> 2.25.1

>


Hi Nick,

I'd like to backport it to 2.34 branch.

-- 
H.J.
H.J. Lu via Binutils March 24, 2020, 12:35 p.m. | #2
On Tue, Mar 24, 2020 at 04:56:02AM -0700, H.J. Lu via Binutils wrote:
> 	PR binutils/25717

> 	* elf-bfd.h (elf_obj_tdata): Change num_group to unsigned int.


OK, obvious even.

-- 
Alan Modra
Australia Development Lab, IBM
H.J. Lu via Binutils March 24, 2020, 3:20 p.m. | #3
Hi H.J.

>>             PR lto/94249

>>             * plugin-api.h: Add more robust endianess detection.


>>         PR binutils/25717

>>         * elf-bfd.h (elf_obj_tdata): Change num_group to unsigned int.



> I'd like to backport it to 2.34 branch.


Sure - please go ahead.

Cheers
  Nick

Patch

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 7cc34c1bb9..8ec3782d9f 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,8 @@ 
+2020-03-24  H.J. Lu  <hongjiu.lu@intel.com>
+
+	PR binutils/25717
+	* elf-bfd.h (elf_obj_tdata): Change num_group to unsigned int.
+
 2020-03-24  H.J. Lu  <hongjiu.lu@intel.com>
 
 	PR binutils/25708
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index c546b583b8..5f3a5cc04b 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -1953,7 +1953,7 @@  struct elf_obj_tdata
   struct sdt_note *sdt_note_head;
 
   Elf_Internal_Shdr **group_sect_ptr;
-  int num_group;
+  unsigned int num_group;
 
   /* Index into group_sect_ptr, updated by setup_group when finding a
      section's group.  Used to optimize subsequent group searches.  */