bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Overloaded shared-library functions on hppa-linux


From: Alan Modra
Subject: Re: Overloaded shared-library functions on hppa-linux
Date: Sat, 20 Apr 2002 13:41:47 +0930
User-agent: Mutt/1.3.25i

On Fri, Apr 19, 2002 at 10:55:23PM -0400, John David Anglin wrote:
> I rebuilt and installed just the linker.  A test with relinking libstdc++
> shows that we still don't get stubs for calls within the shared library.
> I then tried rebuilding binutils and got the following error:

Another try.  Added last hunk of this diff.

        * elf32-hppa.c (hppa_type_of_stub): Correct and simplify condition
        under which a plt call stub is used.
        (final_link_relocate): Similarly.
        (allocate_plt_static): Clear h-plabel except when plt entry is
        exclusively used for a plabel.
        (allocate_dynrelocs): Use the above to simplify plt sizing.

Index: bfd/elf32-hppa.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-hppa.c,v
retrieving revision 1.77
diff -u -p -r1.77 elf32-hppa.c
--- bfd/elf32-hppa.c    8 Apr 2002 11:01:42 -0000       1.77
+++ bfd/elf32-hppa.c    20 Apr 2002 04:09:05 -0000
@@ -683,21 +683,12 @@ hppa_type_of_stub (input_sec, rel, hash,
   unsigned int r_type;
 
   if (hash != NULL
-      && (((hash->elf.root.type == bfd_link_hash_defined
-           || hash->elf.root.type == bfd_link_hash_defweak)
-          && hash->elf.root.u.def.section->output_section == NULL)
-         || (hash->elf.root.type == bfd_link_hash_defweak
-             && hash->elf.dynindx != -1
-             && hash->elf.plt.offset != (bfd_vma) -1)
-         || hash->elf.root.type == bfd_link_hash_undefweak
-         || hash->elf.root.type == bfd_link_hash_undefined
-         || (hash->maybe_pic_call && !(input_sec->flags & SEC_HAS_GOT_REF))))
-    {
-      /* If output_section is NULL, then it's a symbol defined in a
-        shared library.  We will need an import stub.  Decide between
-        hppa_stub_import and hppa_stub_import_shared later.  For
-        shared links we need stubs for undefined or weak syms too;
-        They will presumably be resolved by the dynamic linker.  */
+      && hash->elf.dynindx != -1
+      && hash->elf.plt.offset != (bfd_vma) -1
+      && !hash->plabel)
+    {
+      /* We need an import stub.  Decide between hppa_stub_import
+        and hppa_stub_import_shared later.  */
       return hppa_stub_import;
     }
 
@@ -2039,6 +2030,7 @@ allocate_plt_static (h, inf)
     {
       /* Make an entry in the .plt section for non-pic code that is
         calling pic code.  */
+      ((struct elf32_hppa_link_hash_entry *) h)->plabel = 0;
       s = htab->splt;
       h->plt.offset = s->_raw_size;
       s->_raw_size += PLT_ENTRY_SIZE;
@@ -2058,7 +2050,11 @@ allocate_plt_static (h, inf)
 
       if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, info, h))
        {
-         /* Allocate these later.  */
+         /* Allocate these later.  From this point on, h->plabel
+            means that the plt entry is only used by a plabel.
+            We'll be using a normal plt entry for this symbol, so
+            clear the plabel indicator.  */
+         ((struct elf32_hppa_link_hash_entry *) h)->plabel = 0;
        }
       else if (((struct elf32_hppa_link_hash_entry *) h)->plabel)
        {
@@ -2109,7 +2105,7 @@ allocate_dynrelocs (h, inf)
   if (htab->elf.dynamic_sections_created
       && h->plt.offset != (bfd_vma) -1
       && !((struct elf32_hppa_link_hash_entry *) h)->pic_call
-      && WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, info, h))
+      && !((struct elf32_hppa_link_hash_entry *) h)->plabel)
     {
       /* Make an entry in the .plt section.  */
       s = htab->splt;
@@ -3359,19 +3355,14 @@ final_link_relocate (input_section, cont
     case R_PARISC_PCREL12F:
     case R_PARISC_PCREL17F:
     case R_PARISC_PCREL22F:
-      /* If this is a call to a function defined in another dynamic
-        library, or if it is a call to a PIC function in the same
-        object, or if this is a shared link and it is a call to a
-        weak symbol which may or may not be in the same object, then
-        find the import stub in the stub hash.  */
+      /* If this call should go via the plt, find the import stub in
+        the stub hash.  */
       if (sym_sec == NULL
          || sym_sec->output_section == NULL
          || (h != NULL
-             && ((h->maybe_pic_call
-                  && !(input_section->flags & SEC_HAS_GOT_REF))
-                 || (h->elf.root.type == bfd_link_hash_defweak
-                     && h->elf.dynindx != -1
-                     && h->elf.plt.offset != (bfd_vma) -1))))
+             && h->elf.dynindx != -1
+             && h->elf.plt.offset != (bfd_vma) -1
+             && !h->plabel))
        {
          stub_entry = hppa_get_stub_entry (input_section, sym_sec,
                                            h, rel, htab);

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre



reply via email to

[Prev in Thread] Current Thread [Next in Thread]