bfd/elfnn-aarch64.c: Set st_value to zero for undefined symbols
authorWill Newton <will.newton@linaro.org>
Wed, 28 Jan 2015 10:39:21 +0000 (10:39 +0000)
committerWill Newton <will.newton@linaro.org>
Tue, 3 Feb 2015 14:05:06 +0000 (14:05 +0000)
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.

bfd/ChangeLog
bfd/elfnn-aarch64.c

index e6f0418730ac34420d180721759ed1a7ff94200f..e6ed9b6c6ff34b60883a74d09ef6ec7da2386e48 100644 (file)
@@ -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.
 
index 37de7fa64d58cbb82300c2b44081997b50d1f6c9..39458aad6f5b9c71d64e22e0fad83870c875a4bb 100644 (file)
@@ -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;
        }
     }