[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Overloaded shared-library functions on hppa-linux
From: |
John David Anglin |
Subject: |
Re: Overloaded shared-library functions on hppa-linux |
Date: |
Sat, 20 Apr 2002 19:18:18 -0400 (EDT) |
> It can be seen that exit has been compiled as pic code. The call to atexit
> goes by a simple stub:
>
> 0x1565c <server_setup+64>: b,l 0x22290 <atexit>,rp
> 0x15660 <server_setup+68>: nop
>
> So, r19 is not set correctly. It appears this version of atexit
> has been loaded from libc_nonshared.a:
libc_nonshared.a is built with pic code because it may end up in shared
objects. I think I see the problem. We need to put back the
maybe_pic_call code.
Dave
--
J. David Anglin address@hidden
National Research Council of Canada (613) 990-0752 (FAX: 952-6605)
* 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 -3 -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 22:59:50 -0000
@@ -683,21 +683,13 @@ 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->elf.dynindx != -1
+ && hash->elf.plt.offset != (bfd_vma) -1
+ && !hash->plabel)
|| (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. */
+ /* We need an import stub. Decide between hppa_stub_import
+ and hppa_stub_import_shared later. */
return hppa_stub_import;
}
@@ -2039,6 +2031,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 +2051,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 +2106,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 +3356,16 @@ 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)
+ || (h->maybe_pic_call
+ && !(input_section->flags & SEC_HAS_GOT_REF)))))
{
stub_entry = hppa_get_stub_entry (input_section, sym_sec,
h, rel, htab);