PR27631, ubsan: elf32-metag.c:1550:10

Message ID 20210414090300.GO5425@bubble.grove.modra.org
State New
Headers show
Series
  • PR27631, ubsan: elf32-metag.c:1550:10
Related show

Commit Message

Luis Machado via Binutils April 14, 2021, 9:03 a.m.
PR 27631
	* elf32-metag.c (elf_metag_relocate_section): Don't use &hh->elf
	when hh might be NULL, test for NULL first.


-- 
Alan Modra
Australia Development Lab, IBM

Patch

diff --git a/bfd/elf32-metag.c b/bfd/elf32-metag.c
index 82e67eac99a..984741847a9 100644
--- a/bfd/elf32-metag.c
+++ b/bfd/elf32-metag.c
@@ -1546,8 +1546,8 @@  elf_metag_relocate_section (bfd *output_bfd,
 	  if ((bfd_link_pic (info)
 	       && r_symndx != STN_UNDEF
 	       && (input_section->flags & SEC_ALLOC) != 0
-	       && (r_type != R_METAG_RELBRANCH
-		   || !SYMBOL_CALLS_LOCAL (info, &hh->eh)))
+	       && !(r_type == R_METAG_RELBRANCH
+		    && (hh == NULL || SYMBOL_CALLS_LOCAL (info, &hh->eh))))
 	      || (!bfd_link_pic (info)
 		  && hh != NULL
 		  && hh->eh.dynindx != -1