aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf64-hppa.c
diff options
context:
space:
mode:
authorJeff Law <law@redhat.com>2002-06-12 18:12:25 +0000
committerJeff Law <law@redhat.com>2002-06-12 18:12:25 +0000
commit3db4b612459073a0949b77472ff2eb7473d32ec2 (patch)
tree7c6febe41e90490a0b9c3d5b345ec248f9d29be0 /bfd/elf64-hppa.c
parent03e83a45aeeeeb4756a6444557ba1c06dff7c6ea (diff)
downloadfsf-binutils-gdb-3db4b612459073a0949b77472ff2eb7473d32ec2.zip
fsf-binutils-gdb-3db4b612459073a0949b77472ff2eb7473d32ec2.tar.gz
fsf-binutils-gdb-3db4b612459073a0949b77472ff2eb7473d32ec2.tar.bz2
* elf64-hppa.c (allocate_global_data_opd): We don't need an opd entry
for a symbol that has no output section. (allocate_dynrel_entries): Correct comment. (elf64_hppa_finalize_dynreloc): Likewise. Don't create an opd entry unless we want one. (elf64_hppa_finalize_opd): Prevent segfault if dyn_h is NULL. (elf64_hppa_finalize_dlt): Likewise. Prevent segfault for symbols with no section. Remove unnecessary parentheses.
Diffstat (limited to 'bfd/elf64-hppa.c')
-rw-r--r--bfd/elf64-hppa.c37
1 files changed, 18 insertions, 19 deletions
diff --git a/bfd/elf64-hppa.c b/bfd/elf64-hppa.c
index d110d76..cc46943 100644
--- a/bfd/elf64-hppa.c
+++ b/bfd/elf64-hppa.c
@@ -1159,7 +1159,8 @@ allocate_global_data_opd (dyn_h, data)
/* We never need an opd entry for a symbol which is not
defined by this output file. */
- if (h && h->root.type == bfd_link_hash_undefined)
+ if (h && (h->root.type == bfd_link_hash_undefined
+ || h->root.u.def.section->output_section == NULL))
dyn_h->want_opd = 0;
/* If we are creating a shared library, took the address of a local
@@ -1168,9 +1169,8 @@ allocate_global_data_opd (dyn_h, data)
else if (x->info->shared
|| h == NULL
|| h->dynindx == -1
- || ((h->root.type == bfd_link_hash_defined
- || h->root.type == bfd_link_hash_defweak)
- && h->root.u.def.section->output_section != NULL))
+ || (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak))
{
/* If we are creating a shared library, then we will have to
create a runtime relocation for the symbol to properly
@@ -1535,9 +1535,8 @@ allocate_dynrel_entries (dyn_h, data)
switch (rent->type)
{
case R_PARISC_FPTR64:
- /* Allocate one iff we are not building a shared library and
- !want_opd, which by this point will be true only if we're
- actually allocating one statically in the main executable. */
+ /* Allocate one iff we are building a shared library and don't
+ want an opd entry. */
if (!x->info->shared && dyn_h->want_opd)
continue;
break;
@@ -2115,7 +2114,7 @@ elf64_hppa_finalize_opd (dyn_h, data)
{
struct bfd_link_info *info = (struct bfd_link_info *)data;
struct elf64_hppa_link_hash_table *hppa_info;
- struct elf_link_hash_entry *h = dyn_h->h;
+ struct elf_link_hash_entry *h = dyn_h ? dyn_h->h : NULL;
asection *sopd;
asection *sopdrel;
@@ -2123,7 +2122,7 @@ elf64_hppa_finalize_opd (dyn_h, data)
sopd = hppa_info->opd_sec;
sopdrel = hppa_info->opd_rel_sec;
- if (h && dyn_h && dyn_h->want_opd)
+ if (h && dyn_h->want_opd)
{
bfd_vma value;
@@ -2236,7 +2235,7 @@ elf64_hppa_finalize_dlt (dyn_h, data)
struct bfd_link_info *info = (struct bfd_link_info *)data;
struct elf64_hppa_link_hash_table *hppa_info;
asection *sdlt, *sdltrel;
- struct elf_link_hash_entry *h = dyn_h->h;
+ struct elf_link_hash_entry *h = dyn_h ? dyn_h->h : NULL;
hppa_info = elf64_hppa_hash_table (info);
@@ -2247,7 +2246,7 @@ elf64_hppa_finalize_dlt (dyn_h, data)
address, so there is no need to create a relocation. Just install
the proper value into the DLT, note this shortcut can not be
skipped when building a shared library. */
- if (! info->shared && h && dyn_h && dyn_h->want_dlt)
+ if (! info->shared && h && dyn_h->want_dlt)
{
bfd_vma value;
@@ -2263,16 +2262,17 @@ elf64_hppa_finalize_dlt (dyn_h, data)
+ hppa_info->opd_sec->output_offset
+ hppa_info->opd_sec->output_section->vma);
}
- else
+ else if (h->root.u.def.section)
{
- value = (h->root.u.def.value
- + h->root.u.def.section->output_offset);
-
+ value = h->root.u.def.value + h->root.u.def.section->output_offset;
if (h->root.u.def.section->output_section)
value += h->root.u.def.section->output_section->vma;
else
value += h->root.u.def.section->vma;
}
+ else
+ /* We have an undefined function reference. */
+ value = 0;
/* We do not need to include the output offset of the DLT section
here because we are modifying the in-memory contents. */
@@ -2360,9 +2360,8 @@ elf64_hppa_finalize_dynreloc (dyn_h, data)
switch (rent->type)
{
case R_PARISC_FPTR64:
- /* Allocate one iff we are not building a shared library and
- !want_opd, which by this point will be true only if we're
- actually allocating one statically in the main executable. */
+ /* Allocate one iff we are building a shared library and don't
+ want an opd entry. */
if (!info->shared && dyn_h->want_opd)
continue;
break;
@@ -2395,7 +2394,7 @@ elf64_hppa_finalize_dynreloc (dyn_h, data)
We use a section symbol recorded by check_relocs as the
base symbol for the relocation. The addend is the difference
between the section symbol and the address of the .opd entry. */
- if (info->shared && rent->type == R_PARISC_FPTR64)
+ if (info->shared && rent->type == R_PARISC_FPTR64 && dyn_h->want_opd)
{
bfd_vma value, value2;