This is the mail archive of the binutils-cvs@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Add NULL bfd test to elf_symbol_from


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=0ee5a0e48314fec3522f7eabadd5fea920628077

commit 0ee5a0e48314fec3522f7eabadd5fea920628077
Author: Alan Modra <amodra@gmail.com>
Date:   Tue Nov 21 10:04:05 2017 +1030

    Add NULL bfd test to elf_symbol_from
    
    A followup to PR22443.
    
    	* elf-bfd.h (elf_symbol_from): Check for NULL symbol bfd.
    	* elfcode.h (elf_slurp_reloc_table_from_section): Add FIXME comment.

Diff:
---
 bfd/ChangeLog | 5 +++++
 bfd/elf-bfd.h | 9 +++++----
 bfd/elfcode.h | 2 ++
 3 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 5bf4f1a..696b2d8 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,8 @@
+2017-11-21  Alan Modra  <amodra@gmail.com>
+
+	* elf-bfd.h (elf_symbol_from): Check for NULL symbol bfd.
+	* elfcode.h (elf_slurp_reloc_table_from_section): Add FIXME comment.
+
 2017-11-20  Nick Clifton  <nickc@redhat.com>
 
 	PR 22450
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index 99e13e0..954105e 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -731,10 +731,11 @@ struct elf_size_info {
 };
 
 #define elf_symbol_from(ABFD,S) \
-	(((S)->the_bfd->xvec->flavour == bfd_target_elf_flavour \
-	  && (S)->the_bfd->tdata.elf_obj_data != 0) \
-	 ? (elf_symbol_type *) (S) \
-	 : 0)
+  (((S)->the_bfd != NULL					\
+    && (S)->the_bfd->xvec->flavour == bfd_target_elf_flavour	\
+    && (S)->the_bfd->tdata.elf_obj_data != 0)			\
+   ? (elf_symbol_type *) (S)					\
+   : 0)
 
 enum elf_reloc_type_class {
   reloc_class_normal,
diff --git a/bfd/elfcode.h b/bfd/elfcode.h
index 6114b11..80b26aa 100644
--- a/bfd/elfcode.h
+++ b/bfd/elfcode.h
@@ -1440,6 +1440,8 @@ elf_slurp_reloc_table_from_section (bfd *abfd,
 	relent->address = rela.r_offset - asect->vma;
 
       if (ELF_R_SYM (rela.r_info) == STN_UNDEF)
+	/* FIXME: This and the error case below mean that we have a
+	   symbol on relocs that is not elf_symbol_type.  */
 	relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr;
       else if (ELF_R_SYM (rela.r_info) > symcount)
 	{


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]