Ignore:
Timestamp:
Aug 16, 2003, 6:59:22 PM (22 years ago)
Author:
bird
Message:

binutils v2.14 - offical sources.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/GNU/src/binutils/bfd/elf32-m68k.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r608 r609  
    11/* Motorola 68k series support for 32-bit ELF
    2    Copyright 1993, 1995, 1996, 1997, 1998, 1999, 2000, 2001
     2   Copyright 1993, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
    33   Free Software Foundation, Inc.
    44
    5 This file is part of BFD, the Binary File Descriptor library.
    6 
    7 This program is free software; you can redistribute it and/or modify
    8 it under the terms of the GNU General Public License as published by
    9 the Free Software Foundation; either version 2 of the License, or
    10 (at your option) any later version.
    11 
    12 This program is distributed in the hope that it will be useful,
    13 but WITHOUT ANY WARRANTY; without even the implied warranty of
    14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    15 GNU General Public License for more details.
    16 
    17 You should have received a copy of the GNU General Public License
    18 along with this program; if not, write to the Free Software
    19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
     5   This file is part of BFD, the Binary File Descriptor library.
     6
     7   This program is free software; you can redistribute it and/or modify
     8   it under the terms of the GNU General Public License as published by
     9   the Free Software Foundation; either version 2 of the License, or
     10   (at your option) any later version.
     11
     12   This program is distributed in the hope that it will be useful,
     13   but WITHOUT ANY WARRANTY; without even the implied warranty of
     14   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15   GNU General Public License for more details.
     16
     17   You should have received a copy of the GNU General Public License
     18   along with this program; if not, write to the Free Software
     19   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
    2020
    2121#include "bfd.h"
     
    2929  PARAMS ((bfd *, bfd_reloc_code_real_type));
    3030static void rtype_to_howto
    31   PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *));
     31  PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
    3232static struct bfd_hash_entry *elf_m68k_link_hash_newfunc
    3333  PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
    3434static struct bfd_link_hash_table *elf_m68k_link_hash_table_create
    3535  PARAMS ((bfd *));
    36 static boolean elf_m68k_check_relocs
     36static bfd_boolean elf_m68k_check_relocs
    3737  PARAMS ((bfd *, struct bfd_link_info *, asection *,
    3838           const Elf_Internal_Rela *));
    3939static asection *elf_m68k_gc_mark_hook
    40   PARAMS ((bfd *, struct bfd_link_info *, Elf_Internal_Rela *,
     40  PARAMS ((asection *, struct bfd_link_info *, Elf_Internal_Rela *,
    4141           struct elf_link_hash_entry *, Elf_Internal_Sym *));
    42 static boolean elf_m68k_gc_sweep_hook
     42static bfd_boolean elf_m68k_gc_sweep_hook
    4343  PARAMS ((bfd *, struct bfd_link_info *, asection *,
    4444           const Elf_Internal_Rela *));
    45 static boolean elf_m68k_adjust_dynamic_symbol
     45static bfd_boolean elf_m68k_adjust_dynamic_symbol
    4646  PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
    47 static boolean elf_m68k_size_dynamic_sections
     47static bfd_boolean elf_m68k_size_dynamic_sections
    4848  PARAMS ((bfd *, struct bfd_link_info *));
    49 static boolean elf_m68k_relocate_section
     49static bfd_boolean elf_m68k_discard_copies
     50  PARAMS ((struct elf_link_hash_entry *, PTR));
     51static bfd_boolean elf_m68k_relocate_section
    5052  PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
    5153           Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
    52 static boolean elf_m68k_finish_dynamic_symbol
     54static bfd_boolean elf_m68k_finish_dynamic_symbol
    5355  PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *,
    5456           Elf_Internal_Sym *));
    55 static boolean elf_m68k_finish_dynamic_sections
     57static bfd_boolean elf_m68k_finish_dynamic_sections
    5658  PARAMS ((bfd *, struct bfd_link_info *));
    5759
    58 static boolean elf32_m68k_set_private_flags
     60static bfd_boolean elf32_m68k_set_private_flags
    5961  PARAMS ((bfd *, flagword));
    60 static boolean elf32_m68k_copy_private_bfd_data
     62static bfd_boolean elf32_m68k_merge_private_bfd_data
    6163  PARAMS ((bfd *, bfd *));
    62 static boolean elf32_m68k_merge_private_bfd_data
    63   PARAMS ((bfd *, bfd *));
    64 static boolean elf32_m68k_print_private_bfd_data
     64static bfd_boolean elf32_m68k_print_private_bfd_data
    6565  PARAMS ((bfd *, PTR));
     66static enum elf_reloc_type_class elf32_m68k_reloc_type_class
     67  PARAMS ((const Elf_Internal_Rela *));
    6668
    6769static reloc_howto_type howto_table[] = {
    68   HOWTO(R_68K_NONE,       0, 0, 0, false,0, complain_overflow_dont,     bfd_elf_generic_reloc, "R_68K_NONE",      false, 0, 0x00000000,false),
    69   HOWTO(R_68K_32,         0, 2,32, false,0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_68K_32",        false, 0, 0xffffffff,false),
    70   HOWTO(R_68K_16,         0, 1,16, false,0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_68K_16",        false, 0, 0x0000ffff,false),
    71   HOWTO(R_68K_8,          0, 0, 8, false,0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_68K_8",         false, 0, 0x000000ff,false),
    72   HOWTO(R_68K_PC32,       0, 2,32, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_68K_PC32",      false, 0, 0xffffffff,true),
    73   HOWTO(R_68K_PC16,       0, 1,16, true, 0, complain_overflow_signed,   bfd_elf_generic_reloc, "R_68K_PC16",      false, 0, 0x0000ffff,true),
    74   HOWTO(R_68K_PC8,        0, 0, 8, true, 0, complain_overflow_signed,   bfd_elf_generic_reloc, "R_68K_PC8",       false, 0, 0x000000ff,true),
    75   HOWTO(R_68K_GOT32,      0, 2,32, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_68K_GOT32",     false, 0, 0xffffffff,true),
    76   HOWTO(R_68K_GOT16,      0, 1,16, true, 0, complain_overflow_signed,   bfd_elf_generic_reloc, "R_68K_GOT16",     false, 0, 0x0000ffff,true),
    77   HOWTO(R_68K_GOT8,       0, 0, 8, true, 0, complain_overflow_signed,   bfd_elf_generic_reloc, "R_68K_GOT8",      false, 0, 0x000000ff,true),
    78   HOWTO(R_68K_GOT32O,     0, 2,32, false,0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_68K_GOT32O",    false, 0, 0xffffffff,false),
    79   HOWTO(R_68K_GOT16O,     0, 1,16, false,0, complain_overflow_signed,   bfd_elf_generic_reloc, "R_68K_GOT16O",    false, 0, 0x0000ffff,false),
    80   HOWTO(R_68K_GOT8O,      0, 0, 8, false,0, complain_overflow_signed,   bfd_elf_generic_reloc, "R_68K_GOT8O",     false, 0, 0x000000ff,false),
    81   HOWTO(R_68K_PLT32,      0, 2,32, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_68K_PLT32",     false, 0, 0xffffffff,true),
    82   HOWTO(R_68K_PLT16,      0, 1,16, true, 0, complain_overflow_signed,   bfd_elf_generic_reloc, "R_68K_PLT16",     false, 0, 0x0000ffff,true),
    83   HOWTO(R_68K_PLT8,       0, 0, 8, true, 0, complain_overflow_signed,   bfd_elf_generic_reloc, "R_68K_PLT8",      false, 0, 0x000000ff,true),
    84   HOWTO(R_68K_PLT32O,     0, 2,32, false,0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_68K_PLT32O",    false, 0, 0xffffffff,false),
    85   HOWTO(R_68K_PLT16O,     0, 1,16, false,0, complain_overflow_signed,   bfd_elf_generic_reloc, "R_68K_PLT16O",    false, 0, 0x0000ffff,false),
    86   HOWTO(R_68K_PLT8O,      0, 0, 8, false,0, complain_overflow_signed,   bfd_elf_generic_reloc, "R_68K_PLT8O",     false, 0, 0x000000ff,false),
    87   HOWTO(R_68K_COPY,       0, 0, 0, false,0, complain_overflow_dont,     bfd_elf_generic_reloc, "R_68K_COPY",      false, 0, 0xffffffff,false),
    88   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),
    89   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),
    90   HOWTO(R_68K_RELATIVE,   0, 2,32, false,0, complain_overflow_dont,     bfd_elf_generic_reloc, "R_68K_RELATIVE",  false, 0, 0xffffffff,false),
    91   /* GNU extension to record C++ vtable hierarchy */
     70  HOWTO(R_68K_NONE,       0, 0, 0, FALSE,0, complain_overflow_dont,     bfd_elf_generic_reloc, "R_68K_NONE",      FALSE, 0, 0x00000000,FALSE),
     71  HOWTO(R_68K_32,         0, 2,32, FALSE,0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_68K_32",        FALSE, 0, 0xffffffff,FALSE),
     72  HOWTO(R_68K_16,         0, 1,16, FALSE,0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_68K_16",        FALSE, 0, 0x0000ffff,FALSE),
     73  HOWTO(R_68K_8,          0, 0, 8, FALSE,0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_68K_8",         FALSE, 0, 0x000000ff,FALSE),
     74  HOWTO(R_68K_PC32,       0, 2,32, TRUE, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_68K_PC32",      FALSE, 0, 0xffffffff,TRUE),
     75  HOWTO(R_68K_PC16,       0, 1,16, TRUE, 0, complain_overflow_signed,   bfd_elf_generic_reloc, "R_68K_PC16",      FALSE, 0, 0x0000ffff,TRUE),
     76  HOWTO(R_68K_PC8,        0, 0, 8, TRUE, 0, complain_overflow_signed,   bfd_elf_generic_reloc, "R_68K_PC8",       FALSE, 0, 0x000000ff,TRUE),
     77  HOWTO(R_68K_GOT32,      0, 2,32, TRUE, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_68K_GOT32",     FALSE, 0, 0xffffffff,TRUE),
     78  HOWTO(R_68K_GOT16,      0, 1,16, TRUE, 0, complain_overflow_signed,   bfd_elf_generic_reloc, "R_68K_GOT16",     FALSE, 0, 0x0000ffff,TRUE),
     79  HOWTO(R_68K_GOT8,       0, 0, 8, TRUE, 0, complain_overflow_signed,   bfd_elf_generic_reloc, "R_68K_GOT8",      FALSE, 0, 0x000000ff,TRUE),
     80  HOWTO(R_68K_GOT32O,     0, 2,32, FALSE,0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_68K_GOT32O",    FALSE, 0, 0xffffffff,FALSE),
     81  HOWTO(R_68K_GOT16O,     0, 1,16, FALSE,0, complain_overflow_signed,   bfd_elf_generic_reloc, "R_68K_GOT16O",    FALSE, 0, 0x0000ffff,FALSE),
     82  HOWTO(R_68K_GOT8O,      0, 0, 8, FALSE,0, complain_overflow_signed,   bfd_elf_generic_reloc, "R_68K_GOT8O",     FALSE, 0, 0x000000ff,FALSE),
     83  HOWTO(R_68K_PLT32,      0, 2,32, TRUE, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_68K_PLT32",     FALSE, 0, 0xffffffff,TRUE),
     84  HOWTO(R_68K_PLT16,      0, 1,16, TRUE, 0, complain_overflow_signed,   bfd_elf_generic_reloc, "R_68K_PLT16",     FALSE, 0, 0x0000ffff,TRUE),
     85  HOWTO(R_68K_PLT8,       0, 0, 8, TRUE, 0, complain_overflow_signed,   bfd_elf_generic_reloc, "R_68K_PLT8",      FALSE, 0, 0x000000ff,TRUE),
     86  HOWTO(R_68K_PLT32O,     0, 2,32, FALSE,0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_68K_PLT32O",    FALSE, 0, 0xffffffff,FALSE),
     87  HOWTO(R_68K_PLT16O,     0, 1,16, FALSE,0, complain_overflow_signed,   bfd_elf_generic_reloc, "R_68K_PLT16O",    FALSE, 0, 0x0000ffff,FALSE),
     88  HOWTO(R_68K_PLT8O,      0, 0, 8, FALSE,0, complain_overflow_signed,   bfd_elf_generic_reloc, "R_68K_PLT8O",     FALSE, 0, 0x000000ff,FALSE),
     89  HOWTO(R_68K_COPY,       0, 0, 0, FALSE,0, complain_overflow_dont,     bfd_elf_generic_reloc, "R_68K_COPY",      FALSE, 0, 0xffffffff,FALSE),
     90  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),
     91  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),
     92  HOWTO(R_68K_RELATIVE,   0, 2,32, FALSE,0, complain_overflow_dont,     bfd_elf_generic_reloc, "R_68K_RELATIVE",  FALSE, 0, 0xffffffff,FALSE),
     93  /* GNU extension to record C++ vtable hierarchy. */
    9294  HOWTO (R_68K_GNU_VTINHERIT,   /* type */
    9395         0,                     /* rightshift */
    9496         2,                     /* size (0 = byte, 1 = short, 2 = long) */
    9597         0,                     /* bitsize */
    96          false,                 /* pc_relative */
     98         FALSE,                 /* pc_relative */
    9799         0,                     /* bitpos */
    98100         complain_overflow_dont, /* complain_on_overflow */
    99101         NULL,                  /* special_function */
    100102         "R_68K_GNU_VTINHERIT", /* name */
    101          false,                 /* partial_inplace */
     103         FALSE,                 /* partial_inplace */
    102104         0,                     /* src_mask */
    103105         0,                     /* dst_mask */
    104          false),
    105   /* GNU extension to record C++ vtable member usage */
     106         FALSE),
     107  /* GNU extension to record C++ vtable member usage. */
    106108  HOWTO (R_68K_GNU_VTENTRY,     /* type */
    107109         0,                     /* rightshift */
    108110         2,                     /* size (0 = byte, 1 = short, 2 = long) */
    109111         0,                     /* bitsize */
    110          false,                 /* pc_relative */
     112         FALSE,                 /* pc_relative */
    111113         0,                     /* bitpos */
    112114         complain_overflow_dont, /* complain_on_overflow */
    113115         _bfd_elf_rel_vtable_reloc_fn, /* special_function */
    114116         "R_68K_GNU_VTENTRY",   /* name */
    115          false,                 /* partial_inplace */
     117         FALSE,                 /* partial_inplace */
    116118         0,                     /* src_mask */
    117119         0,                     /* dst_mask */
    118          false),
     120         FALSE),
    119121};
    120122
     
    180182#define bfd_elf32_bfd_reloc_type_lookup reloc_type_lookup
    181183#define ELF_ARCH bfd_arch_m68k
    182 /* end code generated by elf.el */
    183 
    184 #define USE_RELA
    185184
    186185
     
    276275};
    277276
     277#define elf_m68k_hash_entry(ent) ((struct elf_m68k_link_hash_entry *) (ent))
     278
    278279/* m68k ELF linker hash table.  */
    279280
     
    281282{
    282283  struct elf_link_hash_table root;
     284
     285  /* Small local sym to section mapping cache.  */
     286  struct sym_sec_cache sym_sec;
    283287};
    284 
    285 /* Declare this now that the above structures are defined.  */
    286 
    287 static boolean elf_m68k_discard_copies
    288   PARAMS ((struct elf_m68k_link_hash_entry *, PTR));
    289 
    290 /* Traverse an m68k ELF linker hash table.  */
    291 
    292 #define elf_m68k_link_hash_traverse(table, func, info)                  \
    293   (elf_link_hash_traverse                                               \
    294    (&(table)->root,                                                     \
    295     (boolean (*) PARAMS ((struct elf_link_hash_entry *, PTR))) (func),  \
    296     (info)))
    297288
    298289/* Get the m68k ELF linker hash table from a link_info structure.  */
     
    309300     const char *string;
    310301{
    311   struct elf_m68k_link_hash_entry *ret =
    312     (struct elf_m68k_link_hash_entry *) entry;
     302  struct bfd_hash_entry *ret = entry;
    313303
    314304  /* Allocate the structure if it has not already been allocated by a
    315305     subclass.  */
    316   if (ret == (struct elf_m68k_link_hash_entry *) NULL)
    317     ret = ((struct elf_m68k_link_hash_entry *)
    318            bfd_hash_allocate (table,
    319                               sizeof (struct elf_m68k_link_hash_entry)));
    320   if (ret == (struct elf_m68k_link_hash_entry *) NULL)
    321     return (struct bfd_hash_entry *) ret;
     306  if (ret == NULL)
     307    ret = bfd_hash_allocate (table,
     308                             sizeof (struct elf_m68k_link_hash_entry));
     309  if (ret == NULL)
     310    return ret;
    322311
    323312  /* Call the allocation method of the superclass.  */
    324   ret = ((struct elf_m68k_link_hash_entry *)
    325          _bfd_elf_link_hash_newfunc ((struct bfd_hash_entry *) ret,
    326                                      table, string));
    327   if (ret != (struct elf_m68k_link_hash_entry *) NULL)
    328     {
    329       ret->pcrel_relocs_copied = NULL;
    330     }
    331 
    332   return (struct bfd_hash_entry *) ret;
     313  ret = _bfd_elf_link_hash_newfunc (ret, table, string);
     314  if (ret != NULL)
     315    elf_m68k_hash_entry (ret)->pcrel_relocs_copied = NULL;
     316
     317  return ret;
    333318}
    334319
     
    340325{
    341326  struct elf_m68k_link_hash_table *ret;
    342 
    343   ret = ((struct elf_m68k_link_hash_table *)
    344          bfd_alloc (abfd, sizeof (struct elf_m68k_link_hash_table)));
     327  bfd_size_type amt = sizeof (struct elf_m68k_link_hash_table);
     328
     329  ret = (struct elf_m68k_link_hash_table *) bfd_malloc (amt);
    345330  if (ret == (struct elf_m68k_link_hash_table *) NULL)
    346331    return NULL;
     
    349334                                       elf_m68k_link_hash_newfunc))
    350335    {
    351       bfd_release (abfd, ret);
     336      free (ret);
    352337      return NULL;
    353338    }
    354339
     340  ret->sym_sec.abfd = NULL;
     341
    355342  return &ret->root.root;
    356343}
    357344
    358 /* Keep m68k-specific flags in the ELF header */
    359 static boolean
     345/* Keep m68k-specific flags in the ELF header. */
     346static bfd_boolean
    360347elf32_m68k_set_private_flags (abfd, flags)
    361348     bfd *abfd;
     
    363350{
    364351  elf_elfheader (abfd)->e_flags = flags;
    365   elf_flags_init (abfd) = true;
    366   return true;
    367 }
    368 
    369 /* Copy m68k-specific data from one module to another */
    370 static boolean
    371 elf32_m68k_copy_private_bfd_data (ibfd, obfd)
    372      bfd *ibfd;
    373      bfd *obfd;
    374 {
    375   flagword in_flags;
    376 
    377   if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
    378       || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
    379     return true;
    380 
    381   in_flags = elf_elfheader (ibfd)->e_flags;
    382 
    383   elf_elfheader (obfd)->e_flags = in_flags;
    384   elf_flags_init (obfd) = true;
    385 
    386   return true;
     352  elf_flags_init (abfd) = TRUE;
     353  return TRUE;
    387354}
    388355
    389356/* Merge backend specific data from an object file to the output
    390357   object file when linking.  */
    391 static boolean
     358static bfd_boolean
    392359elf32_m68k_merge_private_bfd_data (ibfd, obfd)
    393360     bfd *ibfd;
     
    399366  if (   bfd_get_flavour (ibfd) != bfd_target_elf_flavour
    400367      || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
    401     return true;
     368    return TRUE;
    402369
    403370  in_flags  = elf_elfheader (ibfd)->e_flags;
     
    406373  if (!elf_flags_init (obfd))
    407374    {
    408       elf_flags_init (obfd) = true;
     375      elf_flags_init (obfd) = TRUE;
    409376      elf_elfheader (obfd)->e_flags = in_flags;
    410377    }
    411378
    412   return true;
     379  return TRUE;
    413380}
    414381
    415 /* Display the flags field */
    416 static boolean
     382/* Display the flags field. */
     383static bfd_boolean
    417384elf32_m68k_print_private_bfd_data (abfd, ptr)
    418385     bfd *abfd;
     
    429396
    430397  /* xgettext:c-format */
    431   fprintf (file, _ ("private flags = %lx:"), elf_elfheader (abfd)->e_flags);
     398  fprintf (file, _("private flags = %lx:"), elf_elfheader (abfd)->e_flags);
    432399
    433400  if (elf_elfheader (abfd)->e_flags & EF_CPU32)
    434     fprintf (file, _ (" [cpu32]"));
     401    fprintf (file, _(" [cpu32]"));
     402
     403  if (elf_elfheader (abfd)->e_flags & EF_M68000)
     404    fprintf (file, _(" [m68000]"));
    435405
    436406  fputc ('\n', file);
    437407
    438   return true;
     408  return TRUE;
    439409}
    440410/* Look through the relocs for a section during the first phase, and
     
    442412   table.  */
    443413
    444 static boolean
     414static bfd_boolean
    445415elf_m68k_check_relocs (abfd, info, sec, relocs)
    446416     bfd *abfd;
     
    460430
    461431  if (info->relocateable)
    462     return true;
     432    return TRUE;
    463433
    464434  dynobj = elf_hash_table (info)->dynobj;
     
    503473              elf_hash_table (info)->dynobj = dynobj = abfd;
    504474              if (!_bfd_elf_create_got_section (dynobj, info))
    505                 return false;
     475                return FALSE;
    506476            }
    507477
     
    528498                                                  | SEC_READONLY))
    529499                      || !bfd_set_section_alignment (dynobj, srelgot, 2))
    530                     return false;
     500                    return FALSE;
    531501                }
    532502            }
     
    534504          if (h != NULL)
    535505            {
    536               if (h->got.refcount == -1)
     506              if (h->got.refcount == 0)
    537507                {
    538                   h->got.refcount = 1;
    539 
    540508                  /* Make sure this symbol is output as a dynamic symbol.  */
    541                   if (h->dynindx == -1)
     509                  if (h->dynindx == -1
     510                      && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)
    542511                    {
    543512                      if (!bfd_elf32_link_record_dynamic_symbol (info, h))
    544                         return false;
     513                        return FALSE;
    545514                    }
    546515
     
    550519                  srelgot->_raw_size += sizeof (Elf32_External_Rela);
    551520                }
    552               else
    553                 h->got.refcount++;
     521              h->got.refcount++;
    554522            }
    555523          else
     
    558526              if (local_got_refcounts == NULL)
    559527                {
    560                   size_t size;
    561 
    562                   size = symtab_hdr->sh_info * sizeof (bfd_signed_vma);
     528                  bfd_size_type size;
     529
     530                  size = symtab_hdr->sh_info;
     531                  size *= sizeof (bfd_signed_vma);
    563532                  local_got_refcounts = ((bfd_signed_vma *)
    564                                          bfd_alloc (abfd, size));
     533                                         bfd_zalloc (abfd, size));
    565534                  if (local_got_refcounts == NULL)
    566                     return false;
     535                    return FALSE;
    567536                  elf_local_got_refcounts (abfd) = local_got_refcounts;
    568                   memset (local_got_refcounts, -1, size);
    569537                }
    570               if (local_got_refcounts[r_symndx] == -1)
     538              if (local_got_refcounts[r_symndx] == 0)
    571539                {
    572                   local_got_refcounts[r_symndx] = 1;
    573 
    574540                  sgot->_raw_size += 4;
    575541                  if (info->shared)
     
    581547                    }
    582548                }
    583               else
    584                 local_got_refcounts[r_symndx]++;
     549              local_got_refcounts[r_symndx]++;
    585550            }
    586551          break;
     
    602567
    603568          h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT;
    604           if (h->plt.refcount == -1)
    605             h->plt.refcount = 1;
    606           else
    607             h->plt.refcount++;
     569          h->plt.refcount++;
    608570          break;
    609571
     
    619581                 it does make sense?  */
    620582              bfd_set_error (bfd_error_bad_value);
    621               return false;
     583              return FALSE;
    622584            }
    623585
    624586          /* Make sure this symbol is output as a dynamic symbol.  */
    625           if (h->dynindx == -1)
     587          if (h->dynindx == -1
     588              && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)
    626589            {
    627590              if (!bfd_elf32_link_record_dynamic_symbol (info, h))
    628                 return false;
     591                return FALSE;
    629592            }
    630593
    631594          h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT;
    632           if (h->plt.refcount == -1)
    633             h->plt.refcount = 1;
    634           else
    635             h->plt.refcount++;
     595          h->plt.refcount++;
    636596          break;
    637597
     
    653613                && h != NULL
    654614                && (!info->symbolic
     615                    || h->root.type == bfd_link_hash_defweak
    655616                    || (h->elf_link_hash_flags
    656617                        & ELF_LINK_HASH_DEF_REGULAR) == 0)))
     
    661622                     it turns out to be a function defined by a dynamic
    662623                     object.  */
    663                   if (h->plt.refcount == -1)
    664                     h->plt.refcount = 1;
    665                   else
    666                     h->plt.refcount++;
     624                  h->plt.refcount++;
    667625                }
    668626              break;
     
    676634              /* Make sure a plt entry is created for this symbol if it
    677635                 turns out to be a function defined by a dynamic object.  */
    678               if (h->plt.refcount == -1)
    679                 h->plt.refcount = 1;
    680               else
    681                 h->plt.refcount++;
     636              h->plt.refcount++;
    682637            }
    683638
     
    699654                           elf_section_data (sec)->rel_hdr.sh_name));
    700655                  if (name == NULL)
    701                     return false;
     656                    return FALSE;
    702657
    703658                  BFD_ASSERT (strncmp (name, ".rela", 5) == 0
     
    718673                                                      | SEC_READONLY))
    719674                          || !bfd_set_section_alignment (dynobj, sreloc, 2))
    720                         return false;
     675                        return FALSE;
    721676                    }
    722677                }
    723678
     679              if (sec->flags & SEC_READONLY
     680                  /* Don't set DF_TEXTREL yet for PC relative
     681                     relocations, they might be discarded later.  */
     682                  && !(ELF32_R_TYPE (rel->r_info) == R_68K_PC8
     683                       || ELF32_R_TYPE (rel->r_info) == R_68K_PC16
     684                       || ELF32_R_TYPE (rel->r_info) == R_68K_PC32))
     685                    info->flags |= DF_TEXTREL;
     686
    724687              sreloc->_raw_size += sizeof (Elf32_External_Rela);
    725688
    726               /* If we are linking with -Bsymbolic, we count the number of
    727                  PC relative relocations we have entered for this symbol,
    728                  so that we can discard them again if the symbol is later
    729                  defined by a regular object.  Note that this function is
    730                  only called if we are using an m68kelf linker hash table,
    731                  which means that h is really a pointer to an
     689              /* We count the number of PC relative relocations we have
     690                 entered for this symbol, so that we can discard them
     691                 again if, in the -Bsymbolic case, the symbol is later
     692                 defined by a regular object, or, in the normal shared
     693                 case, the symbol is forced to be local.  Note that this
     694                 function is only called if we are using an m68kelf linker
     695                 hash table, which means that h is really a pointer to an
    732696                 elf_m68k_link_hash_entry.  */
    733               if ((ELF32_R_TYPE (rel->r_info) == R_68K_PC8
    734                    || ELF32_R_TYPE (rel->r_info) == R_68K_PC16
    735                    || ELF32_R_TYPE (rel->r_info) == R_68K_PC32)
    736                   && info->symbolic)
     697              if (ELF32_R_TYPE (rel->r_info) == R_68K_PC8
     698                  || ELF32_R_TYPE (rel->r_info) == R_68K_PC16
     699                  || ELF32_R_TYPE (rel->r_info) == R_68K_PC32)
    737700                {
    738                   struct elf_m68k_link_hash_entry *eh;
    739701                  struct elf_m68k_pcrel_relocs_copied *p;
    740 
    741                   eh = (struct elf_m68k_link_hash_entry *) h;
    742 
    743                   for (p = eh->pcrel_relocs_copied; p != NULL; p = p->next)
     702                  struct elf_m68k_pcrel_relocs_copied **head;
     703
     704                  if (h != NULL)
     705                    {
     706                      struct elf_m68k_link_hash_entry *eh
     707                        = elf_m68k_hash_entry (h);
     708                      head = &eh->pcrel_relocs_copied;
     709                    }
     710                  else
     711                    {
     712                      asection *s;
     713                      s = (bfd_section_from_r_symndx
     714                           (abfd, &elf_m68k_hash_table (info)->sym_sec,
     715                            sec, r_symndx));
     716                      if (s == NULL)
     717                        return FALSE;
     718
     719                      head = ((struct elf_m68k_pcrel_relocs_copied **)
     720                              &elf_section_data (s)->local_dynrel);
     721                    }
     722
     723                  for (p = *head; p != NULL; p = p->next)
    744724                    if (p->section == sreloc)
    745725                      break;
     
    748728                    {
    749729                      p = ((struct elf_m68k_pcrel_relocs_copied *)
    750                            bfd_alloc (dynobj, sizeof *p));
     730                           bfd_alloc (dynobj, (bfd_size_type) sizeof *p));
    751731                      if (p == NULL)
    752                         return false;
    753                       p->next = eh->pcrel_relocs_copied;
    754                       eh->pcrel_relocs_copied = p;
     732                        return FALSE;
     733                      p->next = *head;
     734                      *head = p;
    755735                      p->section = sreloc;
    756736                      p->count = 0;
     
    767747        case R_68K_GNU_VTINHERIT:
    768748          if (!_bfd_elf32_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
    769             return false;
     749            return FALSE;
    770750          break;
    771751
     
    774754        case R_68K_GNU_VTENTRY:
    775755          if (!_bfd_elf32_gc_record_vtentry (abfd, sec, h, rel->r_addend))
    776             return false;
     756            return FALSE;
    777757          break;
    778758
     
    782762    }
    783763
    784   return true;
     764  return TRUE;
    785765}
    786766
     
    789769
    790770static asection *
    791 elf_m68k_gc_mark_hook (abfd, info, rel, h, sym)
    792      bfd *abfd;
     771elf_m68k_gc_mark_hook (sec, info, rel, h, sym)
     772     asection *sec;
    793773     struct bfd_link_info *info ATTRIBUTE_UNUSED;
    794774     Elf_Internal_Rela *rel;
     
    820800    }
    821801  else
    822     {
    823       if (!(elf_bad_symtab (abfd)
    824             && ELF_ST_BIND (sym->st_info) != STB_LOCAL)
    825           && ! ((sym->st_shndx <= 0 || sym->st_shndx >= SHN_LORESERVE)
    826                 && sym->st_shndx != SHN_COMMON))
    827         {
    828           return bfd_section_from_elf_index (abfd, sym->st_shndx);
    829         }
    830     }
     802    return bfd_section_from_elf_index (sec->owner, sym->st_shndx);
    831803
    832804  return NULL;
     
    835807/* Update the got entry reference counts for the section being removed.  */
    836808
    837 static boolean
     809static bfd_boolean
    838810elf_m68k_gc_sweep_hook (abfd, info, sec, relocs)
    839811     bfd *abfd;
     
    858830  dynobj = elf_hash_table (info)->dynobj;
    859831  if (dynobj == NULL)
    860     return true;
     832    return TRUE;
    861833
    862834  sgot = bfd_get_section_by_name (dynobj, ".got");
     
    931903    }
    932904
    933   return true;
     905  return TRUE;
    934906}
    935907
     
    940912   understand.  */
    941913
    942 static boolean
     914static bfd_boolean
    943915elf_m68k_adjust_dynamic_symbol (info, h)
    944916     struct bfd_link_info *info;
     
    983955          BFD_ASSERT ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0);
    984956          h->plt.offset = (bfd_vma) -1;
    985           return true;
     957          return TRUE;
    986958        }
    987959
     
    991963          h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
    992964          h->plt.offset = (bfd_vma) -1;
    993           return true;
     965          return TRUE;
    994966        }
    995967
    996968      /* Make sure this symbol is output as a dynamic symbol.  */
    997       if (h->dynindx == -1)
     969      if (h->dynindx == -1
     970          && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)
    998971        {
    999972          if (! bfd_elf32_link_record_dynamic_symbol (info, h))
    1000             return false;
     973            return FALSE;
    1001974        }
    1002975
     
    10361009      /* We also need to make an entry in the .got.plt section, which
    10371010         will be placed in the .got section by the linker script.  */
    1038 
    10391011      s = bfd_get_section_by_name (dynobj, ".got.plt");
    10401012      BFD_ASSERT (s != NULL);
     
    10421014
    10431015      /* We also need to make an entry in the .rela.plt section.  */
    1044 
    10451016      s = bfd_get_section_by_name (dynobj, ".rela.plt");
    10461017      BFD_ASSERT (s != NULL);
    10471018      s->_raw_size += sizeof (Elf32_External_Rela);
    10481019
    1049       return true;
     1020      return TRUE;
    10501021    }
    10511022
     
    10631034      h->root.u.def.section = h->weakdef->root.u.def.section;
    10641035      h->root.u.def.value = h->weakdef->root.u.def.value;
    1065       return true;
     1036      return TRUE;
    10661037    }
    10671038
     
    10741045     be handled correctly by relocate_section.  */
    10751046  if (info->shared)
    1076     return true;
     1047    return TRUE;
    10771048
    10781049  /* We must allocate the symbol in our .dynbss section, which will
     
    11151086    {
    11161087      if (!bfd_set_section_alignment (dynobj, s, power_of_two))
    1117         return false;
     1088        return FALSE;
    11181089    }
    11191090
     
    11251096  s->_raw_size += h->size;
    11261097
    1127   return true;
     1098  return TRUE;
    11281099}
    11291100
     1101/* This is the condition under which elf_m68k_finish_dynamic_symbol
     1102   will be called from elflink.h.  If elflink.h doesn't call our
     1103   finish_dynamic_symbol routine, we'll need to do something about
     1104   initializing any .plt and .got entries in elf_m68k_relocate_section.  */
     1105#define WILL_CALL_FINISH_DYNAMIC_SYMBOL(DYN, SHARED, H) \
     1106  ((DYN)                                                                \
     1107   && ((SHARED)                                                         \
     1108       || ((H)->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)      \
     1109   && ((H)->dynindx != -1                                               \
     1110       || ((H)->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0))
     1111
    11301112/* Set the sizes of the dynamic sections.  */
    11311113
    1132 static boolean
     1114static bfd_boolean
    11331115elf_m68k_size_dynamic_sections (output_bfd, info)
    1134      bfd *output_bfd;
     1116     bfd *output_bfd ATTRIBUTE_UNUSED;
    11351117     struct bfd_link_info *info;
    11361118{
    11371119  bfd *dynobj;
    11381120  asection *s;
    1139   boolean plt;
    1140   boolean relocs;
    1141   boolean reltext;
     1121  bfd_boolean plt;
     1122  bfd_boolean relocs;
    11421123
    11431124  dynobj = elf_hash_table (info)->dynobj;
     
    11671148    }
    11681149
    1169   /* If this is a -Bsymbolic shared link, then we need to discard all PC
    1170      relative relocs against symbols defined in a regular object.  We
    1171      allocated space for them in the check_relocs routine, but we will not
    1172      fill them in in the relocate_section routine.  */
    1173   if (info->shared && info->symbolic)
    1174     elf_m68k_link_hash_traverse (elf_m68k_hash_table (info),
    1175                                  elf_m68k_discard_copies,
    1176                                  (PTR) NULL);
     1150  /* If this is a -Bsymbolic shared link, then we need to discard all
     1151     PC relative relocs against symbols defined in a regular object.
     1152     For the normal shared case we discard the PC relative relocs
     1153     against symbols that have become local due to visibility changes.
     1154     We allocated space for them in the check_relocs routine, but we
     1155     will not fill them in in the relocate_section routine.  */
     1156  if (info->shared)
     1157    elf_link_hash_traverse (elf_hash_table (info),
     1158                            elf_m68k_discard_copies,
     1159                            (PTR) info);
    11771160
    11781161  /* The check_relocs and adjust_dynamic_symbol entry points have
    11791162     determined the sizes of the various dynamic sections.  Allocate
    11801163     memory for them.  */
    1181   plt = false;
    1182   relocs = false;
    1183   reltext = false;
     1164  plt = FALSE;
     1165  relocs = FALSE;
    11841166  for (s = dynobj->sections; s != NULL; s = s->next)
    11851167    {
    11861168      const char *name;
    1187       boolean strip;
     1169      bfd_boolean strip;
    11881170
    11891171      if ((s->flags & SEC_LINKER_CREATED) == 0)
     
    11941176      name = bfd_get_section_name (dynobj, s);
    11951177
    1196       strip = false;
     1178      strip = FALSE;
    11971179
    11981180      if (strcmp (name, ".plt") == 0)
     
    12021184              /* Strip this section if we don't need it; see the
    12031185                 comment below.  */
    1204               strip = true;
     1186              strip = TRUE;
    12051187            }
    12061188          else
    12071189            {
    12081190              /* Remember whether there is a PLT.  */
    1209               plt = true;
     1191              plt = TRUE;
    12101192            }
    12111193        }
     
    12231205                 function which decides whether anything needs to go
    12241206                 into these sections.  */
    1225               strip = true;
     1207              strip = TRUE;
    12261208            }
    12271209          else
    12281210            {
    1229               asection *target;
    1230 
    1231               /* Remember whether there are any reloc sections other
    1232                  than .rela.plt.  */
    1233               if (strcmp (name, ".rela.plt") != 0)
    1234                 {
    1235                   const char *outname;
    1236 
    1237                   relocs = true;
    1238 
    1239                   /* If this relocation section applies to a read only
    1240                      section, then we probably need a DT_TEXTREL
    1241                      entry.  .rela.plt is actually associated with
    1242                      .got.plt, which is never readonly.  */
    1243                   outname = bfd_get_section_name (output_bfd,
    1244                                                   s->output_section);
    1245                   target = bfd_get_section_by_name (output_bfd, outname + 5);
    1246                   if (target != NULL
    1247                       && (target->flags & SEC_READONLY) != 0
    1248                       && (target->flags & SEC_ALLOC) != 0)
    1249                     reltext = true;
    1250                 }
     1211              relocs = TRUE;
    12511212
    12521213              /* We use the reloc_count field as a counter if we need
     
    12751236      s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->_raw_size);
    12761237      if (s->contents == NULL && s->_raw_size != 0)
    1277         return false;
     1238        return FALSE;
    12781239    }
    12791240
     
    12851246         the .dynamic section.  The DT_DEBUG entry is filled in by the
    12861247         dynamic linker and used by the debugger.  */
     1248#define add_dynamic_entry(TAG, VAL) \
     1249  bfd_elf32_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL))
     1250
    12871251      if (!info->shared)
    12881252        {
    1289           if (!bfd_elf32_add_dynamic_entry (info, DT_DEBUG, 0))
    1290             return false;
     1253          if (!add_dynamic_entry (DT_DEBUG, 0))
     1254            return FALSE;
    12911255        }
    12921256
    12931257      if (plt)
    12941258        {
    1295           if (!bfd_elf32_add_dynamic_entry (info, DT_PLTGOT, 0)
    1296               || !bfd_elf32_add_dynamic_entry (info, DT_PLTRELSZ, 0)
    1297               || !bfd_elf32_add_dynamic_entry (info, DT_PLTREL, DT_RELA)
    1298               || !bfd_elf32_add_dynamic_entry (info, DT_JMPREL, 0))
    1299             return false;
     1259          if (!add_dynamic_entry (DT_PLTGOT, 0)
     1260              || !add_dynamic_entry (DT_PLTRELSZ, 0)
     1261              || !add_dynamic_entry (DT_PLTREL, DT_RELA)
     1262              || !add_dynamic_entry (DT_JMPREL, 0))
     1263            return FALSE;
    13001264        }
    13011265
    13021266      if (relocs)
    13031267        {
    1304           if (!bfd_elf32_add_dynamic_entry (info, DT_RELA, 0)
    1305               || !bfd_elf32_add_dynamic_entry (info, DT_RELASZ, 0)
    1306               || !bfd_elf32_add_dynamic_entry (info, DT_RELAENT,
    1307                                                sizeof (Elf32_External_Rela)))
    1308             return false;
    1309         }
    1310 
    1311       if (reltext)
    1312         {
    1313           if (!bfd_elf32_add_dynamic_entry (info, DT_TEXTREL, 0))
    1314             return false;
    1315           info->flags |= DF_TEXTREL;
     1268          if (!add_dynamic_entry (DT_RELA, 0)
     1269              || !add_dynamic_entry (DT_RELASZ, 0)
     1270              || !add_dynamic_entry (DT_RELAENT, sizeof (Elf32_External_Rela)))
     1271            return FALSE;
     1272        }
     1273
     1274      if ((info->flags & DF_TEXTREL) != 0)
     1275        {
     1276          if (!add_dynamic_entry (DT_TEXTREL, 0))
     1277            return FALSE;
    13161278        }
    13171279    }
    1318 
    1319   return true;
     1280#undef add_dynamic_entry
     1281
     1282  return TRUE;
    13201283}
    13211284
    1322 /* This function is called via elf_m68k_link_hash_traverse if we are
    1323    creating a shared object with -Bsymbolic.  It discards the space
    1324    allocated to copy PC relative relocs against symbols which are defined
    1325    in regular objects.  We allocated space for them in the check_relocs
    1326    routine, but we won't fill them in in the relocate_section routine.  */
    1327 
    1328 static boolean
    1329 elf_m68k_discard_copies (h, ignore)
    1330      struct elf_m68k_link_hash_entry *h;
    1331      PTR ignore ATTRIBUTE_UNUSED;
    1332 {
     1285/* This function is called via elf_link_hash_traverse if we are
     1286   creating a shared object.  In the -Bsymbolic case it discards the
     1287   space allocated to copy PC relative relocs against symbols which
     1288   are defined in regular objects.  For the normal shared case, it
     1289   discards space for pc-relative relocs that have become local due to
     1290   symbol visibility changes.  We allocated space for them in the
     1291   check_relocs routine, but we won't fill them in in the
     1292   relocate_section routine.
     1293
     1294   We also check whether any of the remaining relocations apply
     1295   against a readonly section, and set the DF_TEXTREL flag in this
     1296   case.  */
     1297
     1298static bfd_boolean
     1299elf_m68k_discard_copies (h, inf)
     1300     struct elf_link_hash_entry *h;
     1301     PTR inf;
     1302{
     1303  struct bfd_link_info *info = (struct bfd_link_info *) inf;
    13331304  struct elf_m68k_pcrel_relocs_copied *s;
    13341305
    1335   /* We only discard relocs for symbols defined in a regular object.  */
    1336   if ((h->root.elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
    1337     return true;
    1338 
    1339   for (s = h->pcrel_relocs_copied; s != NULL; s = s->next)
     1306  if (h->root.type == bfd_link_hash_warning)
     1307    h = (struct elf_link_hash_entry *) h->root.u.i.link;
     1308
     1309  if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0
     1310      || (!info->symbolic
     1311          && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0))
     1312    {
     1313      if ((info->flags & DF_TEXTREL) == 0)
     1314        {
     1315          /* Look for relocations against read-only sections.  */
     1316          for (s = elf_m68k_hash_entry (h)->pcrel_relocs_copied;
     1317               s != NULL;
     1318               s = s->next)
     1319            if ((s->section->flags & SEC_READONLY) != 0)
     1320              {
     1321                info->flags |= DF_TEXTREL;
     1322                break;
     1323              }
     1324        }
     1325
     1326      return TRUE;
     1327    }
     1328
     1329  for (s = elf_m68k_hash_entry (h)->pcrel_relocs_copied;
     1330       s != NULL;
     1331       s = s->next)
    13401332    s->section->_raw_size -= s->count * sizeof (Elf32_External_Rela);
    13411333
    1342   return true;
     1334  return TRUE;
    13431335}
    13441336
    13451337/* Relocate an M68K ELF section.  */
    13461338
    1347 static boolean
     1339static bfd_boolean
    13481340elf_m68k_relocate_section (output_bfd, info, input_bfd, input_section,
    13491341                           contents, relocs, local_syms, local_sections)
     
    13661358  Elf_Internal_Rela *rel;
    13671359  Elf_Internal_Rela *relend;
     1360
     1361  if (info->relocateable)
     1362    return TRUE;
    13681363
    13691364  dynobj = elf_hash_table (info)->dynobj;
     
    13931388        {
    13941389          bfd_set_error (bfd_error_bad_value);
    1395           return false;
     1390          return FALSE;
    13961391        }
    13971392      howto = howto_table + r_type;
     
    13991394      r_symndx = ELF32_R_SYM (rel->r_info);
    14001395
    1401       if (info->relocateable)
    1402         {
    1403           /* This is a relocateable link.  We don't have to change
    1404              anything, unless the reloc is against a section symbol,
    1405              in which case we have to adjust according to where the
    1406              section symbol winds up in the output section.  */
    1407           if (r_symndx < symtab_hdr->sh_info)
    1408             {
    1409               sym = local_syms + r_symndx;
    1410               if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
    1411                 {
    1412                   sec = local_sections[r_symndx];
    1413                   rel->r_addend += sec->output_offset + sym->st_value;
    1414                 }
    1415             }
    1416 
    1417           continue;
    1418         }
    1419 
    1420       /* This is a final link.  */
    14211396      h = NULL;
    14221397      sym = NULL;
     
    14261401          sym = local_syms + r_symndx;
    14271402          sec = local_sections[r_symndx];
    1428           relocation = (sec->output_section->vma
    1429                         + sec->output_offset
    1430                         + sym->st_value);
     1403          relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
    14311404        }
    14321405      else
     
    14561429                           && strcmp (h->root.root.string,
    14571430                                      "_GLOBAL_OFFSET_TABLE_") != 0))
    1458                       && elf_hash_table (info)->dynamic_sections_created
     1431                      && (WILL_CALL_FINISH_DYNAMIC_SYMBOL
     1432                          (elf_hash_table (info)->dynamic_sections_created,
     1433                           info->shared, h))
    14591434                      && (! info->shared
    1460                           || (! info->symbolic && h->dynindx != -1)
     1435                          || (! info->symbolic
     1436                              && h->dynindx != -1
     1437                              && (h->elf_link_hash_flags
     1438                                  & ELF_LINK_FORCED_LOCAL) == 0)
    14611439                          || (h->elf_link_hash_flags
    14621440                              & ELF_LINK_HASH_DEF_REGULAR) == 0))
     
    14921470          else if (h->root.type == bfd_link_hash_undefweak)
    14931471            relocation = 0;
    1494           else if (info->shared && !info->symbolic
     1472          else if (info->shared
    14951473                   && !info->no_undefined
    14961474                   && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
     
    15031481                     (!info->shared || info->no_undefined
    15041482                      || ELF_ST_VISIBILITY (h->other)))))
    1505                 return false;
     1483                return FALSE;
    15061484              relocation = 0;
    15071485            }
     
    15361514            if (h != NULL)
    15371515              {
     1516                bfd_boolean dyn;
     1517
    15381518                off = h->got.offset;
    15391519                BFD_ASSERT (off != (bfd_vma) -1);
    15401520
    1541                 if (!elf_hash_table (info)->dynamic_sections_created
     1521                dyn = elf_hash_table (info)->dynamic_sections_created;
     1522                if (!WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h)
    15421523                    || (info->shared
    1543                         && (info->symbolic || h->dynindx == -1)
    1544                         && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)))
     1524                        && (info->symbolic
     1525                            || h->dynindx == -1
     1526                            || (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0)
     1527                        && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)) != 0)
    15451528                  {
    15461529                    /* This is actually a static link, or it is a
     
    15841567                    if (info->shared)
    15851568                      {
    1586                         asection *srelgot;
     1569                        asection *s;
    15871570                        Elf_Internal_Rela outrel;
    1588 
    1589                         srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
    1590                         BFD_ASSERT (srelgot != NULL);
     1571                        bfd_byte *loc;
     1572
     1573                        s = bfd_get_section_by_name (dynobj, ".rela.got");
     1574                        BFD_ASSERT (s != NULL);
    15911575
    15921576                        outrel.r_offset = (sgot->output_section->vma
     
    15951579                        outrel.r_info = ELF32_R_INFO (0, R_68K_RELATIVE);
    15961580                        outrel.r_addend = relocation;
    1597                         bfd_elf32_swap_reloca_out (output_bfd, &outrel,
    1598                                                    (((Elf32_External_Rela *)
    1599                                                      srelgot->contents)
    1600                                                     + srelgot->reloc_count));
    1601                         ++srelgot->reloc_count;
     1581                        loc = s->contents;
     1582                        loc += s->reloc_count++ * sizeof (Elf32_External_Rela);
     1583                        bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
    16021584                      }
    16031585
     
    16731655        case R_68K_PC16:
    16741656        case R_68K_PC32:
    1675           if (h == NULL)
     1657          if (h == NULL
     1658              || (info->shared
     1659                  && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0))
    16761660            break;
    16771661          /* Fall through.  */
     
    16801664        case R_68K_32:
    16811665          if (info->shared
     1666              && r_symndx != 0
    16821667              && (input_section->flags & SEC_ALLOC) != 0
    16831668              && ((r_type != R_68K_PC8
     
    16891674            {
    16901675              Elf_Internal_Rela outrel;
    1691               boolean skip, relocate;
     1676              bfd_byte *loc;
     1677              bfd_boolean skip, relocate;
    16921678
    16931679              /* When generating a shared object, these relocations
     
    17041690                           elf_section_data (input_section)->rel_hdr.sh_name));
    17051691                  if (name == NULL)
    1706                     return false;
     1692                    return FALSE;
    17071693
    17081694                  BFD_ASSERT (strncmp (name, ".rela", 5) == 0
     
    17151701                }
    17161702
    1717               skip = false;
    1718 
    1719               if (elf_section_data (input_section)->stab_info == NULL)
    1720                 outrel.r_offset = rel->r_offset;
    1721               else
    1722                 {
    1723                   bfd_vma off;
    1724 
    1725                   off = (_bfd_stab_section_offset
    1726                          (output_bfd, &elf_hash_table (info)->stab_info,
    1727                           input_section,
    1728                           &elf_section_data (input_section)->stab_info,
    1729                           rel->r_offset));
    1730                   if (off == (bfd_vma) -1)
    1731                     skip = true;
    1732                   outrel.r_offset = off;
    1733                 }
    1734 
     1703              skip = FALSE;
     1704              relocate = FALSE;
     1705
     1706              outrel.r_offset =
     1707                _bfd_elf_section_offset (output_bfd, info, input_section,
     1708                                         rel->r_offset);
     1709              if (outrel.r_offset == (bfd_vma) -1)
     1710                skip = TRUE;
     1711              else if (outrel.r_offset == (bfd_vma) -2)
     1712                skip = TRUE, relocate = TRUE;
    17351713              outrel.r_offset += (input_section->output_section->vma
    17361714                                  + input_section->output_offset);
    17371715
    17381716              if (skip)
    1739                 {
    1740                   memset (&outrel, 0, sizeof outrel);
    1741                   relocate = false;
    1742                 }
     1717                memset (&outrel, 0, sizeof outrel);
    17431718              /* h->dynindx may be -1 if the symbol was marked to
    17441719                 become local.  */
     
    17491724                {
    17501725                  BFD_ASSERT (h->dynindx != -1);
    1751                   relocate = false;
    17521726                  outrel.r_info = ELF32_R_INFO (h->dynindx, r_type);
    17531727                  outrel.r_addend = relocation + rel->r_addend;
     
    17571731                  if (r_type == R_68K_32)
    17581732                    {
    1759                       relocate = true;
     1733                      relocate = TRUE;
    17601734                      outrel.r_info = ELF32_R_INFO (0, R_68K_RELATIVE);
    17611735                      outrel.r_addend = relocation + rel->r_addend;
     
    17791753                        {
    17801754                          bfd_set_error (bfd_error_bad_value);
    1781                           return false;
     1755                          return FALSE;
    17821756                        }
    17831757                      else
     
    17901764                        }
    17911765
    1792                       relocate = false;
    17931766                      outrel.r_info = ELF32_R_INFO (indx, r_type);
    17941767                      outrel.r_addend = relocation + rel->r_addend;
     
    17961769                }
    17971770
    1798               bfd_elf32_swap_reloca_out (output_bfd, &outrel,
    1799                                          (((Elf32_External_Rela *)
    1800                                            sreloc->contents)
    1801                                           + sreloc->reloc_count));
    1802               ++sreloc->reloc_count;
     1771              loc = sreloc->contents;
     1772              loc += sreloc->reloc_count++ * sizeof (Elf32_External_Rela);
     1773              bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
    18031774
    18041775              /* This reloc will be computed at runtime, so there's no
     
    18441815                                                            sym->st_name);
    18451816                    if (name == NULL)
    1846                       return false;
     1817                      return FALSE;
    18471818                    if (*name == '\0')
    18481819                      name = bfd_section_name (input_bfd, sec);
     
    18511822                      (info, name, howto->name, (bfd_vma) 0,
    18521823                       input_bfd, input_section, rel->r_offset)))
    1853                   return false;
     1824                  return FALSE;
    18541825              }
    18551826              break;
     
    18581829    }
    18591830
    1860   return true;
     1831  return TRUE;
    18611832}
    18621833
     
    18641835   dynamic sections here.  */
    18651836
    1866 static boolean
     1837static bfd_boolean
    18671838elf_m68k_finish_dynamic_symbol (output_bfd, info, h, sym)
    18681839     bfd *output_bfd;
     
    18841855      bfd_vma got_offset;
    18851856      Elf_Internal_Rela rela;
     1857      bfd_byte *loc;
    18861858
    18871859      /* This symbol has an entry in the procedure linkage table.  Set
     
    19561928      rela.r_info = ELF32_R_INFO (h->dynindx, R_68K_JMP_SLOT);
    19571929      rela.r_addend = 0;
    1958       bfd_elf32_swap_reloca_out (output_bfd, &rela,
    1959                                  ((Elf32_External_Rela *) srela->contents
    1960                                   + plt_index));
     1930      loc = srela->contents + plt_index * sizeof (Elf32_External_Rela);
     1931      bfd_elf32_swap_reloca_out (output_bfd, &rela, loc);
    19611932
    19621933      if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
     
    19731944      asection *srela;
    19741945      Elf_Internal_Rela rela;
     1946      bfd_byte *loc;
    19751947
    19761948      /* This symbol has an entry in the global offset table.  Set it
     
    19831955      rela.r_offset = (sgot->output_section->vma
    19841956                       + sgot->output_offset
    1985                        + (h->got.offset &~ 1));
     1957                       + (h->got.offset &~ (bfd_vma) 1));
    19861958
    19871959      /* If this is a -Bsymbolic link, and the symbol is defined
     
    19911963         initialized in the relocate_section function.  */
    19921964      if (info->shared
    1993           && (info->symbolic || h->dynindx == -1)
     1965          && (info->symbolic
     1966              || h->dynindx == -1
     1967              || (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0)
    19941968          && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR))
    19951969        {
     
    19971971          rela.r_addend = bfd_get_signed_32 (output_bfd,
    19981972                                             (sgot->contents
    1999                                               + (h->got.offset & ~1)));
     1973                                              + (h->got.offset &~ (bfd_vma) 1)));
    20001974        }
    20011975      else
    20021976        {
    20031977          bfd_put_32 (output_bfd, (bfd_vma) 0,
    2004                       sgot->contents + (h->got.offset & ~1));
     1978                      sgot->contents + (h->got.offset &~ (bfd_vma) 1));
    20051979          rela.r_info = ELF32_R_INFO (h->dynindx, R_68K_GLOB_DAT);
    20061980          rela.r_addend = 0;
    20071981        }
    20081982
    2009       bfd_elf32_swap_reloca_out (output_bfd, &rela,
    2010                                  ((Elf32_External_Rela *) srela->contents
    2011                                   + srela->reloc_count));
    2012       ++srela->reloc_count;
     1983      loc = srela->contents;
     1984      loc += srela->reloc_count++ * sizeof (Elf32_External_Rela);
     1985      bfd_elf32_swap_reloca_out (output_bfd, &rela, loc);
    20131986    }
    20141987
     
    20171990      asection *s;
    20181991      Elf_Internal_Rela rela;
     1992      bfd_byte *loc;
    20191993
    20201994      /* This symbol needs a copy reloc.  Set it up.  */
     
    20332007      rela.r_info = ELF32_R_INFO (h->dynindx, R_68K_COPY);
    20342008      rela.r_addend = 0;
    2035       bfd_elf32_swap_reloca_out (output_bfd, &rela,
    2036                                  ((Elf32_External_Rela *) s->contents
    2037                                   + s->reloc_count));
    2038       ++s->reloc_count;
     2009      loc = s->contents + s->reloc_count++ * sizeof (Elf32_External_Rela);
     2010      bfd_elf32_swap_reloca_out (output_bfd, &rela, loc);
    20392011    }
    20402012
     
    20442016    sym->st_shndx = SHN_ABS;
    20452017
    2046   return true;
     2018  return TRUE;
    20472019}
    20482020
    20492021/* Finish up the dynamic sections.  */
    20502022
    2051 static boolean
     2023static bfd_boolean
    20522024elf_m68k_finish_dynamic_sections (output_bfd, info)
    20532025     bfd *output_bfd;
     
    21832155  elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 4;
    21842156
    2185   return true;
     2157  return TRUE;
    21862158}
    21872159
     
    21932165   objects, and before the final_link entry point is called.  */
    21942166
    2195 boolean
     2167bfd_boolean
    21962168bfd_m68k_elf32_create_embedded_relocs (abfd, info, datasec, relsec, errmsg)
    21972169     bfd *abfd;
     
    22022174{
    22032175  Elf_Internal_Shdr *symtab_hdr;
    2204   Elf32_External_Sym *extsyms;
    2205   Elf32_External_Sym *free_extsyms = NULL;
    2206   Elf_Internal_Rela *internal_relocs;
    2207   Elf_Internal_Rela *free_relocs = NULL;
     2176  Elf_Internal_Sym *isymbuf = NULL;
     2177  Elf_Internal_Rela *internal_relocs = NULL;
    22082178  Elf_Internal_Rela *irel, *irelend;
    22092179  bfd_byte *p;
     2180  bfd_size_type amt;
    22102181
    22112182  BFD_ASSERT (! info->relocateable);
     
    22142185
    22152186  if (datasec->reloc_count == 0)
    2216     return true;
     2187    return TRUE;
    22172188
    22182189  symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
    2219   /* Read this BFD's symbols if we haven't done so already, or get the cached
    2220      copy if it exists.  */
    2221   if (symtab_hdr->contents != NULL)
    2222     extsyms = (Elf32_External_Sym *) symtab_hdr->contents;
    2223   else
    2224     {
    2225       /* Go get them off disk.  */
    2226       if (info->keep_memory)
    2227         extsyms = ((Elf32_External_Sym *)
    2228                    bfd_alloc (abfd, symtab_hdr->sh_size));
    2229       else
    2230         extsyms = ((Elf32_External_Sym *)
    2231                    bfd_malloc (symtab_hdr->sh_size));
    2232       if (extsyms == NULL)
    2233         goto error_return;
    2234       if (! info->keep_memory)
    2235         free_extsyms = extsyms;
    2236       if (bfd_seek (abfd, symtab_hdr->sh_offset, SEEK_SET) != 0
    2237           || (bfd_read (extsyms, 1, symtab_hdr->sh_size, abfd)
    2238               != symtab_hdr->sh_size))
    2239         goto error_return;
    2240       if (info->keep_memory)
    2241         symtab_hdr->contents = extsyms;
    2242     }
    22432190
    22442191  /* Get a copy of the native relocations.  */
     
    22482195  if (internal_relocs == NULL)
    22492196    goto error_return;
    2250   if (! info->keep_memory)
    2251     free_relocs = internal_relocs;
    2252 
    2253   relsec->contents = (bfd_byte *) bfd_alloc (abfd, datasec->reloc_count * 12);
     2197
     2198  amt = (bfd_size_type) datasec->reloc_count * 12;
     2199  relsec->contents = (bfd_byte *) bfd_alloc (abfd, amt);
    22542200  if (relsec->contents == NULL)
    22552201    goto error_return;
     
    22792225      if (ELF32_R_SYM (irel->r_info) < symtab_hdr->sh_info)
    22802226        {
    2281           Elf_Internal_Sym isym;
    2282 
    22832227          /* A local symbol.  */
    2284           bfd_elf32_swap_symbol_in (abfd,
    2285                                     extsyms + ELF32_R_SYM (irel->r_info),
    2286                                     &isym);
    2287 
    2288           targetsec = bfd_section_from_elf_index (abfd, isym.st_shndx);
     2228          Elf_Internal_Sym *isym;
     2229
     2230          /* Read this BFD's local symbols if we haven't done so already.  */
     2231          if (isymbuf == NULL)
     2232            {
     2233              isymbuf = (Elf_Internal_Sym *) symtab_hdr->contents;
     2234              if (isymbuf == NULL)
     2235                isymbuf = bfd_elf_get_elf_syms (abfd, symtab_hdr,
     2236                                                symtab_hdr->sh_info, 0,
     2237                                                NULL, NULL, NULL);
     2238              if (isymbuf == NULL)
     2239                goto error_return;
     2240            }
     2241
     2242          isym = isymbuf + ELF32_R_SYM (irel->r_info);
     2243          targetsec = bfd_section_from_elf_index (abfd, isym->st_shndx);
    22892244        }
    22902245      else
     
    23102265    }
    23112266
    2312   if (free_extsyms != NULL)
    2313     free (free_extsyms);
    2314   if (free_relocs != NULL)
    2315     free (free_relocs);
    2316   return true;
     2267  if (isymbuf != NULL && symtab_hdr->contents != (unsigned char *) isymbuf)
     2268    free (isymbuf);
     2269  if (internal_relocs != NULL
     2270      && elf_section_data (datasec)->relocs != internal_relocs)
     2271    free (internal_relocs);
     2272  return TRUE;
    23172273
    23182274error_return:
    2319   if (free_extsyms != NULL)
    2320     free (free_extsyms);
    2321   if (free_relocs != NULL)
    2322     free (free_relocs);
    2323   return false;
     2275  if (isymbuf != NULL && symtab_hdr->contents != (unsigned char *) isymbuf)
     2276    free (isymbuf);
     2277  if (internal_relocs != NULL
     2278      && elf_section_data (datasec)->relocs != internal_relocs)
     2279    free (internal_relocs);
     2280  return FALSE;
     2281}
     2282
     2283static enum elf_reloc_type_class
     2284elf32_m68k_reloc_type_class (rela)
     2285     const Elf_Internal_Rela *rela;
     2286{
     2287  switch ((int) ELF32_R_TYPE (rela->r_info))
     2288    {
     2289    case R_68K_RELATIVE:
     2290      return reloc_class_relative;
     2291    case R_68K_JMP_SLOT:
     2292      return reloc_class_plt;
     2293    case R_68K_COPY:
     2294      return reloc_class_copy;
     2295    default:
     2296      return reloc_class_normal;
     2297    }
    23242298}
    23252299
     
    23462320#define elf_backend_gc_mark_hook        elf_m68k_gc_mark_hook
    23472321#define elf_backend_gc_sweep_hook       elf_m68k_gc_sweep_hook
    2348 #define bfd_elf32_bfd_copy_private_bfd_data \
    2349                                         elf32_m68k_copy_private_bfd_data
    23502322#define bfd_elf32_bfd_merge_private_bfd_data \
    23512323                                        elf32_m68k_merge_private_bfd_data
     
    23542326#define bfd_elf32_bfd_print_private_bfd_data \
    23552327                                        elf32_m68k_print_private_bfd_data
     2328#define elf_backend_reloc_type_class    elf32_m68k_reloc_type_class
    23562329
    23572330#define elf_backend_can_gc_sections 1
     2331#define elf_backend_can_refcount 1
    23582332#define elf_backend_want_got_plt 1
    23592333#define elf_backend_plt_readonly 1
    23602334#define elf_backend_want_plt_sym 0
    23612335#define elf_backend_got_header_size     12
     2336#define elf_backend_rela_normal         1
    23622337
    23632338#include "elf32-target.h"
Note: See TracChangeset for help on using the changeset viewer.