X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=bfd%2Felf32-hppa.c;h=12f1b04adc712697d9cbd0fe30c34378744f588c;hb=0bf60745767d2465c81ee57ae7705a62d6d8fafe;hp=701c72fd3f821fb173149e726252e58d07247a61;hpb=a005f94ee3eb3a96c6381611ef2bd931250e4e65;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/elf32-hppa.c b/bfd/elf32-hppa.c index 701c72fd3f..12f1b04adc 100644 --- a/bfd/elf32-hppa.c +++ b/bfd/elf32-hppa.c @@ -1,6 +1,6 @@ /* BFD back-end for HP PA-RISC ELF files. Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1999, 2000, 2001, - 2002, 2003, 2004 Free Software Foundation, Inc. + 2002, 2003, 2004, 2005 Free Software Foundation, Inc. Original code by Center for Software Science @@ -22,7 +22,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ #include "bfd.h" #include "sysdep.h" @@ -570,7 +570,7 @@ hppa_type_of_stub (asection *input_sec, && hash->elf.dynindx != -1 && !hash->plabel && (info->shared - || !(hash->elf.elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) + || !hash->elf.def_regular || hash->elf.root.type == bfd_link_hash_defweak)) { /* We need an import stub. Decide between hppa_stub_import @@ -937,6 +937,7 @@ static bfd_boolean elf32_hppa_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) { struct elf32_hppa_link_hash_table *htab; + struct elf_link_hash_entry *h; /* Don't try to create the .plt and .got twice. */ htab = hppa_link_hash_table (info); @@ -951,22 +952,26 @@ elf32_hppa_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) htab->srelplt = bfd_get_section_by_name (abfd, ".rela.plt"); htab->sgot = bfd_get_section_by_name (abfd, ".got"); - htab->srelgot = bfd_make_section (abfd, ".rela.got"); + htab->srelgot = bfd_make_section_with_flags (abfd, ".rela.got", + (SEC_ALLOC + | SEC_LOAD + | SEC_HAS_CONTENTS + | SEC_IN_MEMORY + | SEC_LINKER_CREATED + | SEC_READONLY)); if (htab->srelgot == NULL - || ! bfd_set_section_flags (abfd, htab->srelgot, - (SEC_ALLOC - | SEC_LOAD - | SEC_HAS_CONTENTS - | SEC_IN_MEMORY - | SEC_LINKER_CREATED - | SEC_READONLY)) || ! bfd_set_section_alignment (abfd, htab->srelgot, 2)) return FALSE; htab->sdynbss = bfd_get_section_by_name (abfd, ".dynbss"); htab->srelbss = bfd_get_section_by_name (abfd, ".rela.bss"); - return TRUE; + /* hppa-linux needs _GLOBAL_OFFSET_TABLE_ to be visible from the main + application, because __canonicalize_funcptr_for_compare needs it. */ + h = elf_hash_table (info)->hgot; + h->forced_local = 0; + h->other = STV_DEFAULT; + return bfd_elf_link_record_dynamic_symbol (info, h); } /* Copy the extra info we tack onto an elf_link_hash_entry. */ @@ -1019,15 +1024,16 @@ elf32_hppa_copy_indirect_symbol (const struct elf_backend_data *bed, if (ELIMINATE_COPY_RELOCS && ind->root.type != bfd_link_hash_indirect - && (dir->elf_link_hash_flags & ELF_LINK_HASH_DYNAMIC_ADJUSTED) != 0) - /* If called to transfer flags for a weakdef during processing - of elf_adjust_dynamic_symbol, don't copy ELF_LINK_NON_GOT_REF. - We clear it ourselves for ELIMINATE_COPY_RELOCS. */ - dir->elf_link_hash_flags |= - (ind->elf_link_hash_flags & (ELF_LINK_HASH_REF_DYNAMIC - | ELF_LINK_HASH_REF_REGULAR - | ELF_LINK_HASH_REF_REGULAR_NONWEAK - | ELF_LINK_HASH_NEEDS_PLT)); + && dir->dynamic_adjusted) + { + /* If called to transfer flags for a weakdef during processing + of elf_adjust_dynamic_symbol, don't copy non_got_ref. + We clear it ourselves for ELIMINATE_COPY_RELOCS. */ + dir->ref_dynamic |= ind->ref_dynamic; + dir->ref_regular |= ind->ref_regular; + dir->ref_regular_nonweak |= ind->ref_regular_nonweak; + dir->needs_plt |= ind->needs_plt; + } else _bfd_elf_link_hash_copy_indirect (bed, dir, ind); } @@ -1185,20 +1191,6 @@ elf32_hppa_check_relocs (bfd *abfd, case R_PARISC_DIR14F: /* Used for load/store from absolute locn. */ case R_PARISC_DIR14R: case R_PARISC_DIR21L: /* As above, and for ext branches too. */ -#if 0 - /* Help debug shared library creation. Any of the above - relocs can be used in shared libs, but they may cause - pages to become unshared. */ - if (info->shared) - { - (*_bfd_error_handler) - (_("%B: relocation %s should not be used when making a shared object; recompile with -fPIC"), - abfd, - elf_hppa_howto_table[r_type].name); - } - /* Fall through. */ -#endif - case R_PARISC_DIR32: /* .word relocs. */ /* We may want to output a dynamic relocation later. */ need_entry = NEED_DYNREL; @@ -1278,7 +1270,7 @@ elf32_hppa_check_relocs (bfd *abfd, { if (h != NULL) { - h->elf.elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT; + h->elf.needs_plt = 1; h->elf.plt.refcount += 1; /* If this .plt entry is for a plabel, mark it so @@ -1319,7 +1311,7 @@ elf32_hppa_check_relocs (bfd *abfd, so that we generate copy relocs if it turns out to be dynamic. */ if (h != NULL && !info->shared) - h->elf.elf_link_hash_flags |= ELF_LINK_NON_GOT_REF; + h->elf.non_got_ref = 1; /* If we are creating a shared library then we need to copy the reloc into the shared library. However, if we are @@ -1355,15 +1347,13 @@ elf32_hppa_check_relocs (bfd *abfd, || (h != NULL && (!info->symbolic || h->elf.root.type == bfd_link_hash_defweak - || (h->elf.elf_link_hash_flags - & ELF_LINK_HASH_DEF_REGULAR) == 0)))) + || !h->elf.def_regular)))) || (ELIMINATE_COPY_RELOCS && !info->shared && (sec->flags & SEC_ALLOC) != 0 && h != NULL && (h->elf.root.type == bfd_link_hash_defweak - || (h->elf.elf_link_hash_flags - & ELF_LINK_HASH_DEF_REGULAR) == 0))) + || !h->elf.def_regular))) { struct elf32_hppa_dyn_reloc_entry *p; struct elf32_hppa_dyn_reloc_entry **head; @@ -1397,13 +1387,14 @@ elf32_hppa_check_relocs (bfd *abfd, { flagword flags; - sreloc = bfd_make_section (dynobj, name); flags = (SEC_HAS_CONTENTS | SEC_READONLY | SEC_IN_MEMORY | SEC_LINKER_CREATED); if ((sec->flags & SEC_ALLOC) != 0) flags |= SEC_ALLOC | SEC_LOAD; + sreloc = bfd_make_section_with_flags (dynobj, + name, + flags); if (sreloc == NULL - || !bfd_set_section_flags (dynobj, sreloc, flags) || !bfd_set_section_alignment (dynobj, sreloc, 2)) return FALSE; } @@ -1538,6 +1529,9 @@ elf32_hppa_gc_sweep_hook (bfd *abfd, struct elf32_hppa_dyn_reloc_entry *p; h = sym_hashes[r_symndx - symtab_hdr->sh_info]; + while (h->root.type == bfd_link_hash_indirect + || h->root.type == bfd_link_hash_warning) + h = (struct elf_link_hash_entry *) h->root.u.i.link; eh = (struct elf32_hppa_link_hash_entry *) h; for (pp = &eh->dyn_relocs; (p = *pp) != NULL; pp = &p->next) @@ -1601,6 +1595,67 @@ elf32_hppa_gc_sweep_hook (bfd *abfd, return TRUE; } +/* Support for core dump NOTE sections. */ + +static bfd_boolean +elf32_hppa_grok_prstatus (bfd *abfd, Elf_Internal_Note *note) +{ + int offset; + size_t size; + + switch (note->descsz) + { + default: + return FALSE; + + case 396: /* Linux/hppa */ + /* pr_cursig */ + elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12); + + /* pr_pid */ + elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 24); + + /* pr_reg */ + offset = 72; + size = 320; + + break; + } + + /* Make a ".reg/999" section. */ + return _bfd_elfcore_make_pseudosection (abfd, ".reg", + size, note->descpos + offset); +} + +static bfd_boolean +elf32_hppa_grok_psinfo (bfd *abfd, Elf_Internal_Note *note) +{ + switch (note->descsz) + { + default: + return FALSE; + + case 124: /* Linux/hppa elf_prpsinfo. */ + elf_tdata (abfd)->core_program + = _bfd_elfcore_strndup (abfd, note->descdata + 28, 16); + elf_tdata (abfd)->core_command + = _bfd_elfcore_strndup (abfd, note->descdata + 44, 80); + } + + /* Note that for some reason, a spurious space is tacked + onto the end of the args in some (at least one anyway) + implementations, so strip it off if it exists. */ + { + char *command = elf_tdata (abfd)->core_command; + int n = strlen (command); + + if (0 < n && command[n - 1] == ' ') + command[n - 1] = '\0'; + } + + return TRUE; +} + /* Our own version of hide_symbol, so that we can keep plt entries for plabels. */ @@ -1611,7 +1666,7 @@ elf32_hppa_hide_symbol (struct bfd_link_info *info, { if (force_local) { - h->elf_link_hash_flags |= ELF_LINK_FORCED_LOCAL; + h->forced_local = 1; if (h->dynindx != -1) { h->dynindx = -1; @@ -1622,8 +1677,8 @@ elf32_hppa_hide_symbol (struct bfd_link_info *info, if (! ((struct elf32_hppa_link_hash_entry *) h)->plabel) { - h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT; - h->plt = elf_hash_table (info)->init_refcount; + h->needs_plt = 0; + h->plt = elf_hash_table (info)->init_plt_refcount; } } @@ -1644,10 +1699,10 @@ elf32_hppa_adjust_dynamic_symbol (struct bfd_link_info *info, /* If this is a function, put it in the procedure linkage table. We will fill in the contents of the procedure linkage table later. */ if (h->type == STT_FUNC - || (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0) + || h->needs_plt) { if (h->plt.refcount <= 0 - || ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) != 0 + || (h->def_regular && h->root.type != bfd_link_hash_defweak && ! ((struct elf32_hppa_link_hash_entry *) h)->plabel && (!info->shared || info->symbolic))) @@ -1661,7 +1716,7 @@ elf32_hppa_adjust_dynamic_symbol (struct bfd_link_info *info, application or we are doing a shared symbolic link. */ h->plt.offset = (bfd_vma) -1; - h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT; + h->needs_plt = 0; } return TRUE; @@ -1672,17 +1727,15 @@ elf32_hppa_adjust_dynamic_symbol (struct bfd_link_info *info, /* If this is a weak symbol, and there is a real definition, the processor independent code will have arranged for us to see the real definition first, and we can just use the same value. */ - if (h->weakdef != NULL) + if (h->u.weakdef != NULL) { - if (h->weakdef->root.type != bfd_link_hash_defined - && h->weakdef->root.type != bfd_link_hash_defweak) + if (h->u.weakdef->root.type != bfd_link_hash_defined + && h->u.weakdef->root.type != bfd_link_hash_defweak) abort (); - h->root.u.def.section = h->weakdef->root.u.def.section; - h->root.u.def.value = h->weakdef->root.u.def.value; + h->root.u.def.section = h->u.weakdef->root.u.def.section; + h->root.u.def.value = h->u.weakdef->root.u.def.value; if (ELIMINATE_COPY_RELOCS) - h->elf_link_hash_flags - = ((h->elf_link_hash_flags & ~ELF_LINK_NON_GOT_REF) - | (h->weakdef->elf_link_hash_flags & ELF_LINK_NON_GOT_REF)); + h->non_got_ref = h->u.weakdef->non_got_ref; return TRUE; } @@ -1698,7 +1751,7 @@ elf32_hppa_adjust_dynamic_symbol (struct bfd_link_info *info, /* If there are no references to this symbol that do not use the GOT, we don't need to generate a copy reloc. */ - if ((h->elf_link_hash_flags & ELF_LINK_NON_GOT_REF) == 0) + if (!h->non_got_ref) return TRUE; if (ELIMINATE_COPY_RELOCS) @@ -1718,7 +1771,7 @@ elf32_hppa_adjust_dynamic_symbol (struct bfd_link_info *info, we'll be keeping the dynamic relocs and avoiding the copy reloc. */ if (p == NULL) { - h->elf_link_hash_flags &= ~ELF_LINK_NON_GOT_REF; + h->non_got_ref = 0; return TRUE; } } @@ -1741,7 +1794,7 @@ elf32_hppa_adjust_dynamic_symbol (struct bfd_link_info *info, if ((h->root.u.def.section->flags & SEC_ALLOC) != 0) { htab->srelbss->size += sizeof (Elf32_External_Rela); - h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_COPY; + h->needs_copy = 1; } /* We need to figure out the alignment required for this symbol. I @@ -1789,12 +1842,12 @@ allocate_plt_static (struct elf_link_hash_entry *h, void *inf) info = inf; htab = hppa_link_hash_table (info); if (htab->elf.dynamic_sections_created - && h->plt.refcount > 0) + && h->plt.refcount > 0) { /* Make sure this symbol is output as a dynamic symbol. Undefined weak syms won't yet be marked as dynamic. */ if (h->dynindx == -1 - && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0 + && !h->forced_local && h->type != STT_PARISC_MILLI) { if (! bfd_elf_link_record_dynamic_symbol (info, h)) @@ -1821,13 +1874,13 @@ allocate_plt_static (struct elf_link_hash_entry *h, void *inf) { /* No .plt entry needed. */ h->plt.offset = (bfd_vma) -1; - h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT; + h->needs_plt = 0; } } else { h->plt.offset = (bfd_vma) -1; - h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT; + h->needs_plt = 0; } return TRUE; @@ -1872,7 +1925,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) /* Make sure this symbol is output as a dynamic symbol. Undefined weak syms won't yet be marked as dynamic. */ if (h->dynindx == -1 - && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0 + && !h->forced_local && h->type != STT_PARISC_MILLI) { if (! bfd_elf_link_record_dynamic_symbol (info, h)) @@ -1885,7 +1938,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) if (htab->elf.dynamic_sections_created && (info->shared || (h->dynindx != -1 - && h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)) + && !h->forced_local))) { htab->srelgot->size += sizeof (Elf32_External_Rela); } @@ -1932,10 +1985,10 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) /* For the non-shared case, discard space for relocs against symbols which turn out to need copy relocs or are not dynamic. */ - if ((h->elf_link_hash_flags & ELF_LINK_NON_GOT_REF) == 0 + if (!h->non_got_ref && ((ELIMINATE_COPY_RELOCS - && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) != 0 - && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0) + && h->def_dynamic + && !h->def_regular) || (htab->elf.dynamic_sections_created && (h->root.type == bfd_link_hash_undefweak || h->root.type == bfd_link_hash_undefined)))) @@ -1943,7 +1996,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) /* Make sure this symbol is output as a dynamic symbol. Undefined weak syms won't yet be marked as dynamic. */ if (h->dynindx == -1 - && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0 + && !h->forced_local && h->type != STT_PARISC_MILLI) { if (! bfd_elf_link_record_dynamic_symbol (info, h)) @@ -1987,7 +2040,7 @@ clobber_millicode_symbols (struct elf_link_hash_entry *h, h = (struct elf_link_hash_entry *) h->root.u.i.link; if (h->type == STT_PARISC_MILLI - && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0) + && !h->forced_local) { elf32_hppa_hide_symbol (info, h, TRUE); } @@ -2217,7 +2270,7 @@ elf32_hppa_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, adjust_dynamic_symbol is called, and it is that function which decides whether anything needs to go into these sections. */ - _bfd_strip_section_from_output (info, s); + s->flags |= SEC_EXCLUDE; continue; } @@ -2323,7 +2376,7 @@ elf32_hppa_setup_section_lists (bfd *output_bfd, struct bfd_link_info *info) /* We can't use output_bfd->section_count here to find the top output section index as some sections may have been removed, and - _bfd_strip_section_from_output doesn't renumber the indices. */ + strip_excluded_output_sections doesn't renumber the indices. */ for (section = output_bfd->sections, top_index = 0; section != NULL; section = section->next) @@ -2546,8 +2599,8 @@ get_local_syms (bfd *output_bfd, bfd *input_bfd, struct bfd_link_info *info) && (hash->elf.root.u.def.section->output_section->owner == output_bfd) && hash->elf.root.u.def.section->owner == input_bfd - && (hash->elf.elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) - && !(hash->elf.elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) + && hash->elf.def_regular + && !hash->elf.forced_local && ELF_ST_VISIBILITY (hash->elf.other) == STV_DEFAULT) { asection *sec; @@ -3104,7 +3157,7 @@ final_link_relocate (asection *input_section, && h->elf.dynindx != -1 && !h->plabel && (info->shared - || !(h->elf.elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) + || !h->elf.def_regular || h->elf.root.type == bfd_link_hash_defweak))) { stub_entry = hppa_get_stub_entry (input_section, sym_sec, @@ -3192,14 +3245,6 @@ final_link_relocate (asection *input_section, == (((int) OP_ADDIL << 26) | (27 << 21))) { insn &= ~ (0x1f << 21); -#if 0 /* debug them. */ - (*_bfd_error_handler) - (_("%B(%A+0x%lx): fixing %s"), - input_bfd, - input_section, - (long) rel->r_offset, - howto->name); -#endif } /* Now try to make things easy for the dynamic linker. */ @@ -3690,12 +3735,10 @@ elf32_hppa_relocate_section (bfd *output_bfd, || (!info->shared && h != NULL && h->elf.dynindx != -1 - && (h->elf.elf_link_hash_flags & ELF_LINK_NON_GOT_REF) == 0 + && !h->elf.non_got_ref && ((ELIMINATE_COPY_RELOCS - && (h->elf.elf_link_hash_flags - & ELF_LINK_HASH_DEF_DYNAMIC) != 0 - && (h->elf.elf_link_hash_flags - & ELF_LINK_HASH_DEF_REGULAR) == 0) + && h->elf.def_dynamic + && !h->elf.def_regular) || h->elf.root.type == bfd_link_hash_undefweak || h->elf.root.type == bfd_link_hash_undefined))) { @@ -3727,8 +3770,7 @@ elf32_hppa_relocate_section (bfd *output_bfd, || !IS_ABSOLUTE_RELOC (r_type) || !info->shared || !info->symbolic - || (h->elf.elf_link_hash_flags - & ELF_LINK_HASH_DEF_REGULAR) == 0)) + || !h->elf.def_regular)) { outrel.r_info = ELF32_R_INFO (h->elf.dynindx, r_type); } @@ -3765,13 +3807,6 @@ elf32_hppa_relocate_section (bfd *output_bfd, outrel.r_info = ELF32_R_INFO (indx, r_type); } -#if 0 - /* EH info can cause unaligned DIR32 relocs. - Tweak the reloc type for the dynamic linker. */ - if (r_type == R_PARISC_DIR32 && (outrel.r_offset & 3) != 0) - outrel.r_info = ELF32_R_INFO (ELF32_R_SYM (outrel.r_info), - R_PARISC_DIR32U); -#endif sreloc = elf_section_data (input_section)->sreloc; if (sreloc == NULL) abort (); @@ -3825,8 +3860,8 @@ elf32_hppa_relocate_section (bfd *output_bfd, else { if (!((*info->callbacks->reloc_overflow) - (info, sym_name, howto->name, 0, input_bfd, input_section, - rel->r_offset))) + (info, (h ? &h->elf.root : NULL), sym_name, howto->name, + (bfd_vma) 0, input_bfd, input_section, rel->r_offset))) return FALSE; } } @@ -3894,7 +3929,7 @@ elf32_hppa_finish_dynamic_symbol (bfd *output_bfd, loc += htab->srelplt->reloc_count++ * sizeof (Elf32_External_Rela); bfd_elf32_swap_reloca_out (htab->splt->output_section->owner, &rel, loc); - if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0) + if (!h->def_regular) { /* Mark the symbol as undefined, rather than as defined in the .plt section. Leave the value alone. */ @@ -3918,7 +3953,7 @@ elf32_hppa_finish_dynamic_symbol (bfd *output_bfd, relocate_section function. */ if (info->shared && (info->symbolic || h->dynindx == -1) - && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)) + && h->def_regular) { rel.r_info = ELF32_R_INFO (0, R_PARISC_DIR32); rel.r_addend = (h->root.u.def.value @@ -3939,7 +3974,7 @@ elf32_hppa_finish_dynamic_symbol (bfd *output_bfd, bfd_elf32_swap_reloca_out (output_bfd, &rel, loc); } - if ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_COPY) != 0) + if (h->needs_copy) { asection *s; @@ -4171,6 +4206,8 @@ elf32_hppa_elf_get_symbol_type (Elf_Internal_Sym *elf_sym, int type) #define elf_backend_size_dynamic_sections elf32_hppa_size_dynamic_sections #define elf_backend_gc_mark_hook elf32_hppa_gc_mark_hook #define elf_backend_gc_sweep_hook elf32_hppa_gc_sweep_hook +#define elf_backend_grok_prstatus elf32_hppa_grok_prstatus +#define elf_backend_grok_psinfo elf32_hppa_grok_psinfo #define elf_backend_object_p elf32_hppa_object_p #define elf_backend_final_write_processing elf_hppa_final_write_processing #define elf_backend_post_process_headers elf32_hppa_post_process_headers