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] bfd/elfnn-aarch64.c: Set st_value to zero for undefined symbols


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

commit 46b87d490296235ab7c76c68816de7c402a79326
Author: Will Newton <will.newton@linaro.org>
Date:   Wed Jan 28 10:39:21 2015 +0000

    bfd/elfnn-aarch64.c: Set st_value to zero for undefined symbols
    
    Unless pointer_equality_needed is set then set st_value to be zero
    for undefined symbols.
    
    bfd/ChangeLog:
    
    2015-02-03  Will Newton  <will.newton@linaro.org>
    
    	* elfnn-aarch64.c (elfNN_aarch64_finish_dynamic_symbol):
    	Set st_value to zero for undefined symbols if the reference
    	is weak or pointer_equality_needed is FALSE.

Diff:
---
 bfd/ChangeLog       |  4 ++++
 bfd/elfnn-aarch64.c | 15 +++++++++++----
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index e6f0418..e6ed9b6 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,9 @@
 2015-02-03  Will Newton  <will.newton@linaro.org>
 
+	* elfnn-aarch64.c (elfNN_aarch64_finish_dynamic_symbol):
+	Set st_value to zero for undefined symbols if the reference
+	is weak or pointer_equality_needed is FALSE.
+
 	* elf32-arm.c (elf32_arm_finish_dynamic_symbol): Improve
 	  comment discussing why we clear st_value for some symbols.
 
diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c
index 37de7fa..39458aa 100644
--- a/bfd/elfnn-aarch64.c
+++ b/bfd/elfnn-aarch64.c
@@ -7436,11 +7436,18 @@ elfNN_aarch64_finish_dynamic_symbol (bfd *output_bfd,
       if (!h->def_regular)
 	{
 	  /* Mark the symbol as undefined, rather than as defined in
-	     the .plt section.  Leave the value alone.  This is a clue
-	     for the dynamic linker, to make function pointer
-	     comparisons work between an application and shared
-	     library.  */
+	     the .plt section.  */
 	  sym->st_shndx = SHN_UNDEF;
+	  /* If the symbol is weak we need to clear the value.
+	     Otherwise, the PLT entry would provide a definition for
+	     the symbol even if the symbol wasn't defined anywhere,
+	     and so the symbol would never be NULL.  Leave the value if
+	     there were any relocations where pointer equality matters
+	     (this is a clue for the dynamic linker, to make function
+	     pointer comparisons work between an application and shared
+	     library).  */
+	  if (!h->ref_regular_nonweak || !h->pointer_equality_needed)
+	    sym->st_value = 0;
 	}
     }


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