Fix GCC9 warning on elf32-arm.c:elf32_arm_final_link_relocate

Message ID 20190121204113.22669-1-sergiodj@redhat.com
State New
Headers show
Series
  • Fix GCC9 warning on elf32-arm.c:elf32_arm_final_link_relocate
Related show

Commit Message

Sergio Durigan Junior Jan. 21, 2019, 8:41 p.m.
Fedora Rawhide has just switched to GCC9, and now GDB doesn't compile
because of a BFD warning:

  BUILDSTDERR: ../../bfd/elf32-arm.c: In function 'elf32_arm_final_link_relocate':
  BUILDSTDERR: ../../bfd/elf32-arm.c:10907:10: error: absolute value function 'labs' given an argument of type 'bfd_signed_vma' {aka 'long long int'} but has parameter of type 'long int' which may cause truncation of value [-Werror=absolute-value]
  BUILDSTDERR: 10907 |  value = labs (relocation);
  BUILDSTDERR:       |          ^~~~

You can take a look at the full build log here:

  https://kojipkgs.fedoraproject.org//work/tasks/4828/32174828/build.log

The fix is (apparently) simple: instead of using 'labs', we should use
'llabs', since we're passing a 'bfd_signed_vma' to it, which is at
least a 'long long int', as far as I have checked.  This is what this
patch does.

OK to apply?
---
 bfd/ChangeLog   | 5 +++++
 bfd/elf32-arm.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

-- 
2.17.2

Comments

Sergio Durigan Junior Jan. 28, 2019, 2:57 a.m. | #1
Ping.

On Monday, January 21 2019, I wrote:

> Fedora Rawhide has just switched to GCC9, and now GDB doesn't compile

> because of a BFD warning:

>

>   BUILDSTDERR: ../../bfd/elf32-arm.c: In function 'elf32_arm_final_link_relocate':

>   BUILDSTDERR: ../../bfd/elf32-arm.c:10907:10: error: absolute value function 'labs' given an argument of type 'bfd_signed_vma' {aka 'long long int'} but has parameter of type 'long int' which may cause truncation of value [-Werror=absolute-value]

>   BUILDSTDERR: 10907 |  value = labs (relocation);

>   BUILDSTDERR:       |          ^~~~

>

> You can take a look at the full build log here:

>

>   https://kojipkgs.fedoraproject.org//work/tasks/4828/32174828/build.log

>

> The fix is (apparently) simple: instead of using 'labs', we should use

> 'llabs', since we're passing a 'bfd_signed_vma' to it, which is at

> least a 'long long int', as far as I have checked.  This is what this

> patch does.

>

> OK to apply?

> ---

>  bfd/ChangeLog   | 5 +++++

>  bfd/elf32-arm.c | 2 +-

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

>

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

> index 717999968a..d3fcd83ea6 100644

> --- a/bfd/ChangeLog

> +++ b/bfd/ChangeLog

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

> +2019-01-21  Sergio Durigan Junior  <sergiodj@redhat.com>

> +

> +	* elf32-arm.c (elf32_arm_final_link_relocate): Use 'llabs' instead

> +	of 'labs' (and fix GCC warning).

> +

>  2019-01-21  Nick Clifton  <nickc@redhat.com>

>  

>  	* po/pt.po: Updated Portuguese translation.

> diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c

> index 53baea269b..28ee9d55a8 100644

> --- a/bfd/elf32-arm.c

> +++ b/bfd/elf32-arm.c

> @@ -10904,7 +10904,7 @@ elf32_arm_final_link_relocate (reloc_howto_type *	    howto,

>  

>  	/* PR 21523: Use an absolute value.  The user of this reloc will

>  	   have already selected an ADD or SUB insn appropriately.  */

> -	value = labs (relocation);

> +	value = llabs (relocation);

>  

>  	if (value >= 0x1000)

>  	  return bfd_reloc_overflow;

> -- 

> 2.17.2


-- 
Sergio
GPG key ID: 237A 54B1 0287 28BF 00EF  31F4 D0EB 7628 65FC 5E36
Please send encrypted e-mail if possible
http://sergiodj.net/
Nick Clifton Jan. 28, 2019, 12:41 p.m. | #2
Hi Sergio,

> Ping.


Sorry - I meant to reply last week, but got distracted.

>> The fix is (apparently) simple: instead of using 'labs', we should use

>> 'llabs', since we're passing a 'bfd_signed_vma' to it, which is at

>> least a 'long long int', as far as I have checked.  This is what this

>> patch does.

>>

>> OK to apply?


Yes - approved - please apply.

Cheers
  Nick
Sergio Durigan Junior Jan. 28, 2019, 3:52 p.m. | #3
On Monday, January 28 2019, Nick Clifton wrote:

> Hi Sergio,

>

>> Ping.

>

> Sorry - I meant to reply last week, but got distracted.


No problem.

>>> The fix is (apparently) simple: instead of using 'labs', we should use

>>> 'llabs', since we're passing a 'bfd_signed_vma' to it, which is at

>>> least a 'long long int', as far as I have checked.  This is what this

>>> patch does.

>>>

>>> OK to apply?

>

> Yes - approved - please apply.


Thanks, pushed.

453f8e1e4918171bc12e4d03aab7ee8360dfcfef

-- 
Sergio
GPG key ID: 237A 54B1 0287 28BF 00EF  31F4 D0EB 7628 65FC 5E36
Please send encrypted e-mail if possible
http://sergiodj.net/

Patch

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 717999968a..d3fcd83ea6 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,8 @@ 
+2019-01-21  Sergio Durigan Junior  <sergiodj@redhat.com>
+
+	* elf32-arm.c (elf32_arm_final_link_relocate): Use 'llabs' instead
+	of 'labs' (and fix GCC warning).
+
 2019-01-21  Nick Clifton  <nickc@redhat.com>
 
 	* po/pt.po: Updated Portuguese translation.
diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index 53baea269b..28ee9d55a8 100644
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -10904,7 +10904,7 @@  elf32_arm_final_link_relocate (reloc_howto_type *	    howto,
 
 	/* PR 21523: Use an absolute value.  The user of this reloc will
 	   have already selected an ADD or SUB insn appropriately.  */
-	value = labs (relocation);
+	value = llabs (relocation);
 
 	if (value >= 0x1000)
 	  return bfd_reloc_overflow;