/* BFD back-end for HP PA-RISC ELF files.
- Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1999, 2000, 2001
- Free Software Foundation, Inc.
+ Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1999, 2000, 2001,
+ 2002 Free Software Foundation, Inc.
Original code by
Center for Software Science
#include "libhppa.h"
#include "elf32-hppa.h"
#define ARCH_SIZE 32
-#include "elf-hppa.h"
#include "elf32-hppa.h"
+#include "elf-hppa.h"
/* In order to gain some understanding of code in this file without
knowing all the intricate details of the linker, note the
asection *, const Elf_Internal_Rela *));
static void elf32_hppa_hide_symbol
- PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
+ PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *, boolean));
static boolean elf32_hppa_adjust_dynamic_symbol
PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
}
else
{
- if (!(elf_bad_symtab (abfd)
- && ELF_ST_BIND (sym->st_info) != STB_LOCAL)
- && ! ((sym->st_shndx <= 0 || sym->st_shndx >= SHN_LORESERVE)
- && sym->st_shndx != SHN_COMMON))
- {
- return bfd_section_from_elf_index (abfd, sym->st_shndx);
- }
+ return bfd_section_from_elf_index (abfd, sym->st_shndx);
}
return NULL;
plabels. */
static void
-elf32_hppa_hide_symbol (info, h)
- struct bfd_link_info *info ATTRIBUTE_UNUSED;
+elf32_hppa_hide_symbol (info, h, force_local)
+ struct bfd_link_info *info;
struct elf_link_hash_entry *h;
+ boolean force_local;
{
- if ((h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0)
- h->dynindx = -1;
+ if (force_local)
+ {
+ h->elf_link_hash_flags |= ELF_LINK_FORCED_LOCAL;
+ if (h->dynindx != -1)
+ {
+ h->dynindx = -1;
+ _bfd_elf_strtab_delref (elf_hash_table (info)->dynstr,
+ h->dynstr_index);
+ }
+ }
+
if (! ((struct elf32_hppa_link_hash_entry *) h)->plabel)
{
h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
if (h->type == STT_PARISC_MILLI
&& (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)
{
- struct elf32_hppa_link_hash_table *htab;
-
- h->elf_link_hash_flags |= ELF_LINK_FORCED_LOCAL;
- elf32_hppa_hide_symbol (info, h);
- htab = hppa_link_hash_table (info);
- _bfd_elf_strtab_delref (htab->elf.dynstr, h->dynstr_index);
+ elf32_hppa_hide_symbol (info, h, true);
/* ?!? We only want to remove these from the dynamic symbol table.
Therefore we do not leave ELF_LINK_FORCED_LOCAL set. */
linker script /DISCARD/, so we'll be discarding
the relocs too. */
}
- else
+ else if (p->count != 0)
{
srel = elf_section_data (p->sec)->sreloc;
srel->_raw_size += p->count * sizeof (Elf32_External_Rela);
+ if ((p->sec->output_section->flags & SEC_READONLY) != 0)
+ info->flags |= DF_TEXTREL;
}
}
}
/* If any dynamic relocs apply to a read-only section,
then we need a DT_TEXTREL entry. */
- elf_link_hash_traverse (&htab->elf, readonly_dynrelocs, (PTR) info);
+ if ((info->flags & DF_TEXTREL) == 0)
+ elf_link_hash_traverse (&htab->elf, readonly_dynrelocs,
+ (PTR) info);
if ((info->flags & DF_TEXTREL) != 0)
{
input_bfd = input_bfd->link_next, bfd_indx++)
{
Elf_Internal_Shdr *symtab_hdr;
+ Elf_Internal_Shdr *shndx_hdr;
Elf_Internal_Sym *isym;
Elf32_External_Sym *ext_syms, *esym, *end_sy;
+ Elf_External_Sym_Shndx *shndx_buf, *shndx;
bfd_size_type sec_size;
/* We'll need the symbol table in a second. */
sec_size *= sizeof (Elf_Internal_Sym);
local_syms = (Elf_Internal_Sym *) bfd_malloc (sec_size);
if (local_syms == NULL)
- {
- goto error_ret_free_local;
- }
+ goto error_ret_free_local;
+
all_local_syms[bfd_indx] = local_syms;
sec_size = symtab_hdr->sh_info;
sec_size *= sizeof (Elf32_External_Sym);
ext_syms = (Elf32_External_Sym *) bfd_malloc (sec_size);
if (ext_syms == NULL)
- {
- goto error_ret_free_local;
- }
+ goto error_ret_free_local;
if (bfd_seek (input_bfd, symtab_hdr->sh_offset, SEEK_SET) != 0
- || (bfd_bread (ext_syms, sec_size, input_bfd) != sec_size))
+ || bfd_bread ((PTR) ext_syms, sec_size, input_bfd) != sec_size)
{
+ error_ret_free_ext_syms:
free (ext_syms);
goto error_ret_free_local;
}
+ shndx_buf = NULL;
+ shndx_hdr = &elf_tdata (input_bfd)->symtab_shndx_hdr;
+ if (shndx_hdr->sh_size != 0)
+ {
+ sec_size = symtab_hdr->sh_info;
+ sec_size *= sizeof (Elf_External_Sym_Shndx);
+ shndx_buf = (Elf_External_Sym_Shndx *) bfd_malloc (sec_size);
+ if (shndx_buf == NULL)
+ goto error_ret_free_ext_syms;
+
+ if (bfd_seek (input_bfd, shndx_hdr->sh_offset, SEEK_SET) != 0
+ || bfd_bread ((PTR) shndx_buf, sec_size, input_bfd) != sec_size)
+ {
+ free (shndx_buf);
+ goto error_ret_free_ext_syms;
+ }
+ }
+
/* Swap the local symbols in. */
- isym = local_syms;
- esym = ext_syms;
- for (end_sy = esym + symtab_hdr->sh_info; esym < end_sy; esym++, isym++)
- bfd_elf32_swap_symbol_in (input_bfd, esym, isym);
+ for (esym = ext_syms, end_sy = esym + symtab_hdr->sh_info,
+ isym = local_syms, shndx = shndx_buf;
+ esym < end_sy;
+ esym++, isym++, shndx = (shndx ? shndx + 1 : NULL))
+ bfd_elf32_swap_symbol_in (input_bfd, esym, shndx, isym);
/* Now we can free the external symbols. */
+ free (shndx_buf);
free (ext_syms);
if (info->shared && htab->multi_subspace)
/* Read in the external relocs. */
input_rel_hdr = &elf_section_data (section)->rel_hdr;
if (bfd_seek (input_bfd, input_rel_hdr->sh_offset, SEEK_SET) != 0
- || bfd_bread (external_relocs,
- input_rel_hdr->sh_size,
- input_bfd) != input_rel_hdr->sh_size)
+ || bfd_bread ((PTR) external_relocs,
+ input_rel_hdr->sh_size,
+ input_bfd) != input_rel_hdr->sh_size)
{
free (external_relocs);
error_ret_free_internal: