diff options
Diffstat (limited to 'bfd/elf32-m68k.c')
-rw-r--r-- | bfd/elf32-m68k.c | 108 |
1 files changed, 47 insertions, 61 deletions
diff --git a/bfd/elf32-m68k.c b/bfd/elf32-m68k.c index 2f49dad9351..19a2ce8c755 100644 --- a/bfd/elf32-m68k.c +++ b/bfd/elf32-m68k.c @@ -2,21 +2,21 @@ Copyright 1993, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. -This file is part of BFD, the Binary File Descriptor library. + This file is part of BFD, the Binary File Descriptor library. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -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. */ + 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. */ #include "bfd.h" #include "sysdep.h" @@ -46,6 +46,8 @@ static bfd_boolean elf_m68k_adjust_dynamic_symbol PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *)); static bfd_boolean elf_m68k_size_dynamic_sections PARAMS ((bfd *, struct bfd_link_info *)); +static bfd_boolean elf_m68k_discard_copies + PARAMS ((struct elf_link_hash_entry *, PTR)); static bfd_boolean elf_m68k_relocate_section PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, Elf_Internal_Rela *, Elf_Internal_Sym *, asection **)); @@ -88,7 +90,7 @@ static reloc_howto_type howto_table[] = { HOWTO(R_68K_GLOB_DAT, 0, 2,32, FALSE,0, complain_overflow_dont, bfd_elf_generic_reloc, "R_68K_GLOB_DAT", FALSE, 0, 0xffffffff,FALSE), HOWTO(R_68K_JMP_SLOT, 0, 2,32, FALSE,0, complain_overflow_dont, bfd_elf_generic_reloc, "R_68K_JMP_SLOT", FALSE, 0, 0xffffffff,FALSE), HOWTO(R_68K_RELATIVE, 0, 2,32, FALSE,0, complain_overflow_dont, bfd_elf_generic_reloc, "R_68K_RELATIVE", FALSE, 0, 0xffffffff,FALSE), - /* GNU extension to record C++ vtable hierarchy */ + /* GNU extension to record C++ vtable hierarchy. */ HOWTO (R_68K_GNU_VTINHERIT, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ @@ -102,7 +104,7 @@ static reloc_howto_type howto_table[] = { 0, /* src_mask */ 0, /* dst_mask */ FALSE), - /* GNU extension to record C++ vtable member usage */ + /* GNU extension to record C++ vtable member usage. */ HOWTO (R_68K_GNU_VTENTRY, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ @@ -179,7 +181,6 @@ reloc_type_lookup (abfd, code) #define bfd_elf32_bfd_reloc_type_lookup reloc_type_lookup #define ELF_ARCH bfd_arch_m68k -/* end code generated by elf.el */ /* Functions for the m68k ELF linker. */ @@ -272,6 +273,8 @@ struct elf_m68k_link_hash_entry struct elf_m68k_pcrel_relocs_copied *pcrel_relocs_copied; }; +#define elf_m68k_hash_entry(ent) ((struct elf_m68k_link_hash_entry *) (ent)) + /* m68k ELF linker hash table. */ struct elf_m68k_link_hash_table @@ -282,19 +285,6 @@ struct elf_m68k_link_hash_table struct sym_sec_cache sym_sec; }; -/* Declare this now that the above structures are defined. */ - -static bfd_boolean elf_m68k_discard_copies - PARAMS ((struct elf_m68k_link_hash_entry *, PTR)); - -/* Traverse an m68k ELF linker hash table. */ - -#define elf_m68k_link_hash_traverse(table, func, info) \ - (elf_link_hash_traverse \ - (&(table)->root, \ - (bfd_boolean (*) PARAMS ((struct elf_link_hash_entry *, PTR))) (func), \ - (info))) - /* Get the m68k ELF linker hash table from a link_info structure. */ #define elf_m68k_hash_table(p) \ @@ -308,28 +298,22 @@ elf_m68k_link_hash_newfunc (entry, table, string) struct bfd_hash_table *table; const char *string; { - struct elf_m68k_link_hash_entry *ret = - (struct elf_m68k_link_hash_entry *) entry; + struct bfd_hash_entry *ret = entry; /* Allocate the structure if it has not already been allocated by a subclass. */ - if (ret == (struct elf_m68k_link_hash_entry *) NULL) - ret = ((struct elf_m68k_link_hash_entry *) - bfd_hash_allocate (table, - sizeof (struct elf_m68k_link_hash_entry))); - if (ret == (struct elf_m68k_link_hash_entry *) NULL) - return (struct bfd_hash_entry *) ret; + if (ret == NULL) + ret = bfd_hash_allocate (table, + sizeof (struct elf_m68k_link_hash_entry)); + if (ret == NULL) + return ret; /* Call the allocation method of the superclass. */ - ret = ((struct elf_m68k_link_hash_entry *) - _bfd_elf_link_hash_newfunc ((struct bfd_hash_entry *) ret, - table, string)); - if (ret != (struct elf_m68k_link_hash_entry *) NULL) - { - ret->pcrel_relocs_copied = NULL; - } + ret = _bfd_elf_link_hash_newfunc (ret, table, string); + if (ret != NULL) + elf_m68k_hash_entry (ret)->pcrel_relocs_copied = NULL; - return (struct bfd_hash_entry *) ret; + return ret; } /* Create an m68k ELF linker hash table. */ @@ -357,7 +341,7 @@ elf_m68k_link_hash_table_create (abfd) return &ret->root.root; } -/* Keep m68k-specific flags in the ELF header */ +/* Keep m68k-specific flags in the ELF header. */ static bfd_boolean elf32_m68k_set_private_flags (abfd, flags) bfd *abfd; @@ -394,7 +378,7 @@ elf32_m68k_merge_private_bfd_data (ibfd, obfd) return TRUE; } -/* Display the flags field */ +/* Display the flags field. */ static bfd_boolean elf32_m68k_print_private_bfd_data (abfd, ptr) bfd *abfd; @@ -719,7 +703,7 @@ elf_m68k_check_relocs (abfd, info, sec, relocs) if (h != NULL) { struct elf_m68k_link_hash_entry *eh - = (struct elf_m68k_link_hash_entry *) h; + = elf_m68k_hash_entry (h); head = &eh->pcrel_relocs_copied; } else @@ -1023,13 +1007,11 @@ elf_m68k_adjust_dynamic_symbol (info, h) /* We also need to make an entry in the .got.plt section, which will be placed in the .got section by the linker script. */ - s = bfd_get_section_by_name (dynobj, ".got.plt"); BFD_ASSERT (s != NULL); s->_raw_size += 4; /* We also need to make an entry in the .rela.plt section. */ - s = bfd_get_section_by_name (dynobj, ".rela.plt"); BFD_ASSERT (s != NULL); s->_raw_size += sizeof (Elf32_External_Rela); @@ -1160,9 +1142,9 @@ elf_m68k_size_dynamic_sections (output_bfd, info) We allocated space for them in the check_relocs routine, but we will not fill them in in the relocate_section routine. */ if (info->shared) - elf_m68k_link_hash_traverse (elf_m68k_hash_table (info), - elf_m68k_discard_copies, - (PTR) info); + elf_link_hash_traverse (elf_hash_table (info), + elf_m68k_discard_copies, + (PTR) info); /* The check_relocs and adjust_dynamic_symbol entry points have determined the sizes of the various dynamic sections. Allocate @@ -1288,7 +1270,7 @@ elf_m68k_size_dynamic_sections (output_bfd, info) return TRUE; } -/* This function is called via elf_m68k_link_hash_traverse if we are +/* This function is called via elf_link_hash_traverse if we are creating a shared object. In the -Bsymbolic case it discards the space allocated to copy PC relative relocs against symbols which are defined in regular objects. For the normal shared case, it @@ -1303,33 +1285,38 @@ elf_m68k_size_dynamic_sections (output_bfd, info) static bfd_boolean elf_m68k_discard_copies (h, inf) - struct elf_m68k_link_hash_entry *h; + struct elf_link_hash_entry *h; PTR inf; { struct bfd_link_info *info = (struct bfd_link_info *) inf; struct elf_m68k_pcrel_relocs_copied *s; - if (h->root.root.type == bfd_link_hash_warning) - h = (struct elf_m68k_link_hash_entry *) h->root.root.u.i.link; + if (h->root.type == bfd_link_hash_warning) + h = (struct elf_link_hash_entry *) h->root.u.i.link; - if ((h->root.elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0 + if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0 || (!info->symbolic - && (h->root.elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)) + && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)) { if ((info->flags & DF_TEXTREL) == 0) { /* Look for relocations against read-only sections. */ - for (s = h->pcrel_relocs_copied; s != NULL; s = s->next) + for (s = elf_m68k_hash_entry (h)->pcrel_relocs_copied; + s != NULL; + s = s->next) if ((s->section->flags & SEC_READONLY) != 0) { info->flags |= DF_TEXTREL; break; } } + return TRUE; } - for (s = h->pcrel_relocs_copied; s != NULL; s = s->next) + for (s = elf_m68k_hash_entry (h)->pcrel_relocs_copied; + s != NULL; + s = s->next) s->section->_raw_size -= s->count * sizeof (Elf32_External_Rela); return TRUE; @@ -1466,7 +1453,6 @@ elf_m68k_relocate_section (output_bfd, info, input_bfd, input_section, else if (h->root.type == bfd_link_hash_undefweak) relocation = 0; else if (info->shared - && (!info->symbolic || info->allow_shlib_undefined) && !info->no_undefined && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT) relocation = 0; |