Fix SPARC64 handling of R_SPARC_H34 (bug 24231)

Message ID alpine.DEB.2.21.1902181840540.12080@digraph.polyomino.org.uk
State Committed
Headers

Commit Message

Joseph Myers Feb. 18, 2019, 6:41 p.m. UTC
  Building glibc with -Wextra shows a -Wimplicit-fallthrough warning for
SPARC64 that appears to be a real bug in glibc.  The dynamic linker
handling of R_SPARC_H34 falls through to that of R_SPARC_H44, which in
the case of this code is nonsensical (it means the value computed for
R_SPARC_H34 gets overwritten by one computed with the different logic
for R_SPARC_H44).  Thus, this patch adds the missing break there.
Note: I do not have a testcase to demonstrate this bug.

Tested with build-many-glibcs.py.

2019-02-18  Joseph Myers  <joseph@codesourcery.com>

	[BZ #24231]
	* sysdeps/sparc/sparc64/dl-machine.h (elf_machine_rela): Add break
	after R_SPARC_H34 case.
  

Comments

Adhemerval Zanella Feb. 18, 2019, 8:18 p.m. UTC | #1
On 18/02/2019 15:41, Joseph Myers wrote:
> Building glibc with -Wextra shows a -Wimplicit-fallthrough warning for
> SPARC64 that appears to be a real bug in glibc.  The dynamic linker
> handling of R_SPARC_H34 falls through to that of R_SPARC_H44, which in
> the case of this code is nonsensical (it means the value computed for
> R_SPARC_H34 gets overwritten by one computed with the different logic
> for R_SPARC_H44).  Thus, this patch adds the missing break there.
> Note: I do not have a testcase to demonstrate this bug.
> 
> Tested with build-many-glibcs.py.

Look obvious enough to me.

> 
> 2019-02-18  Joseph Myers  <joseph@codesourcery.com>
> 
> 	[BZ #24231]
> 	* sysdeps/sparc/sparc64/dl-machine.h (elf_machine_rela): Add break
> 	after R_SPARC_H34 case.
> 
> diff --git a/sysdeps/sparc/sparc64/dl-machine.h b/sysdeps/sparc/sparc64/dl-machine.h
> index 2fb207dc2d..14930890e3 100644
> --- a/sysdeps/sparc/sparc64/dl-machine.h
> +++ b/sysdeps/sparc/sparc64/dl-machine.h
> @@ -573,6 +573,7 @@ elf_machine_rela (struct link_map *map, const Elf64_Rela *reloc,
>        *(unsigned int *) reloc_addr =
>  	((*(unsigned int *)reloc_addr & 0xffc00000) |
>  	 ((value >> 12) & 0x3fffff));
> +      break;
>  
>        /* MEDMID code model relocs */
>      case R_SPARC_H44:
>
  
David Miller Feb. 19, 2019, 1:51 a.m. UTC | #2
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Mon, 18 Feb 2019 17:18:24 -0300

> 
> 
> On 18/02/2019 15:41, Joseph Myers wrote:
>> Building glibc with -Wextra shows a -Wimplicit-fallthrough warning for
>> SPARC64 that appears to be a real bug in glibc.  The dynamic linker
>> handling of R_SPARC_H34 falls through to that of R_SPARC_H44, which in
>> the case of this code is nonsensical (it means the value computed for
>> R_SPARC_H34 gets overwritten by one computed with the different logic
>> for R_SPARC_H44).  Thus, this patch adds the missing break there.
>> Note: I do not have a testcase to demonstrate this bug.
>> 
>> Tested with build-many-glibcs.py.
> 
> Look obvious enough to me.

Looks good here too.
  

Patch

diff --git a/sysdeps/sparc/sparc64/dl-machine.h b/sysdeps/sparc/sparc64/dl-machine.h
index 2fb207dc2d..14930890e3 100644
--- a/sysdeps/sparc/sparc64/dl-machine.h
+++ b/sysdeps/sparc/sparc64/dl-machine.h
@@ -573,6 +573,7 @@  elf_machine_rela (struct link_map *map, const Elf64_Rela *reloc,
       *(unsigned int *) reloc_addr =
 	((*(unsigned int *)reloc_addr & 0xffc00000) |
 	 ((value >> 12) & 0x3fffff));
+      break;
 
       /* MEDMID code model relocs */
     case R_SPARC_H44: