]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - bfd/elf32-m68k.c
bfd: sframe: minor code adjustments and fix typos
[thirdparty/binutils-gdb.git] / bfd / elf32-m68k.c
index 0eb4133b06006b906ed3c8f31e7d48c9334dad08..6355ae92a3c088b95f0848ee01c01e658ad5549d 100644 (file)
@@ -1,6 +1,5 @@
 /* Motorola 68k series support for 32-bit ELF
-   Copyright 1993, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
-   2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+   Copyright (C) 1993-2024 Free Software Foundation, Inc.
 
    This file is part of BFD, the Binary File Descriptor library.
 
 #include "elf-bfd.h"
 #include "elf/m68k.h"
 #include "opcode/m68k.h"
+#include "cpu-m68k.h"
+#include "elf32-m68k.h"
 
-static reloc_howto_type *reloc_type_lookup
-  PARAMS ((bfd *, bfd_reloc_code_real_type));
-static void rtype_to_howto
-  PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
-static struct bfd_hash_entry *elf_m68k_link_hash_newfunc
-  PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
-static struct bfd_link_hash_table *elf_m68k_link_hash_table_create
-  PARAMS ((bfd *));
-static bfd_boolean elf_m68k_check_relocs
-  PARAMS ((bfd *, struct bfd_link_info *, asection *,
-          const Elf_Internal_Rela *));
-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 **));
-static bfd_boolean elf_m68k_finish_dynamic_symbol
-  PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *,
-          Elf_Internal_Sym *));
-static bfd_boolean elf_m68k_finish_dynamic_sections
-  PARAMS ((bfd *, struct bfd_link_info *));
-
-static bfd_boolean elf32_m68k_set_private_flags
-  PARAMS ((bfd *, flagword));
-static bfd_boolean elf32_m68k_merge_private_bfd_data
-  PARAMS ((bfd *, bfd *));
-static bfd_boolean elf32_m68k_print_private_bfd_data
-  PARAMS ((bfd *, PTR));
-static enum elf_reloc_type_class elf32_m68k_reloc_type_class
-  PARAMS ((const Elf_Internal_Rela *));
-
-static reloc_howto_type howto_table[] = {
-  HOWTO(R_68K_NONE,       0, 0, 0, FALSE,0, complain_overflow_dont,     bfd_elf_generic_reloc, "R_68K_NONE",      FALSE, 0, 0x00000000,FALSE),
-  HOWTO(R_68K_32,         0, 2,32, FALSE,0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_68K_32",        FALSE, 0, 0xffffffff,FALSE),
-  HOWTO(R_68K_16,         0, 1,16, FALSE,0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_68K_16",        FALSE, 0, 0x0000ffff,FALSE),
-  HOWTO(R_68K_8,          0, 0, 8, FALSE,0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_68K_8",         FALSE, 0, 0x000000ff,FALSE),
-  HOWTO(R_68K_PC32,       0, 2,32, TRUE, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_68K_PC32",      FALSE, 0, 0xffffffff,TRUE),
-  HOWTO(R_68K_PC16,       0, 1,16, TRUE, 0, complain_overflow_signed,   bfd_elf_generic_reloc, "R_68K_PC16",      FALSE, 0, 0x0000ffff,TRUE),
-  HOWTO(R_68K_PC8,        0, 0, 8, TRUE, 0, complain_overflow_signed,   bfd_elf_generic_reloc, "R_68K_PC8",       FALSE, 0, 0x000000ff,TRUE),
-  HOWTO(R_68K_GOT32,      0, 2,32, TRUE, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_68K_GOT32",     FALSE, 0, 0xffffffff,TRUE),
-  HOWTO(R_68K_GOT16,      0, 1,16, TRUE, 0, complain_overflow_signed,   bfd_elf_generic_reloc, "R_68K_GOT16",     FALSE, 0, 0x0000ffff,TRUE),
-  HOWTO(R_68K_GOT8,       0, 0, 8, TRUE, 0, complain_overflow_signed,   bfd_elf_generic_reloc, "R_68K_GOT8",      FALSE, 0, 0x000000ff,TRUE),
-  HOWTO(R_68K_GOT32O,     0, 2,32, FALSE,0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_68K_GOT32O",    FALSE, 0, 0xffffffff,FALSE),
-  HOWTO(R_68K_GOT16O,     0, 1,16, FALSE,0, complain_overflow_signed,   bfd_elf_generic_reloc, "R_68K_GOT16O",    FALSE, 0, 0x0000ffff,FALSE),
-  HOWTO(R_68K_GOT8O,      0, 0, 8, FALSE,0, complain_overflow_signed,   bfd_elf_generic_reloc, "R_68K_GOT8O",     FALSE, 0, 0x000000ff,FALSE),
-  HOWTO(R_68K_PLT32,      0, 2,32, TRUE, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_68K_PLT32",     FALSE, 0, 0xffffffff,TRUE),
-  HOWTO(R_68K_PLT16,      0, 1,16, TRUE, 0, complain_overflow_signed,   bfd_elf_generic_reloc, "R_68K_PLT16",     FALSE, 0, 0x0000ffff,TRUE),
-  HOWTO(R_68K_PLT8,       0, 0, 8, TRUE, 0, complain_overflow_signed,   bfd_elf_generic_reloc, "R_68K_PLT8",      FALSE, 0, 0x000000ff,TRUE),
-  HOWTO(R_68K_PLT32O,     0, 2,32, FALSE,0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_68K_PLT32O",    FALSE, 0, 0xffffffff,FALSE),
-  HOWTO(R_68K_PLT16O,     0, 1,16, FALSE,0, complain_overflow_signed,   bfd_elf_generic_reloc, "R_68K_PLT16O",    FALSE, 0, 0x0000ffff,FALSE),
-  HOWTO(R_68K_PLT8O,      0, 0, 8, FALSE,0, complain_overflow_signed,   bfd_elf_generic_reloc, "R_68K_PLT8O",     FALSE, 0, 0x000000ff,FALSE),
-  HOWTO(R_68K_COPY,       0, 0, 0, FALSE,0, complain_overflow_dont,     bfd_elf_generic_reloc, "R_68K_COPY",      FALSE, 0, 0xffffffff,FALSE),
-  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),
+static bool
+elf_m68k_discard_copies (struct elf_link_hash_entry *, void *);
+
+static reloc_howto_type howto_table[] =
+{
+  HOWTO(R_68K_NONE,      0, 0, 0, false,0, complain_overflow_dont,     bfd_elf_generic_reloc, "R_68K_NONE",      false, 0, 0x00000000,false),
+  HOWTO(R_68K_32,        0, 4,32, false,0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_68K_32",        false, 0, 0xffffffff,false),
+  HOWTO(R_68K_16,        0, 2,16, false,0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_68K_16",        false, 0, 0x0000ffff,false),
+  HOWTO(R_68K_8,         0, 1, 8, false,0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_68K_8",         false, 0, 0x000000ff,false),
+  HOWTO(R_68K_PC32,      0, 4,32, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_68K_PC32",      false, 0, 0xffffffff,true),
+  HOWTO(R_68K_PC16,      0, 2,16, true, 0, complain_overflow_signed,   bfd_elf_generic_reloc, "R_68K_PC16",      false, 0, 0x0000ffff,true),
+  HOWTO(R_68K_PC8,       0, 1, 8, true, 0, complain_overflow_signed,   bfd_elf_generic_reloc, "R_68K_PC8",       false, 0, 0x000000ff,true),
+  HOWTO(R_68K_GOT32,     0, 4,32, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_68K_GOT32",     false, 0, 0xffffffff,true),
+  HOWTO(R_68K_GOT16,     0, 2,16, true, 0, complain_overflow_signed,   bfd_elf_generic_reloc, "R_68K_GOT16",     false, 0, 0x0000ffff,true),
+  HOWTO(R_68K_GOT8,      0, 1, 8, true, 0, complain_overflow_signed,   bfd_elf_generic_reloc, "R_68K_GOT8",      false, 0, 0x000000ff,true),
+  HOWTO(R_68K_GOT32O,    0, 4,32, false,0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_68K_GOT32O",    false, 0, 0xffffffff,false),
+  HOWTO(R_68K_GOT16O,    0, 2,16, false,0, complain_overflow_signed,   bfd_elf_generic_reloc, "R_68K_GOT16O",    false, 0, 0x0000ffff,false),
+  HOWTO(R_68K_GOT8O,     0, 1, 8, false,0, complain_overflow_signed,   bfd_elf_generic_reloc, "R_68K_GOT8O",     false, 0, 0x000000ff,false),
+  HOWTO(R_68K_PLT32,     0, 4,32, true, 0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_68K_PLT32",     false, 0, 0xffffffff,true),
+  HOWTO(R_68K_PLT16,     0, 2,16, true, 0, complain_overflow_signed,   bfd_elf_generic_reloc, "R_68K_PLT16",     false, 0, 0x0000ffff,true),
+  HOWTO(R_68K_PLT8,      0, 1, 8, true, 0, complain_overflow_signed,   bfd_elf_generic_reloc, "R_68K_PLT8",      false, 0, 0x000000ff,true),
+  HOWTO(R_68K_PLT32O,    0, 4,32, false,0, complain_overflow_bitfield, bfd_elf_generic_reloc, "R_68K_PLT32O",    false, 0, 0xffffffff,false),
+  HOWTO(R_68K_PLT16O,    0, 2,16, false,0, complain_overflow_signed,   bfd_elf_generic_reloc, "R_68K_PLT16O",    false, 0, 0x0000ffff,false),
+  HOWTO(R_68K_PLT8O,     0, 1, 8, false,0, complain_overflow_signed,   bfd_elf_generic_reloc, "R_68K_PLT8O",     false, 0, 0x000000ff,false),
+  HOWTO(R_68K_COPY,      0, 0, 0, false,0, complain_overflow_dont,     bfd_elf_generic_reloc, "R_68K_COPY",      false, 0, 0xffffffff,false),
+  HOWTO(R_68K_GLOB_DAT,          0, 4,32, false,0, complain_overflow_dont,     bfd_elf_generic_reloc, "R_68K_GLOB_DAT",  false, 0, 0xffffffff,false),
+  HOWTO(R_68K_JMP_SLOT,          0, 4,32, false,0, complain_overflow_dont,     bfd_elf_generic_reloc, "R_68K_JMP_SLOT",  false, 0, 0xffffffff,false),
+  HOWTO(R_68K_RELATIVE,          0, 4,32, false,0, complain_overflow_dont,     bfd_elf_generic_reloc, "R_68K_RELATIVE",  false, 0, 0xffffffff,false),
   /* GNU extension to record C++ vtable hierarchy.  */
   HOWTO (R_68K_GNU_VTINHERIT,  /* type */
         0,                     /* rightshift */
-        2,                     /* size (0 = byte, 1 = short, 2 = long) */
+        4,                     /* size */
         0,                     /* bitsize */
-        FALSE,                 /* pc_relative */
+        false,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_dont, /* complain_on_overflow */
         NULL,                  /* special_function */
         "R_68K_GNU_VTINHERIT", /* name */
-        FALSE,                 /* partial_inplace */
+        false,                 /* partial_inplace */
         0,                     /* src_mask */
         0,                     /* dst_mask */
-        FALSE),
+        false),
   /* GNU extension to record C++ vtable member usage.  */
   HOWTO (R_68K_GNU_VTENTRY,    /* type */
         0,                     /* rightshift */
-        2,                     /* size (0 = byte, 1 = short, 2 = long) */
+        4,                     /* size */
         0,                     /* bitsize */
-        FALSE,                 /* pc_relative */
+        false,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_dont, /* complain_on_overflow */
         _bfd_elf_rel_vtable_reloc_fn, /* special_function */
         "R_68K_GNU_VTENTRY",   /* name */
-        FALSE,                 /* partial_inplace */
+        false,                 /* partial_inplace */
         0,                     /* src_mask */
         0,                     /* dst_mask */
-        FALSE),
+        false),
 
   /* TLS general dynamic variable reference.  */
   HOWTO (R_68K_TLS_GD32,       /* type */
         0,                     /* rightshift */
-        2,                     /* size (0 = byte, 1 = short, 2 = long) */
+        4,                     /* size */
         32,                    /* bitsize */
-        FALSE,                 /* pc_relative */
+        false,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_bitfield, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_68K_TLS_GD32",      /* name */
-        FALSE,                 /* partial_inplace */
+        false,                 /* partial_inplace */
         0,                     /* src_mask */
         0xffffffff,            /* dst_mask */
-        FALSE),                /* pcrel_offset */
+        false),                /* pcrel_offset */
 
   HOWTO (R_68K_TLS_GD16,       /* type */
         0,                     /* rightshift */
-        1,                     /* size (0 = byte, 1 = short, 2 = long) */
+        2,                     /* size */
         16,                    /* bitsize */
-        FALSE,                 /* pc_relative */
+        false,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_signed, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_68K_TLS_GD16",      /* name */
-        FALSE,                 /* partial_inplace */
+        false,                 /* partial_inplace */
         0,                     /* src_mask */
         0x0000ffff,            /* dst_mask */
-        FALSE),                /* pcrel_offset */
+        false),                /* pcrel_offset */
 
   HOWTO (R_68K_TLS_GD8,                /* type */
         0,                     /* rightshift */
-        0,                     /* size (0 = byte, 1 = short, 2 = long) */
+        1,                     /* size */
         8,                     /* bitsize */
-        FALSE,                 /* pc_relative */
+        false,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_signed, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_68K_TLS_GD8",       /* name */
-        FALSE,                 /* partial_inplace */
+        false,                 /* partial_inplace */
         0,                     /* src_mask */
         0x000000ff,            /* dst_mask */
-        FALSE),                /* pcrel_offset */
+        false),                /* pcrel_offset */
 
   /* TLS local dynamic variable reference.  */
   HOWTO (R_68K_TLS_LDM32,      /* type */
         0,                     /* rightshift */
-        2,                     /* size (0 = byte, 1 = short, 2 = long) */
+        4,                     /* size */
         32,                    /* bitsize */
-        FALSE,                 /* pc_relative */
+        false,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_bitfield, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_68K_TLS_LDM32",     /* name */
-        FALSE,                 /* partial_inplace */
+        false,                 /* partial_inplace */
         0,                     /* src_mask */
         0xffffffff,            /* dst_mask */
-        FALSE),                /* pcrel_offset */
+        false),                /* pcrel_offset */
 
   HOWTO (R_68K_TLS_LDM16,      /* type */
         0,                     /* rightshift */
-        1,                     /* size (0 = byte, 1 = short, 2 = long) */
+        2,                     /* size */
         16,                    /* bitsize */
-        FALSE,                 /* pc_relative */
+        false,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_signed, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_68K_TLS_LDM16",     /* name */
-        FALSE,                 /* partial_inplace */
+        false,                 /* partial_inplace */
         0,                     /* src_mask */
         0x0000ffff,            /* dst_mask */
-        FALSE),                /* pcrel_offset */
+        false),                /* pcrel_offset */
 
   HOWTO (R_68K_TLS_LDM8,               /* type */
         0,                     /* rightshift */
-        0,                     /* size (0 = byte, 1 = short, 2 = long) */
+        1,                     /* size */
         8,                     /* bitsize */
-        FALSE,                 /* pc_relative */
+        false,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_signed, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_68K_TLS_LDM8",      /* name */
-        FALSE,                 /* partial_inplace */
+        false,                 /* partial_inplace */
         0,                     /* src_mask */
         0x000000ff,            /* dst_mask */
-        FALSE),                /* pcrel_offset */
+        false),                /* pcrel_offset */
 
   HOWTO (R_68K_TLS_LDO32,      /* type */
         0,                     /* rightshift */
-        2,                     /* size (0 = byte, 1 = short, 2 = long) */
+        4,                     /* size */
         32,                    /* bitsize */
-        FALSE,                 /* pc_relative */
+        false,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_bitfield, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_68K_TLS_LDO32",     /* name */
-        FALSE,                 /* partial_inplace */
+        false,                 /* partial_inplace */
         0,                     /* src_mask */
         0xffffffff,            /* dst_mask */
-        FALSE),                /* pcrel_offset */
+        false),                /* pcrel_offset */
 
   HOWTO (R_68K_TLS_LDO16,      /* type */
         0,                     /* rightshift */
-        1,                     /* size (0 = byte, 1 = short, 2 = long) */
+        2,                     /* size */
         16,                    /* bitsize */
-        FALSE,                 /* pc_relative */
+        false,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_signed, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_68K_TLS_LDO16",     /* name */
-        FALSE,                 /* partial_inplace */
+        false,                 /* partial_inplace */
         0,                     /* src_mask */
         0x0000ffff,            /* dst_mask */
-        FALSE),                /* pcrel_offset */
+        false),                /* pcrel_offset */
 
   HOWTO (R_68K_TLS_LDO8,               /* type */
         0,                     /* rightshift */
-        0,                     /* size (0 = byte, 1 = short, 2 = long) */
+        1,                     /* size */
         8,                     /* bitsize */
-        FALSE,                 /* pc_relative */
+        false,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_signed, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_68K_TLS_LDO8",      /* name */
-        FALSE,                 /* partial_inplace */
+        false,                 /* partial_inplace */
         0,                     /* src_mask */
         0x000000ff,            /* dst_mask */
-        FALSE),                /* pcrel_offset */
+        false),                /* pcrel_offset */
 
   /* TLS initial execution variable reference.  */
   HOWTO (R_68K_TLS_IE32,       /* type */
         0,                     /* rightshift */
-        2,                     /* size (0 = byte, 1 = short, 2 = long) */
+        4,                     /* size */
         32,                    /* bitsize */
-        FALSE,                 /* pc_relative */
+        false,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_bitfield, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_68K_TLS_IE32",      /* name */
-        FALSE,                 /* partial_inplace */
+        false,                 /* partial_inplace */
         0,                     /* src_mask */
         0xffffffff,            /* dst_mask */
-        FALSE),                /* pcrel_offset */
+        false),                /* pcrel_offset */
 
   HOWTO (R_68K_TLS_IE16,       /* type */
         0,                     /* rightshift */
-        1,                     /* size (0 = byte, 1 = short, 2 = long) */
+        2,                     /* size */
         16,                    /* bitsize */
-        FALSE,                 /* pc_relative */
+        false,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_signed, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_68K_TLS_IE16",      /* name */
-        FALSE,                 /* partial_inplace */
+        false,                 /* partial_inplace */
         0,                     /* src_mask */
         0x0000ffff,            /* dst_mask */
-        FALSE),                /* pcrel_offset */
+        false),                /* pcrel_offset */
 
   HOWTO (R_68K_TLS_IE8,                /* type */
         0,                     /* rightshift */
-        0,                     /* size (0 = byte, 1 = short, 2 = long) */
+        1,                     /* size */
         8,                     /* bitsize */
-        FALSE,                 /* pc_relative */
+        false,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_signed, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_68K_TLS_IE8",       /* name */
-        FALSE,                 /* partial_inplace */
+        false,                 /* partial_inplace */
         0,                     /* src_mask */
         0x000000ff,            /* dst_mask */
-        FALSE),                /* pcrel_offset */
+        false),                /* pcrel_offset */
 
   /* TLS local execution variable reference.  */
   HOWTO (R_68K_TLS_LE32,       /* type */
         0,                     /* rightshift */
-        2,                     /* size (0 = byte, 1 = short, 2 = long) */
+        4,                     /* size */
         32,                    /* bitsize */
-        FALSE,                 /* pc_relative */
+        false,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_bitfield, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_68K_TLS_LE32",      /* name */
-        FALSE,                 /* partial_inplace */
+        false,                 /* partial_inplace */
         0,                     /* src_mask */
         0xffffffff,            /* dst_mask */
-        FALSE),                /* pcrel_offset */
+        false),                /* pcrel_offset */
 
   HOWTO (R_68K_TLS_LE16,       /* type */
         0,                     /* rightshift */
-        1,                     /* size (0 = byte, 1 = short, 2 = long) */
+        2,                     /* size */
         16,                    /* bitsize */
-        FALSE,                 /* pc_relative */
+        false,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_signed, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_68K_TLS_LE16",      /* name */
-        FALSE,                 /* partial_inplace */
+        false,                 /* partial_inplace */
         0,                     /* src_mask */
         0x0000ffff,            /* dst_mask */
-        FALSE),                /* pcrel_offset */
+        false),                /* pcrel_offset */
 
   HOWTO (R_68K_TLS_LE8,                /* type */
         0,                     /* rightshift */
-        0,                     /* size (0 = byte, 1 = short, 2 = long) */
+        1,                     /* size */
         8,                     /* bitsize */
-        FALSE,                 /* pc_relative */
+        false,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_signed, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_68K_TLS_LE8",       /* name */
-        FALSE,                 /* partial_inplace */
+        false,                 /* partial_inplace */
         0,                     /* src_mask */
         0x000000ff,            /* dst_mask */
-        FALSE),                /* pcrel_offset */
+        false),                /* pcrel_offset */
 
   /* TLS GD/LD dynamic relocations.  */
   HOWTO (R_68K_TLS_DTPMOD32,   /* type */
         0,                     /* rightshift */
-        2,                     /* size (0 = byte, 1 = short, 2 = long) */
+        4,                     /* size */
         32,                    /* bitsize */
-        FALSE,                 /* pc_relative */
+        false,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_dont, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_68K_TLS_DTPMOD32",  /* name */
-        FALSE,                 /* partial_inplace */
+        false,                 /* partial_inplace */
         0,                     /* src_mask */
         0xffffffff,            /* dst_mask */
-        FALSE),                /* pcrel_offset */
+        false),                /* pcrel_offset */
 
   HOWTO (R_68K_TLS_DTPREL32,   /* type */
         0,                     /* rightshift */
-        2,                     /* size (0 = byte, 1 = short, 2 = long) */
+        4,                     /* size */
         32,                    /* bitsize */
-        FALSE,                 /* pc_relative */
+        false,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_dont, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_68K_TLS_DTPREL32",  /* name */
-        FALSE,                 /* partial_inplace */
+        false,                 /* partial_inplace */
         0,                     /* src_mask */
         0xffffffff,            /* dst_mask */
-        FALSE),                /* pcrel_offset */
+        false),                /* pcrel_offset */
 
   HOWTO (R_68K_TLS_TPREL32,    /* type */
         0,                     /* rightshift */
-        2,                     /* size (0 = byte, 1 = short, 2 = long) */
+        4,                     /* size */
         32,                    /* bitsize */
-        FALSE,                 /* pc_relative */
+        false,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_dont, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_68K_TLS_TPREL32",   /* name */
-        FALSE,                 /* partial_inplace */
+        false,                 /* partial_inplace */
         0,                     /* src_mask */
         0xffffffff,            /* dst_mask */
-        FALSE),                /* pcrel_offset */
+        false),                /* pcrel_offset */
 };
 
-static void
+static bool
 rtype_to_howto (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst)
 {
   unsigned int indx = ELF32_R_TYPE (dst->r_info);
 
   if (indx >= (unsigned int) R_68K_max)
     {
-      (*_bfd_error_handler) (_("%B: invalid relocation type %d"),
-                            abfd, (int) indx);
-      indx = R_68K_NONE;
+      /* xgettext:c-format */
+      _bfd_error_handler (_("%pB: unsupported relocation type %#x"),
+                         abfd, indx);
+      bfd_set_error (bfd_error_bad_value);
+      return false;
     }
   cache_ptr->howto = &howto_table[indx];
+  return true;
 }
 
 #define elf_info_to_howto rtype_to_howto
@@ -440,9 +413,8 @@ static const struct
 };
 
 static reloc_howto_type *
-reloc_type_lookup (abfd, code)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     bfd_reloc_code_real_type code;
+reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
+                  bfd_reloc_code_real_type code)
 {
   unsigned int i;
   for (i = 0; i < sizeof (reloc_map) / sizeof (reloc_map[0]); i++)
@@ -469,6 +441,7 @@ reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, const char *r_name)
 #define bfd_elf32_bfd_reloc_type_lookup reloc_type_lookup
 #define bfd_elf32_bfd_reloc_name_lookup reloc_name_lookup
 #define ELF_ARCH bfd_arch_m68k
+#define ELF_TARGET_ID M68K_ELF_DATA
 \f
 /* Functions for the m68k ELF linker.  */
 
@@ -539,7 +512,8 @@ static const bfd_byte elf_m68k_plt_entry[PLT_ENTRY_SIZE] =
   0, 0, 0, 0             /* + .plt - . */
 };
 
-static const struct elf_m68k_plt_info elf_m68k_plt_info = {
+static const struct elf_m68k_plt_info elf_m68k_plt_info =
+{
   PLT_ENTRY_SIZE,
   elf_m68k_plt0_entry, { 4, 12 },
   elf_m68k_plt_entry, { 4, 16 }, 8
@@ -549,13 +523,13 @@ static const struct elf_m68k_plt_info elf_m68k_plt_info = {
 
 static const bfd_byte elf_isab_plt0_entry[ISAB_PLT_ENTRY_SIZE] =
 {
-  0x20, 0x3c,             /* move.l #offset,%d0 */
-  0, 0, 0, 0,             /* + (.got + 4) - . */
+  0x20, 0x3c,            /* move.l #offset,%d0 */
+  0, 0, 0, 0,            /* + (.got + 4) - . */
   0x2f, 0x3b, 0x08, 0xfa, /* move.l (-6,%pc,%d0:l),-(%sp) */
-  0x20, 0x3c,             /* move.l #offset,%d0 */
-  0, 0, 0, 0,             /* + (.got + 8) - . */
+  0x20, 0x3c,            /* move.l #offset,%d0 */
+  0, 0, 0, 0,            /* + (.got + 8) - . */
   0x20, 0x7b, 0x08, 0xfa, /* move.l (-6,%pc,%d0:l), %a0 */
-  0x4e, 0xd0,             /* jmp (%a0) */
+  0x4e, 0xd0,            /* jmp (%a0) */
   0x4e, 0x71             /* nop */
 };
 
@@ -563,17 +537,18 @@ static const bfd_byte elf_isab_plt0_entry[ISAB_PLT_ENTRY_SIZE] =
 
 static const bfd_byte elf_isab_plt_entry[ISAB_PLT_ENTRY_SIZE] =
 {
-  0x20, 0x3c,             /* move.l #offset,%d0 */
-  0, 0, 0, 0,             /* + (.got.plt entry) - . */
+  0x20, 0x3c,            /* move.l #offset,%d0 */
+  0, 0, 0, 0,            /* + (.got.plt entry) - . */
   0x20, 0x7b, 0x08, 0xfa, /* move.l (-6,%pc,%d0:l), %a0 */
-  0x4e, 0xd0,             /* jmp (%a0) */
-  0x2f, 0x3c,             /* move.l #offset,-(%sp) */
-  0, 0, 0, 0,             /* + reloc index */
-  0x60, 0xff,             /* bra.l .plt */
-  0, 0, 0, 0              /* + .plt - . */
+  0x4e, 0xd0,            /* jmp (%a0) */
+  0x2f, 0x3c,            /* move.l #offset,-(%sp) */
+  0, 0, 0, 0,            /* + reloc index */
+  0x60, 0xff,            /* bra.l .plt */
+  0, 0, 0, 0             /* + .plt - . */
 };
 
-static const struct elf_m68k_plt_info elf_isab_plt_info = {
+static const struct elf_m68k_plt_info elf_isab_plt_info =
+{
   ISAB_PLT_ENTRY_SIZE,
   elf_isab_plt0_entry, { 2, 12 },
   elf_isab_plt_entry, { 2, 20 }, 12
@@ -604,10 +579,11 @@ static const bfd_byte elf_isac_plt_entry[ISAC_PLT_ENTRY_SIZE] =
   0x2f, 0x3c,            /* move.l #offset,-(%sp) */
   0, 0, 0, 0,            /* replaced with offset into relocation table */
   0x61, 0xff,            /* bsr.l .plt */
-  0, 0, 0, 0             /* replaced with .plt - . */
+  0, 0, 0, 0             /* replaced with .plt - . */
 };
 
-static const struct elf_m68k_plt_info elf_isac_plt_info = {
+static const struct elf_m68k_plt_info elf_isac_plt_info =
+{
   ISAC_PLT_ENTRY_SIZE,
   elf_isac_plt0_entry, { 2, 12},
   elf_isac_plt_entry, { 2, 20 }, 12
@@ -618,27 +594,28 @@ static const struct elf_m68k_plt_info elf_isac_plt_info = {
 static const bfd_byte elf_cpu32_plt0_entry[CPU32_PLT_ENTRY_SIZE] =
 {
   0x2f, 0x3b, 0x01, 0x70, /* move.l (%pc,addr),-(%sp) */
-  0, 0, 0, 2,             /* + (.got + 4) - . */
+  0, 0, 0, 2,            /* + (.got + 4) - . */
   0x22, 0x7b, 0x01, 0x70, /* moveal %pc@(0xc), %a1 */
-  0, 0, 0, 2,             /* + (.got + 8) - . */
-  0x4e, 0xd1,             /* jmp %a1@ */
-  0, 0, 0, 0,             /* pad out to 24 bytes.  */
+  0, 0, 0, 2,            /* + (.got + 8) - . */
+  0x4e, 0xd1,            /* jmp %a1@ */
+  0, 0, 0, 0,            /* pad out to 24 bytes.  */
   0, 0
 };
 
 static const bfd_byte elf_cpu32_plt_entry[CPU32_PLT_ENTRY_SIZE] =
 {
   0x22, 0x7b, 0x01, 0x70,  /* moveal %pc@(0xc), %a1 */
-  0, 0, 0, 2,              /* + (.got.plt entry) - . */
-  0x4e, 0xd1,              /* jmp %a1@ */
-  0x2f, 0x3c,              /* move.l #offset,-(%sp) */
-  0, 0, 0, 0,              /* + reloc index */
-  0x60, 0xff,              /* bra.l .plt */
-  0, 0, 0, 0,              /* + .plt - . */
+  0, 0, 0, 2,             /* + (.got.plt entry) - . */
+  0x4e, 0xd1,             /* jmp %a1@ */
+  0x2f, 0x3c,             /* move.l #offset,-(%sp) */
+  0, 0, 0, 0,             /* + reloc index */
+  0x60, 0xff,             /* bra.l .plt */
+  0, 0, 0, 0,             /* + .plt - . */
   0, 0
 };
 
-static const struct elf_m68k_plt_info elf_cpu32_plt_info = {
+static const struct elf_m68k_plt_info elf_cpu32_plt_info =
+{
   CPU32_PLT_ENTRY_SIZE,
   elf_cpu32_plt0_entry, { 4, 12 },
   elf_cpu32_plt_entry, { 4, 18 }, 10
@@ -722,15 +699,14 @@ struct elf_m68k_got_entry
   {
     struct
     {
-      /* Number of times this entry is referenced.  It is used to
-        filter out unnecessary GOT slots in elf_m68k_gc_sweep_hook.  */
+      /* Number of times this entry is referenced.  */
       bfd_vma refcount;
     } s1;
 
     struct
     {
       /* Offset from the start of .got section.  To calculate offset relative
-        to GOT pointer one should substract got->offset from this value.  */
+        to GOT pointer one should subtract got->offset from this value.  */
       bfd_vma offset;
 
       /* Pointer to the next GOT entry for this global symbol.
@@ -780,7 +756,7 @@ elf_m68k_reloc_got_type (enum elf_m68k_reloc_type r_type)
       return R_68K_TLS_IE32;
 
     default:
-      BFD_ASSERT (FALSE);
+      BFD_ASSERT (false);
       return 0;
     }
 }
@@ -806,7 +782,7 @@ elf_m68k_reloc_got_offset_size (enum elf_m68k_reloc_type r_type)
       return R_8;
 
     default:
-      BFD_ASSERT (FALSE);
+      BFD_ASSERT (false);
       return 0;
     }
 }
@@ -828,14 +804,14 @@ elf_m68k_reloc_got_n_slots (enum elf_m68k_reloc_type r_type)
       return 2;
 
     default:
-      BFD_ASSERT (FALSE);
+      BFD_ASSERT (false);
       return 0;
     }
 }
 
 /* Return TRUE if relocation R_TYPE is a TLS one.  */
 
-static bfd_boolean
+static bool
 elf_m68k_reloc_tls_p (enum elf_m68k_reloc_type r_type)
 {
   switch (r_type)
@@ -846,10 +822,10 @@ elf_m68k_reloc_tls_p (enum elf_m68k_reloc_type r_type)
     case R_68K_TLS_IE32: case R_68K_TLS_IE16: case R_68K_TLS_IE8:
     case R_68K_TLS_LE32: case R_68K_TLS_LE16: case R_68K_TLS_LE8:
     case R_68K_TLS_DTPMOD32: case R_68K_TLS_DTPREL32: case R_68K_TLS_TPREL32:
-      return TRUE;
+      return true;
 
     default:
-      return FALSE;
+      return false;
     }
 }
 
@@ -913,22 +889,19 @@ struct elf_m68k_link_hash_table
 {
   struct elf_link_hash_table root;
 
-  /* Small local sym cache.  */
-  struct sym_cache sym_cache;
-
   /* The PLT format used by this link, or NULL if the format has not
      yet been chosen.  */
   const struct elf_m68k_plt_info *plt_info;
 
   /* True, if GP is loaded within each function which uses it.
      Set to TRUE when GOT negative offsets or multi-GOT is enabled.  */
-  bfd_boolean local_gp_p;
+  bool local_gp_p;
 
   /* Switch controlling use of negative offsets to double the size of GOTs.  */
-  bfd_boolean use_neg_got_offsets_p;
+  bool use_neg_got_offsets_p;
 
   /* Switch controlling generation of multiple GOTs.  */
-  bfd_boolean allow_multigot_p;
+  bool allow_multigot_p;
 
   /* Multi-GOT data structure.  */
   struct elf_m68k_multi_got multi_got_;
@@ -937,8 +910,9 @@ struct elf_m68k_link_hash_table
 /* Get the m68k ELF linker hash table from a link_info structure.  */
 
 #define elf_m68k_hash_table(p) \
-  (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \
-  == M68K_ELF_DATA ? ((struct elf_m68k_link_hash_table *) ((p)->hash)) : NULL)
+  ((is_elf_hash_table ((p)->hash)                                      \
+    && elf_hash_table_id (elf_hash_table (p)) == M68K_ELF_DATA)                \
+   ? (struct elf_m68k_link_hash_table *) (p)->hash : NULL)
 
 /* Shortcut to multi-GOT data.  */
 #define elf_m68k_multi_got(INFO) (&elf_m68k_hash_table (INFO)->multi_got_)
@@ -972,15 +946,32 @@ elf_m68k_link_hash_newfunc (struct bfd_hash_entry *entry,
   return ret;
 }
 
+/* Destroy an m68k ELF linker hash table.  */
+
+static void
+elf_m68k_link_hash_table_free (bfd *obfd)
+{
+  struct elf_m68k_link_hash_table *htab;
+
+  htab = (struct elf_m68k_link_hash_table *) obfd->link.hash;
+
+  if (htab->multi_got_.bfd2got != NULL)
+    {
+      htab_delete (htab->multi_got_.bfd2got);
+      htab->multi_got_.bfd2got = NULL;
+    }
+  _bfd_elf_link_hash_table_free (obfd);
+}
+
 /* Create an m68k ELF linker hash table.  */
 
 static struct bfd_link_hash_table *
 elf_m68k_link_hash_table_create (bfd *abfd)
 {
   struct elf_m68k_link_hash_table *ret;
-  bfd_size_type amt = sizeof (struct elf_m68k_link_hash_table);
+  size_t amt = sizeof (struct elf_m68k_link_hash_table);
 
-  ret = (struct elf_m68k_link_hash_table *) bfd_malloc (amt);
+  ret = (struct elf_m68k_link_hash_table *) bfd_zmalloc (amt);
   if (ret == (struct elf_m68k_link_hash_table *) NULL)
     return NULL;
 
@@ -992,37 +983,16 @@ elf_m68k_link_hash_table_create (bfd *abfd)
       free (ret);
       return NULL;
     }
+  ret->root.root.hash_table_free = elf_m68k_link_hash_table_free;
 
-  ret->sym_cache.abfd = NULL;
-  ret->plt_info = NULL;
-  ret->local_gp_p = FALSE;
-  ret->use_neg_got_offsets_p = FALSE;
-  ret->allow_multigot_p = FALSE;
-  ret->multi_got_.bfd2got = NULL;
   ret->multi_got_.global_symndx = 1;
 
   return &ret->root.root;
 }
 
-/* Destruct local data.  */
-
-static void
-elf_m68k_link_hash_table_free (struct bfd_link_hash_table *_htab)
-{
-  struct elf_m68k_link_hash_table *htab;
-
-  htab = (struct elf_m68k_link_hash_table *) _htab;
-
-  if (htab->multi_got_.bfd2got != NULL)
-    {
-      htab_delete (htab->multi_got_.bfd2got);
-      htab->multi_got_.bfd2got = NULL;
-    }
-}
-
 /* Set the right machine number.  */
 
-static bfd_boolean
+static bool
 elf32_m68k_object_p (bfd *abfd)
 {
   unsigned int mach = 0;
@@ -1077,15 +1047,14 @@ elf32_m68k_object_p (bfd *abfd)
   mach = bfd_m68k_features_to_mach (features);
   bfd_default_set_arch_mach (abfd, bfd_arch_m68k, mach);
 
-  return TRUE;
+  return true;
 }
 
 /* Somewhat reverse of elf32_m68k_object_p, this sets the e_flag
    field based on the machine number.  */
 
-static void
-elf_m68k_final_write_processing (bfd *abfd,
-                                bfd_boolean linker ATTRIBUTE_UNUSED)
+static bool
+elf_m68k_final_write_processing (bfd *abfd)
 {
   int mach = bfd_get_mach (abfd);
   unsigned long e_flags = elf_elfheader (abfd)->e_flags;
@@ -1138,50 +1107,112 @@ elf_m68k_final_write_processing (bfd *abfd,
        }
       elf_elfheader (abfd)->e_flags = e_flags;
     }
+  return _bfd_elf_final_write_processing (abfd);
 }
 
 /* Keep m68k-specific flags in the ELF header.  */
 
-static bfd_boolean
-elf32_m68k_set_private_flags (abfd, flags)
-     bfd *abfd;
-     flagword flags;
+static bool
+elf32_m68k_set_private_flags (bfd *abfd, flagword flags)
 {
   elf_elfheader (abfd)->e_flags = flags;
-  elf_flags_init (abfd) = TRUE;
-  return TRUE;
+  elf_flags_init (abfd) = true;
+  return true;
+}
+
+/* Merge object attributes from IBFD into OBFD.  Warn if
+   there are conflicting attributes. */
+static bool
+m68k_elf_merge_obj_attributes (bfd *ibfd, struct bfd_link_info *info)
+{
+  bfd *obfd = info->output_bfd;
+  obj_attribute *in_attr, *in_attrs;
+  obj_attribute *out_attr, *out_attrs;
+  bool ret = true;
+
+  in_attrs = elf_known_obj_attributes (ibfd)[OBJ_ATTR_GNU];
+  out_attrs = elf_known_obj_attributes (obfd)[OBJ_ATTR_GNU];
+
+  in_attr = &in_attrs[Tag_GNU_M68K_ABI_FP];
+  out_attr = &out_attrs[Tag_GNU_M68K_ABI_FP];
+
+  if (in_attr->i != out_attr->i)
+    {
+      int in_fp = in_attr->i & 3;
+      int out_fp = out_attr->i & 3;
+      static bfd *last_fp;
+
+      if (in_fp == 0)
+       ;
+      else if (out_fp == 0)
+       {
+         out_attr->type = ATTR_TYPE_FLAG_INT_VAL;
+         out_attr->i ^= in_fp;
+         last_fp = ibfd;
+       }
+      else if (out_fp == 1 && in_fp == 2)
+       {
+         _bfd_error_handler
+           /* xgettext:c-format */
+           (_("%pB uses hard float, %pB uses soft float"),
+            last_fp, ibfd);
+         ret = false;
+       }
+      else if (out_fp == 2 && in_fp == 1)
+       {
+         _bfd_error_handler
+           /* xgettext:c-format */
+           (_("%pB uses hard float, %pB uses soft float"),
+            ibfd, last_fp);
+         ret = false;
+       }
+    }
+
+  if (!ret)
+    {
+      out_attr->type = ATTR_TYPE_FLAG_INT_VAL | ATTR_TYPE_FLAG_ERROR;
+      bfd_set_error (bfd_error_bad_value);
+      return false;
+    }
+
+  /* Merge Tag_compatibility attributes and any common GNU ones.  */
+  return _bfd_elf_merge_object_attributes (ibfd, info);
 }
 
 /* Merge backend specific data from an object file to the output
    object file when linking.  */
-static bfd_boolean
-elf32_m68k_merge_private_bfd_data (ibfd, obfd)
-     bfd *ibfd;
-     bfd *obfd;
+static bool
+elf32_m68k_merge_private_bfd_data (bfd *ibfd, struct bfd_link_info *info)
 {
+  bfd *obfd = info->output_bfd;
   flagword out_flags;
   flagword in_flags;
   flagword out_isa;
   flagword in_isa;
   const bfd_arch_info_type *arch_info;
 
-  if (   bfd_get_flavour (ibfd) != bfd_target_elf_flavour
+  if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
       || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
-    return FALSE;
+    /* PR 24523: For non-ELF files do not try to merge any private
+       data, but also do not prevent the link from succeeding.  */
+    return true;
 
   /* Get the merged machine.  This checks for incompatibility between
      Coldfire & non-Coldfire flags, incompability between different
      Coldfire ISAs, and incompability between different MAC types.  */
-  arch_info = bfd_arch_get_compatible (ibfd, obfd, FALSE);
+  arch_info = bfd_arch_get_compatible (ibfd, obfd, false);
   if (!arch_info)
-    return FALSE;
+    return false;
 
   bfd_set_arch_mach (obfd, bfd_arch_m68k, arch_info->mach);
 
+  if (!m68k_elf_merge_obj_attributes (ibfd, info))
+    return false;
+
   in_flags = elf_elfheader (ibfd)->e_flags;
   if (!elf_flags_init (obfd))
     {
-      elf_flags_init (obfd) = TRUE;
+      elf_flags_init (obfd) = true;
       out_flags = in_flags;
     }
   else
@@ -1212,12 +1243,12 @@ elf32_m68k_merge_private_bfd_data (ibfd, obfd)
     }
   elf_elfheader (obfd)->e_flags = out_flags;
 
-  return TRUE;
+  return true;
 }
 
 /* Display the flags field.  */
 
-static bfd_boolean
+static bool
 elf32_m68k_print_private_bfd_data (bfd *abfd, void * ptr)
 {
   FILE *file = (FILE *) ptr;
@@ -1293,6 +1324,9 @@ elf32_m68k_print_private_bfd_data (bfd *abfd, void * ptr)
            case EF_M68K_CF_EMAC:
              mac = "emac";
              break;
+           case EF_M68K_CF_EMAC_B:
+             mac = "emac_b";
+             break;
            }
          if (mac)
            fprintf (file, " [%s]", mac);
@@ -1301,7 +1335,7 @@ elf32_m68k_print_private_bfd_data (bfd *abfd, void * ptr)
 
   fputc ('\n', file);
 
-  return TRUE;
+  return true;
 }
 
 /* Multi-GOT support implementation design:
@@ -1547,14 +1581,18 @@ elf_m68k_get_got_entry (struct elf_m68k_got *got,
     }
 
   entry_.key_ = *key;
-  ptr = htab_find_slot (got->entries, &entry_, (howto != SEARCH
-                                               ? INSERT : NO_INSERT));
+  ptr = htab_find_slot (got->entries, &entry_,
+                       (howto == SEARCH || howto == MUST_FIND ? NO_INSERT
+                        : INSERT));
   if (ptr == NULL)
     {
       if (howto == SEARCH)
        /* Entry not found.  */
        return NULL;
 
+      if (howto == MUST_FIND)
+       abort ();
+
       /* We're out of memory.  */
       bfd_set_error (bfd_error_no_memory);
       return NULL;
@@ -1563,7 +1601,10 @@ elf_m68k_get_got_entry (struct elf_m68k_got *got,
   if (*ptr == NULL)
     /* We didn't find the entry and we're asked to create a new one.  */
     {
-      BFD_ASSERT (howto != MUST_FIND && howto != SEARCH);
+      if (howto == MUST_FIND)
+       abort ();
+
+      BFD_ASSERT (howto != SEARCH);
 
       entry = bfd_alloc (elf_hash_table (info)->dynobj, sizeof (*entry));
       if (entry == NULL)
@@ -1637,27 +1678,6 @@ elf_m68k_update_got_entry_type (struct elf_m68k_got *got,
   return was;
 }
 
-/* Update GOT counters when removing an entry of type TYPE.  */
-
-static void
-elf_m68k_remove_got_entry_type (struct elf_m68k_got *got,
-                               enum elf_m68k_reloc_type type)
-{
-  enum elf_m68k_got_offset_size os;
-  bfd_vma n_slots;
-
-  n_slots = elf_m68k_reloc_got_n_slots (type);
-
-  /* Decrese counter of slots with offset size corresponding to TYPE
-     and all greater offset sizes.  */
-  for (os = elf_m68k_reloc_got_offset_size (type); os <= R_32; ++os)
-    {
-      BFD_ASSERT (got->n_slots[os] >= n_slots);
-
-      got->n_slots[os] -= n_slots;
-    }
-}
-
 /* Add new or update existing entry to GOT.
    H, ABFD, TYPE and SYMNDX is data for the entry.
    INFO is a context where memory should be allocated.  */
@@ -1707,17 +1727,19 @@ elf_m68k_add_entry_to_got (struct elf_m68k_got *got,
     /* This BFD has too many relocation.  */
     {
       if (got->n_slots[R_8] > ELF_M68K_R_8_MAX_N_SLOTS_IN_GOT (info))
-       (*_bfd_error_handler) (_("%B: GOT overflow: "
-                                "Number of relocations with 8-bit "
-                                "offset > %d"),
-                              abfd,
-                              ELF_M68K_R_8_MAX_N_SLOTS_IN_GOT (info));
+       /* xgettext:c-format */
+       _bfd_error_handler (_("%pB: GOT overflow: "
+                             "number of relocations with 8-bit "
+                             "offset > %d"),
+                           abfd,
+                           ELF_M68K_R_8_MAX_N_SLOTS_IN_GOT (info));
       else
-       (*_bfd_error_handler) (_("%B: GOT overflow: "
-                                "Number of relocations with 8- or 16-bit "
-                                "offset > %d"),
-                              abfd,
-                              ELF_M68K_R_8_16_MAX_N_SLOTS_IN_GOT (info));
+       /* xgettext:c-format */
+       _bfd_error_handler (_("%pB: GOT overflow: "
+                             "number of relocations with 8- or 16-bit "
+                             "offset > %d"),
+                           abfd,
+                           ELF_M68K_R_8_16_MAX_N_SLOTS_IN_GOT (info));
 
       return NULL;
     }
@@ -1797,14 +1819,18 @@ elf_m68k_get_bfd2got_entry (struct elf_m68k_multi_got *multi_got,
     }
 
   entry_.bfd = abfd;
-  ptr = htab_find_slot (multi_got->bfd2got, &entry_, (howto != SEARCH
-                                                     ? INSERT : NO_INSERT));
+  ptr = htab_find_slot (multi_got->bfd2got, &entry_,
+                       (howto == SEARCH || howto == MUST_FIND ? NO_INSERT
+                        : INSERT));
   if (ptr == NULL)
     {
       if (howto == SEARCH)
        /* Entry not found.  */
        return NULL;
 
+      if (howto == MUST_FIND)
+       abort ();
+
       /* We're out of memory.  */
       bfd_set_error (bfd_error_no_memory);
       return NULL;
@@ -1813,7 +1839,10 @@ elf_m68k_get_bfd2got_entry (struct elf_m68k_multi_got *multi_got,
   if (*ptr == NULL)
     /* Entry was not found.  Create new one.  */
     {
-      BFD_ASSERT (howto != MUST_FIND && howto != SEARCH);
+      if (howto == MUST_FIND)
+       abort ();
+
+      BFD_ASSERT (howto != SEARCH);
 
       entry = ((struct elf_m68k_bfd2got_entry *)
               bfd_alloc (elf_hash_table (info)->dynobj, sizeof (*entry)));
@@ -1852,7 +1881,7 @@ struct elf_m68k_can_merge_gots_arg
   struct bfd_link_info *info;
 
   /* Error flag.  */
-  bfd_boolean error_p;
+  bool error_p;
 };
 
 /* Process a single entry from the small GOT to see if it should be added
@@ -1905,7 +1934,7 @@ elf_m68k_can_merge_gots_1 (void **_entry_ptr, void *_arg)
                                      arg->info);
       if (entry == NULL)
        {
-         arg->error_p = TRUE;
+         arg->error_p = true;
          return 0;
        }
 
@@ -1920,7 +1949,7 @@ elf_m68k_can_merge_gots_1 (void **_entry_ptr, void *_arg)
    in BIG GOT to accumulate information from SMALL.
    INFO is the context where memory should be allocated.  */
 
-static bfd_boolean
+static bool
 elf_m68k_can_merge_gots (struct elf_m68k_got *big,
                         const struct elf_m68k_got *small,
                         struct bfd_link_info *info,
@@ -1933,12 +1962,12 @@ elf_m68k_can_merge_gots (struct elf_m68k_got *big,
   arg_.big = big;
   arg_.diff = diff;
   arg_.info = info;
-  arg_.error_p = FALSE;
+  arg_.error_p = false;
   htab_traverse_noresize (small->entries, elf_m68k_can_merge_gots_1, &arg_);
   if (arg_.error_p)
     {
       diff->offset = 0;
-      return FALSE;
+      return false;
     }
 
   /* Check for overflow.  */
@@ -1946,9 +1975,9 @@ elf_m68k_can_merge_gots (struct elf_m68k_got *big,
        > ELF_M68K_R_8_MAX_N_SLOTS_IN_GOT (info))
       || (big->n_slots[R_16] + arg_.diff->n_slots[R_16]
          > ELF_M68K_R_8_16_MAX_N_SLOTS_IN_GOT (info)))
-    return FALSE;
+    return false;
 
-  return TRUE;
+  return true;
 }
 
 struct elf_m68k_merge_gots_arg
@@ -1960,7 +1989,7 @@ struct elf_m68k_merge_gots_arg
   struct bfd_link_info *info;
 
   /* Error flag.  */
-  bfd_boolean error_p;
+  bool error_p;
 };
 
 /* Process a single entry from DIFF got.  Add or update corresponding
@@ -1980,7 +2009,7 @@ elf_m68k_merge_gots_1 (void **entry_ptr, void *_arg)
                               arg->info);
   if (to == NULL)
     {
-      arg->error_p = TRUE;
+      arg->error_p = true;
       return 0;
     }
 
@@ -1994,7 +2023,7 @@ elf_m68k_merge_gots_1 (void **entry_ptr, void *_arg)
 /* Merge data from DIFF to BIG.  INFO is context where memory should be
    allocated.  */
 
-static bfd_boolean
+static bool
 elf_m68k_merge_gots (struct elf_m68k_got *big,
                     struct elf_m68k_got *diff,
                     struct bfd_link_info *info)
@@ -2007,10 +2036,10 @@ elf_m68k_merge_gots (struct elf_m68k_got *big,
       /* Merge entries.  */
       arg_.big = big;
       arg_.info = info;
-      arg_.error_p = FALSE;
+      arg_.error_p = false;
       htab_traverse_noresize (diff->entries, elf_m68k_merge_gots_1, &arg_);
       if (arg_.error_p)
-       return FALSE;
+       return false;
 
       /* Merge counters.  */
       big->n_slots[R_8] += diff->n_slots[R_8];
@@ -2033,7 +2062,7 @@ elf_m68k_merge_gots (struct elf_m68k_got *big,
                  && (big->n_slots[R_16]
                      <= ELF_M68K_R_8_16_MAX_N_SLOTS_IN_GOT (info))));
 
-  return TRUE;
+  return true;
 }
 
 struct elf_m68k_finalize_got_offsets_arg
@@ -2136,7 +2165,7 @@ elf_m68k_finalize_got_offsets_1 (void **entry_ptr, void *_arg)
 
 static void
 elf_m68k_finalize_got_offsets (struct elf_m68k_got *got,
-                              bfd_boolean use_neg_got_offsets_p,
+                              bool use_neg_got_offsets_p,
                               struct elf_m68k_link_hash_entry **symndx2h,
                               bfd_vma *final_offset, bfd_vma *n_ldm_entries)
 {
@@ -2249,7 +2278,7 @@ struct elf_m68k_partition_multi_got_arg
   bfd_vma slots_relas_diff;
 
   /* Error flag.  */
-  bfd_boolean error_p;
+  bool error_p;
 
   /* Mapping from global symndx to global symbols.
      This is used to build lists of got entries for global symbols.  */
@@ -2269,7 +2298,7 @@ elf_m68k_partition_multi_got_2 (struct elf_m68k_partition_multi_got_arg *arg)
 
   arg->n_slots += arg->current_got->n_slots[R_32];
 
-  if (!arg->info->shared)
+  if (!bfd_link_pic (arg->info))
     /* If we are generating a shared object, we need to
        output a R_68K_RELATIVE reloc so that the dynamic
        linker can adjust this GOT entry.  Overwise we
@@ -2316,7 +2345,7 @@ elf_m68k_partition_multi_got_1 (void **_entry, void *_arg)
          if (diff->offset == 0)
            /* Offset set to 0 in the diff_ indicates an error.  */
            {
-             arg->error_p = TRUE;
+             arg->error_p = true;
              goto final_return;
            }
 
@@ -2340,7 +2369,7 @@ elf_m68k_partition_multi_got_1 (void **_entry, void *_arg)
       arg->current_got = elf_m68k_create_empty_got (arg->info);
       if (arg->current_got == NULL)
        {
-         arg->error_p = TRUE;
+         arg->error_p = true;
          goto final_return;
        }
 
@@ -2353,7 +2382,7 @@ elf_m68k_partition_multi_got_1 (void **_entry, void *_arg)
     {
       if (!elf_m68k_merge_gots (arg->current_got, diff, arg->info))
        {
-         arg->error_p = TRUE;
+         arg->error_p = true;
          goto final_return;
        }
 
@@ -2382,12 +2411,12 @@ elf_m68k_partition_multi_got_1 (void **_entry, void *_arg)
   if (diff != NULL)
     elf_m68k_clear_got (diff);
 
-  return arg->error_p == FALSE ? 1 : 0;
+  return !arg->error_p;
 }
 
 /* Helper function to build symndx2h mapping.  */
 
-static bfd_boolean
+static bool
 elf_m68k_init_symndx2h_1 (struct elf_link_hash_entry *_h,
                          void *_arg)
 {
@@ -2406,14 +2435,14 @@ elf_m68k_init_symndx2h_1 (struct elf_link_hash_entry *_h,
       arg->symndx2h[h->got_entry_key] = h;
     }
 
-  return TRUE;
+  return true;
 }
 
 /* Merge GOTs of some BFDs, assign offsets to GOT entries and build
    lists of GOT entries for global symbols.
    Calculate sizes of .got and .rela.got sections.  */
 
-static bfd_boolean
+static bool
 elf_m68k_partition_multi_got (struct bfd_link_info *info)
 {
   struct elf_m68k_multi_got *multi_got;
@@ -2426,7 +2455,7 @@ elf_m68k_partition_multi_got (struct bfd_link_info *info)
   arg_.info = info;
   arg_.n_slots = 0;
   arg_.slots_relas_diff = 0;
-  arg_.error_p = FALSE;
+  arg_.error_p = false;
 
   if (multi_got->bfd2got != NULL)
     {
@@ -2435,7 +2464,7 @@ elf_m68k_partition_multi_got (struct bfd_link_info *info)
        arg_.symndx2h = bfd_zmalloc (multi_got->global_symndx
                                     * sizeof (*arg_.symndx2h));
        if (arg_.symndx2h == NULL)
-         return FALSE;
+         return false;
 
        elf_link_hash_traverse (elf_hash_table (info),
                                elf_m68k_init_symndx2h_1, &arg_);
@@ -2449,7 +2478,7 @@ elf_m68k_partition_multi_got (struct bfd_link_info *info)
          free (arg_.symndx2h);
          arg_.symndx2h = NULL;
 
-         return FALSE;
+         return false;
        }
 
       /* Finish up last current_got.  */
@@ -2463,7 +2492,7 @@ elf_m68k_partition_multi_got (struct bfd_link_info *info)
     {
       asection *s;
 
-      s = bfd_get_section_by_name (elf_hash_table (info)->dynobj, ".got");
+      s = elf_hash_table (info)->sgot;
       if (s != NULL)
        s->size = arg_.offset;
       else
@@ -2472,7 +2501,7 @@ elf_m68k_partition_multi_got (struct bfd_link_info *info)
       BFD_ASSERT (arg_.slots_relas_diff <= arg_.n_slots);
       arg_.n_slots -= arg_.slots_relas_diff;
 
-      s = bfd_get_section_by_name (elf_hash_table (info)->dynobj, ".rela.got");
+      s = elf_hash_table (info)->srelgot;
       if (s != NULL)
        s->size = arg_.n_slots * sizeof (Elf32_External_Rela);
       else
@@ -2481,53 +2510,7 @@ elf_m68k_partition_multi_got (struct bfd_link_info *info)
   else
     BFD_ASSERT (multi_got->bfd2got == NULL);
 
-  return TRUE;
-}
-
-/* Specialized version of elf_m68k_get_got_entry that returns pointer
-   to hashtable slot, thus allowing removal of entry via
-   elf_m68k_remove_got_entry.  */
-
-static struct elf_m68k_got_entry **
-elf_m68k_find_got_entry_ptr (struct elf_m68k_got *got,
-                            struct elf_m68k_got_entry_key *key)
-{
-  void **ptr;
-  struct elf_m68k_got_entry entry_;
-  struct elf_m68k_got_entry **entry_ptr;
-
-  entry_.key_ = *key;
-  ptr = htab_find_slot (got->entries, &entry_, NO_INSERT);
-  BFD_ASSERT (ptr != NULL);
-
-  entry_ptr = (struct elf_m68k_got_entry **) ptr;
-
-  return entry_ptr;
-}
-
-/* Remove entry pointed to by ENTRY_PTR from GOT.  */
-
-static void
-elf_m68k_remove_got_entry (struct elf_m68k_got *got,
-                          struct elf_m68k_got_entry **entry_ptr)
-{
-  struct elf_m68k_got_entry *entry;
-
-  entry = *entry_ptr;
-
-  /* Check that offsets have not been finalized yet.  */
-  BFD_ASSERT (got->offset == (bfd_vma) -1);
-  /* Check that this entry is indeed unused.  */
-  BFD_ASSERT (entry->u.s1.refcount == 0);
-
-  elf_m68k_remove_got_entry_type (got, entry->key_.type);
-
-  if (entry->key_.bfd != NULL)
-    got->local_n_slots -= elf_m68k_reloc_got_n_slots (entry->key_.type);
-
-  BFD_ASSERT (got->n_slots[R_32] >= got->local_n_slots);
-
-  htab_clear_slot (got->entries, (void **) entry_ptr);
+  return true;
 }
 
 /* Copy any information related to dynamic linking from a pre-existing
@@ -2575,32 +2558,27 @@ elf_m68k_copy_indirect_symbol (struct bfd_link_info *info,
    allocate space in the global offset table or procedure linkage
    table.  */
 
-static bfd_boolean
-elf_m68k_check_relocs (abfd, info, sec, relocs)
-     bfd *abfd;
-     struct bfd_link_info *info;
-     asection *sec;
-     const Elf_Internal_Rela *relocs;
+static bool
+elf_m68k_check_relocs (bfd *abfd,
+                      struct bfd_link_info *info,
+                      asection *sec,
+                      const Elf_Internal_Rela *relocs)
 {
   bfd *dynobj;
   Elf_Internal_Shdr *symtab_hdr;
   struct elf_link_hash_entry **sym_hashes;
   const Elf_Internal_Rela *rel;
   const Elf_Internal_Rela *rel_end;
-  asection *sgot;
-  asection *srelgot;
   asection *sreloc;
   struct elf_m68k_got *got;
 
-  if (info->relocatable)
-    return TRUE;
+  if (bfd_link_relocatable (info))
+    return true;
 
   dynobj = elf_hash_table (info)->dynobj;
   symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
   sym_hashes = elf_sym_hashes (abfd);
 
-  sgot = NULL;
-  srelgot = NULL;
   sreloc = NULL;
 
   got = NULL;
@@ -2654,7 +2632,7 @@ elf_m68k_check_relocs (abfd, info, sec, relocs)
        case R_68K_TLS_DTPREL32:
 
          if (ELF32_R_TYPE (rel->r_info) == R_68K_TLS_TPREL32
-             && info->shared)
+             && bfd_link_pic (info))
            /* Do the special chorus for libraries with static TLS.  */
            info->flags |= DF_STATIC_TLS;
 
@@ -2665,33 +2643,7 @@ elf_m68k_check_relocs (abfd, info, sec, relocs)
              /* Create the .got section.  */
              elf_hash_table (info)->dynobj = dynobj = abfd;
              if (!_bfd_elf_create_got_section (dynobj, info))
-               return FALSE;
-           }
-
-         if (sgot == NULL)
-           {
-             sgot = bfd_get_section_by_name (dynobj, ".got");
-             BFD_ASSERT (sgot != NULL);
-           }
-
-         if (srelgot == NULL
-             && (h != NULL || info->shared))
-           {
-             srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
-             if (srelgot == NULL)
-               {
-                 srelgot = bfd_make_section_with_flags (dynobj,
-                                                        ".rela.got",
-                                                        (SEC_ALLOC
-                                                         | SEC_LOAD
-                                                         | SEC_HAS_CONTENTS
-                                                         | SEC_IN_MEMORY
-                                                         | SEC_LINKER_CREATED
-                                                         | SEC_READONLY));
-                 if (srelgot == NULL
-                     || !bfd_set_section_alignment (dynobj, srelgot, 2))
-                   return FALSE;
-               }
+               return false;
            }
 
          if (got == NULL)
@@ -2702,7 +2654,7 @@ elf_m68k_check_relocs (abfd, info, sec, relocs)
                = elf_m68k_get_bfd2got_entry (elf_m68k_multi_got (info),
                                              abfd, FIND_OR_CREATE, info);
              if (bfd2got_entry == NULL)
-               return FALSE;
+               return false;
 
              got = bfd2got_entry->got;
              BFD_ASSERT (got != NULL);
@@ -2716,7 +2668,7 @@ elf_m68k_check_relocs (abfd, info, sec, relocs)
                                                   ELF32_R_TYPE (rel->r_info),
                                                   r_symndx, info);
            if (got_entry == NULL)
-             return FALSE;
+             return false;
 
            if (got_entry->u.s1.refcount == 1)
              {
@@ -2726,7 +2678,7 @@ elf_m68k_check_relocs (abfd, info, sec, relocs)
                    && !h->forced_local)
                  {
                    if (!bfd_elf_link_record_dynamic_symbol (info, h))
-                     return FALSE;
+                     return false;
                  }
              }
          }
@@ -2738,10 +2690,10 @@ elf_m68k_check_relocs (abfd, info, sec, relocs)
        case R_68K_PLT32:
          /* This symbol requires a procedure linkage table entry.  We
             actually build the entry in adjust_dynamic_symbol,
-             because this might be a case of linking PIC code which is
-             never referenced by a dynamic object, in which case we
-             don't need to generate a procedure linkage table entry
-             after all.  */
+            because this might be a case of linking PIC code which is
+            never referenced by a dynamic object, in which case we
+            don't need to generate a procedure linkage table entry
+            after all.  */
 
          /* If this is a local symbol, we resolve it directly without
             creating a procedure linkage table entry.  */
@@ -2763,7 +2715,7 @@ elf_m68k_check_relocs (abfd, info, sec, relocs)
                 local symbol.  FIXME: does it?  How to handle it if
                 it does make sense?  */
              bfd_set_error (bfd_error_bad_value);
-             return FALSE;
+             return false;
            }
 
          /* Make sure this symbol is output as a dynamic symbol.  */
@@ -2771,7 +2723,7 @@ elf_m68k_check_relocs (abfd, info, sec, relocs)
              && !h->forced_local)
            {
              if (!bfd_elf_link_record_dynamic_symbol (info, h))
-               return FALSE;
+               return false;
            }
 
          h->needs_plt = 1;
@@ -2791,10 +2743,10 @@ elf_m68k_check_relocs (abfd, info, sec, relocs)
             will be set later (it is never cleared).  We account for that
             possibility below by storing information in the
             pcrel_relocs_copied field of the hash table entry.  */
-         if (!(info->shared
+         if (!(bfd_link_pic (info)
                && (sec->flags & SEC_ALLOC) != 0
                && h != NULL
-               && (!info->symbolic
+               && (!SYMBOLIC_BIND (info, h)
                    || h->root.type == bfd_link_hash_defweak
                    || !h->def_regular)))
            {
@@ -2811,21 +2763,27 @@ elf_m68k_check_relocs (abfd, info, sec, relocs)
        case R_68K_8:
        case R_68K_16:
        case R_68K_32:
+         /* We don't need to handle relocs into sections not going into
+            the "real" output.  */
+         if ((sec->flags & SEC_ALLOC) == 0)
+             break;
+
          if (h != NULL)
            {
              /* Make sure a plt entry is created for this symbol if it
                 turns out to be a function defined by a dynamic object.  */
              h->plt.refcount++;
 
-             if (!info->shared)
+             if (bfd_link_executable (info))
                /* This symbol needs a non-GOT reference.  */
                h->non_got_ref = 1;
            }
 
          /* If we are creating a shared library, we need to copy the
             reloc into the shared library.  */
-         if (info->shared
-             && (sec->flags & SEC_ALLOC) != 0)
+         if (bfd_link_pic (info)
+             && (h == NULL
+                 || !UNDEFWEAK_NO_DYNAMIC_RELOC (info, h)))
            {
              /* When creating a shared object, we must copy these
                 reloc types into the output file.  We create a reloc
@@ -2833,10 +2791,10 @@ elf_m68k_check_relocs (abfd, info, sec, relocs)
              if (sreloc == NULL)
                {
                  sreloc = _bfd_elf_make_dynamic_reloc_section
-                   (sec, dynobj, 2, abfd, /*rela?*/ TRUE);
+                   (sec, dynobj, 2, abfd, /*rela?*/ true);
 
                  if (sreloc == NULL)
-                   return FALSE;
+                   return false;
                }
 
              if (sec->flags & SEC_READONLY
@@ -2876,10 +2834,10 @@ elf_m68k_check_relocs (abfd, info, sec, relocs)
                      void *vpp;
                      Elf_Internal_Sym *isym;
 
-                     isym = bfd_sym_from_r_symndx (&elf_m68k_hash_table (info)->sym_cache,
+                     isym = bfd_sym_from_r_symndx (&elf_m68k_hash_table (info)->root.sym_cache,
                                                    abfd, r_symndx);
                      if (isym == NULL)
-                       return FALSE;
+                       return false;
 
                      s = bfd_section_from_elf_index (abfd, isym->st_shndx);
                      if (s == NULL)
@@ -2898,7 +2856,7 @@ elf_m68k_check_relocs (abfd, info, sec, relocs)
                      p = ((struct elf_m68k_pcrel_relocs_copied *)
                           bfd_alloc (dynobj, (bfd_size_type) sizeof *p));
                      if (p == NULL)
-                       return FALSE;
+                       return false;
                      p->next = *head;
                      *head = p;
                      p->section = sreloc;
@@ -2915,16 +2873,14 @@ elf_m68k_check_relocs (abfd, info, sec, relocs)
             Reconstruct it for later use during GC.  */
        case R_68K_GNU_VTINHERIT:
          if (!bfd_elf_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
-           return FALSE;
+           return false;
          break;
 
          /* This relocation describes which C++ vtable entries are actually
             used.  Record for later use during GC.  */
        case R_68K_GNU_VTENTRY:
-         BFD_ASSERT (h != NULL);
-         if (h != NULL
-             && !bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
-           return FALSE;
+         if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
+           return false;
          break;
 
        default:
@@ -2932,7 +2888,7 @@ elf_m68k_check_relocs (abfd, info, sec, relocs)
        }
     }
 
-  return TRUE;
+  return true;
 }
 
 /* Return the section that should be marked against GC for a given
@@ -2955,136 +2911,6 @@ elf_m68k_gc_mark_hook (asection *sec,
 
   return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
 }
-
-/* Update the got entry reference counts for the section being removed.  */
-
-static bfd_boolean
-elf_m68k_gc_sweep_hook (bfd *abfd,
-                       struct bfd_link_info *info,
-                       asection *sec,
-                       const Elf_Internal_Rela *relocs)
-{
-  Elf_Internal_Shdr *symtab_hdr;
-  struct elf_link_hash_entry **sym_hashes;
-  const Elf_Internal_Rela *rel, *relend;
-  bfd *dynobj;
-  asection *sgot;
-  asection *srelgot;
-  struct elf_m68k_got *got;
-
-  if (info->relocatable)
-    return TRUE;
-
-  dynobj = elf_hash_table (info)->dynobj;
-  if (dynobj == NULL)
-    return TRUE;
-
-  symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
-  sym_hashes = elf_sym_hashes (abfd);
-
-  sgot = bfd_get_section_by_name (dynobj, ".got");
-  srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
-  got = NULL;
-
-  relend = relocs + sec->reloc_count;
-  for (rel = relocs; rel < relend; rel++)
-    {
-      unsigned long r_symndx;
-      struct elf_link_hash_entry *h = NULL;
-
-      r_symndx = ELF32_R_SYM (rel->r_info);
-      if (r_symndx >= symtab_hdr->sh_info)
-       {
-         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;
-       }
-
-      switch (ELF32_R_TYPE (rel->r_info))
-       {
-       case R_68K_GOT8:
-       case R_68K_GOT16:
-       case R_68K_GOT32:
-         if (h != NULL
-             && strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0)
-           break;
-
-         /* FALLTHRU */
-       case R_68K_GOT8O:
-       case R_68K_GOT16O:
-       case R_68K_GOT32O:
-         /* Fall through.  */
-
-         /* TLS relocations.  */
-       case R_68K_TLS_GD8:
-       case R_68K_TLS_GD16:
-       case R_68K_TLS_GD32:
-       case R_68K_TLS_LDM8:
-       case R_68K_TLS_LDM16:
-       case R_68K_TLS_LDM32:
-       case R_68K_TLS_IE8:
-       case R_68K_TLS_IE16:
-       case R_68K_TLS_IE32:
-
-       case R_68K_TLS_TPREL32:
-       case R_68K_TLS_DTPREL32:
-
-         if (got == NULL)
-           {
-             got = elf_m68k_get_bfd2got_entry (elf_m68k_multi_got (info),
-                                               abfd, MUST_FIND, NULL)->got;
-             BFD_ASSERT (got != NULL);
-           }
-
-         {
-           struct elf_m68k_got_entry_key key_;
-           struct elf_m68k_got_entry **got_entry_ptr;
-           struct elf_m68k_got_entry *got_entry;
-
-           elf_m68k_init_got_entry_key (&key_, h, abfd, r_symndx,
-                                        ELF32_R_TYPE (rel->r_info));
-           got_entry_ptr = elf_m68k_find_got_entry_ptr (got, &key_);
-
-           got_entry = *got_entry_ptr;
-
-           if (got_entry->u.s1.refcount > 0)
-             {
-               --got_entry->u.s1.refcount;
-
-               if (got_entry->u.s1.refcount == 0)
-                 /* We don't need the .got entry any more.  */
-                 elf_m68k_remove_got_entry (got, got_entry_ptr);
-             }
-         }
-         break;
-
-       case R_68K_PLT8:
-       case R_68K_PLT16:
-       case R_68K_PLT32:
-       case R_68K_PLT8O:
-       case R_68K_PLT16O:
-       case R_68K_PLT32O:
-       case R_68K_PC8:
-       case R_68K_PC16:
-       case R_68K_PC32:
-       case R_68K_8:
-       case R_68K_16:
-       case R_68K_32:
-         if (h != NULL)
-           {
-             if (h->plt.refcount > 0)
-               --h->plt.refcount;
-           }
-         break;
-
-       default:
-         break;
-       }
-    }
-
-  return TRUE;
-}
 \f
 /* Return the type of PLT associated with OUTPUT_BFD.  */
 
@@ -3107,16 +2933,16 @@ elf_m68k_get_plt_info (bfd *output_bfd)
    and the input sections have been assigned to output sections.
    It's a convenient place to determine the PLT style.  */
 
-static bfd_boolean
-elf_m68k_always_size_sections (bfd *output_bfd, struct bfd_link_info *info)
+static bool
+elf_m68k_early_size_sections (bfd *output_bfd, struct bfd_link_info *info)
 {
   /* Bind input BFDs to GOTs and calculate sizes of .got and .rela.got
      sections.  */
   if (!elf_m68k_partition_multi_got (info))
-    return FALSE;
+    return false;
 
   elf_m68k_hash_table (info)->plt_info = elf_m68k_get_plt_info (output_bfd);
-  return TRUE;
+  return true;
 }
 
 /* Adjust a symbol defined by a dynamic object and referenced by a
@@ -3125,22 +2951,21 @@ elf_m68k_always_size_sections (bfd *output_bfd, struct bfd_link_info *info)
    change the definition to something the rest of the link can
    understand.  */
 
-static bfd_boolean
-elf_m68k_adjust_dynamic_symbol (info, h)
-     struct bfd_link_info *info;
-     struct elf_link_hash_entry *h;
+static bool
+elf_m68k_adjust_dynamic_symbol (struct bfd_link_info *info,
+                               struct elf_link_hash_entry *h)
 {
   struct elf_m68k_link_hash_table *htab;
   bfd *dynobj;
   asection *s;
 
   htab = elf_m68k_hash_table (info);
-  dynobj = elf_hash_table (info)->dynobj;
+  dynobj = htab->root.dynobj;
 
   /* Make sure we know what is going on here.  */
   BFD_ASSERT (dynobj != NULL
              && (h->needs_plt
-                 || h->u.weakdef != NULL
+                 || h->is_weakalias
                  || (h->def_dynamic
                      && h->ref_regular
                      && !h->def_regular)));
@@ -3152,8 +2977,9 @@ elf_m68k_adjust_dynamic_symbol (info, h)
       || h->needs_plt)
     {
       if ((h->plt.refcount <= 0
-           || SYMBOL_CALLS_LOCAL (info, h)
-          || (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
+          || SYMBOL_CALLS_LOCAL (info, h)
+          || ((ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
+               || UNDEFWEAK_NO_DYNAMIC_RELOC (info, h))
               && h->root.type == bfd_link_hash_undefweak))
          /* We must always create the plt entry if it was referenced
             by a PLTxxO relocation.  In this case we already recorded
@@ -3167,7 +2993,7 @@ elf_m68k_adjust_dynamic_symbol (info, h)
             linkage table, and we can just do a PCxx reloc instead.  */
          h->plt.offset = (bfd_vma) -1;
          h->needs_plt = 0;
-         return TRUE;
+         return true;
        }
 
       /* Make sure this symbol is output as a dynamic symbol.  */
@@ -3175,10 +3001,10 @@ elf_m68k_adjust_dynamic_symbol (info, h)
          && !h->forced_local)
        {
          if (! bfd_elf_link_record_dynamic_symbol (info, h))
-           return FALSE;
+           return false;
        }
 
-      s = bfd_get_section_by_name (dynobj, ".plt");
+      s = htab->root.splt;
       BFD_ASSERT (s != NULL);
 
       /* If this is the first .plt entry, make room for the special
@@ -3191,7 +3017,7 @@ elf_m68k_adjust_dynamic_symbol (info, h)
         location in the .plt.  This is required to make function
         pointers compare as equal between the normal executable and
         the shared library.  */
-      if (!info->shared
+      if (!bfd_link_pic (info)
          && !h->def_regular)
        {
          h->root.u.def.section = s;
@@ -3205,16 +3031,16 @@ 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");
+      s = htab->root.sgotplt;
       BFD_ASSERT (s != NULL);
       s->size += 4;
 
       /* We also need to make an entry in the .rela.plt section.  */
-      s = bfd_get_section_by_name (dynobj, ".rela.plt");
+      s = htab->root.srelplt;
       BFD_ASSERT (s != NULL);
       s->size += sizeof (Elf32_External_Rela);
 
-      return TRUE;
+      return true;
     }
 
   /* Reinitialize the plt offset now that it is not used as a reference
@@ -3224,13 +3050,13 @@ elf_m68k_adjust_dynamic_symbol (info, h)
   /* 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->u.weakdef != NULL)
+  if (h->is_weakalias)
     {
-      BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined
-                 || h->u.weakdef->root.type == bfd_link_hash_defweak);
-      h->root.u.def.section = h->u.weakdef->root.u.def.section;
-      h->root.u.def.value = h->u.weakdef->root.u.def.value;
-      return TRUE;
+      struct elf_link_hash_entry *def = weakdef (h);
+      BFD_ASSERT (def->root.type == bfd_link_hash_defined);
+      h->root.u.def.section = def->root.u.def.section;
+      h->root.u.def.value = def->root.u.def.value;
+      return true;
     }
 
   /* This is a reference to a symbol defined by a dynamic object which
@@ -3240,20 +3066,13 @@ elf_m68k_adjust_dynamic_symbol (info, h)
      only references to the symbol are via the global offset table.
      For such cases we need not do anything here; the relocations will
      be handled correctly by relocate_section.  */
-  if (info->shared)
-    return TRUE;
+  if (bfd_link_pic (info))
+    return true;
 
   /* 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->non_got_ref)
-    return TRUE;
-
-  if (h->size == 0)
-    {
-      (*_bfd_error_handler) (_("dynamic variable `%s' is zero size"),
-                            h->root.root.string);
-      return TRUE;
-    }
+    return true;
 
   /* We must allocate the symbol in our .dynbss section, which will
      become part of the .bss section of the executable.  There will be
@@ -3265,47 +3084,46 @@ elf_m68k_adjust_dynamic_symbol (info, h)
      both the dynamic object and the regular object will refer to the
      same memory location for the variable.  */
 
-  s = bfd_get_section_by_name (dynobj, ".dynbss");
+  s = bfd_get_linker_section (dynobj, ".dynbss");
   BFD_ASSERT (s != NULL);
 
   /* We must generate a R_68K_COPY reloc to tell the dynamic linker to
      copy the initial value out of the dynamic object and into the
      runtime process image.  We need to remember the offset into the
      .rela.bss section we are going to use.  */
-  if ((h->root.u.def.section->flags & SEC_ALLOC) != 0)
+  if ((h->root.u.def.section->flags & SEC_ALLOC) != 0 && h->size != 0)
     {
       asection *srel;
 
-      srel = bfd_get_section_by_name (dynobj, ".rela.bss");
+      srel = bfd_get_linker_section (dynobj, ".rela.bss");
       BFD_ASSERT (srel != NULL);
       srel->size += sizeof (Elf32_External_Rela);
       h->needs_copy = 1;
     }
 
-  return _bfd_elf_adjust_dynamic_copy (h, s);
+  return _bfd_elf_adjust_dynamic_copy (info, h, s);
 }
 
 /* Set the sizes of the dynamic sections.  */
 
-static bfd_boolean
-elf_m68k_size_dynamic_sections (output_bfd, info)
-     bfd *output_bfd ATTRIBUTE_UNUSED;
-     struct bfd_link_info *info;
+static bool
+elf_m68k_late_size_sections (bfd *output_bfd ATTRIBUTE_UNUSED,
+                            struct bfd_link_info *info)
 {
   bfd *dynobj;
   asection *s;
-  bfd_boolean plt;
-  bfd_boolean relocs;
+  bool relocs;
 
   dynobj = elf_hash_table (info)->dynobj;
-  BFD_ASSERT (dynobj != NULL);
+  if (dynobj == NULL)
+    return true;
 
   if (elf_hash_table (info)->dynamic_sections_created)
     {
       /* Set the contents of the .interp section to the interpreter.  */
-      if (info->executable)
+      if (bfd_link_executable (info) && !info->nointerp)
        {
-         s = bfd_get_section_by_name (dynobj, ".interp");
+         s = bfd_get_linker_section (dynobj, ".interp");
          BFD_ASSERT (s != NULL);
          s->size = sizeof ELF_DYNAMIC_INTERPRETER;
          s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
@@ -3318,7 +3136,7 @@ elf_m68k_size_dynamic_sections (output_bfd, info)
         not actually use these entries.  Reset the size of .rela.got,
         which will cause it to get stripped from the output file
         below.  */
-      s = bfd_get_section_by_name (dynobj, ".rela.got");
+      s = elf_hash_table (info)->srelgot;
       if (s != NULL)
        s->size = 0;
     }
@@ -3329,16 +3147,15 @@ elf_m68k_size_dynamic_sections (output_bfd, info)
      against symbols that have become local due to visibility changes.
      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)
+  if (bfd_link_pic (info))
     elf_link_hash_traverse (elf_hash_table (info),
                            elf_m68k_discard_copies,
-                           (PTR) info);
+                           info);
 
   /* The check_relocs and adjust_dynamic_symbol entry points have
      determined the sizes of the various dynamic sections.  Allocate
      memory for them.  */
-  plt = FALSE;
-  relocs = FALSE;
+  relocs = false;
   for (s = dynobj->sections; s != NULL; s = s->next)
     {
       const char *name;
@@ -3348,25 +3165,25 @@ elf_m68k_size_dynamic_sections (output_bfd, info)
 
       /* It's OK to base decisions on the section name, because none
         of the dynobj section names depend upon the input files.  */
-      name = bfd_get_section_name (dynobj, s);
+      name = bfd_section_name (s);
 
       if (strcmp (name, ".plt") == 0)
        {
          /* Remember whether there is a PLT.  */
-         plt = s->size != 0;
+         ;
        }
-      else if (CONST_STRNEQ (name, ".rela"))
+      else if (startswith (name, ".rela"))
        {
          if (s->size != 0)
            {
-             relocs = TRUE;
+             relocs = true;
 
              /* We use the reloc_count field as a counter if we need
                 to copy relocs into the output file.  */
              s->reloc_count = 0;
            }
        }
-      else if (! CONST_STRNEQ (name, ".got")
+      else if (! startswith (name, ".got")
               && strcmp (name, ".dynbss") != 0)
        {
          /* It's not one of our sections, so don't allocate space.  */
@@ -3399,51 +3216,10 @@ elf_m68k_size_dynamic_sections (output_bfd, info)
         contents to zero.  */
       s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->size);
       if (s->contents == NULL)
-       return FALSE;
-    }
-
-  if (elf_hash_table (info)->dynamic_sections_created)
-    {
-      /* Add some entries to the .dynamic section.  We fill in the
-        values later, in elf_m68k_finish_dynamic_sections, but we
-        must add the entries now so that we get the correct size for
-        the .dynamic section.  The DT_DEBUG entry is filled in by the
-        dynamic linker and used by the debugger.  */
-#define add_dynamic_entry(TAG, VAL) \
-  _bfd_elf_add_dynamic_entry (info, TAG, VAL)
-
-      if (!info->shared)
-       {
-         if (!add_dynamic_entry (DT_DEBUG, 0))
-           return FALSE;
-       }
-
-      if (plt)
-       {
-         if (!add_dynamic_entry (DT_PLTGOT, 0)
-             || !add_dynamic_entry (DT_PLTRELSZ, 0)
-             || !add_dynamic_entry (DT_PLTREL, DT_RELA)
-             || !add_dynamic_entry (DT_JMPREL, 0))
-           return FALSE;
-       }
-
-      if (relocs)
-       {
-         if (!add_dynamic_entry (DT_RELA, 0)
-             || !add_dynamic_entry (DT_RELASZ, 0)
-             || !add_dynamic_entry (DT_RELAENT, sizeof (Elf32_External_Rela)))
-           return FALSE;
-       }
-
-      if ((info->flags & DF_TEXTREL) != 0)
-       {
-         if (!add_dynamic_entry (DT_TEXTREL, 0))
-           return FALSE;
-       }
+       return false;
     }
-#undef add_dynamic_entry
 
-  return TRUE;
+  return _bfd_elf_add_dynamic_tags (output_bfd, info, relocs);
 }
 
 /* This function is called via elf_link_hash_traverse if we are
@@ -3459,17 +3235,13 @@ elf_m68k_size_dynamic_sections (output_bfd, info)
    against a readonly section, and set the DF_TEXTREL flag in this
    case.  */
 
-static bfd_boolean
-elf_m68k_discard_copies (h, inf)
-     struct elf_link_hash_entry *h;
-     PTR inf;
+static bool
+elf_m68k_discard_copies (struct elf_link_hash_entry *h,
+                        void * inf)
 {
   struct bfd_link_info *info = (struct bfd_link_info *) inf;
   struct elf_m68k_pcrel_relocs_copied *s;
 
-  if (h->root.type == bfd_link_hash_warning)
-    h = (struct elf_link_hash_entry *) h->root.u.i.link;
-
   if (!SYMBOL_CALLS_LOCAL (info, h))
     {
       if ((info->flags & DF_TEXTREL) == 0)
@@ -3485,7 +3257,19 @@ elf_m68k_discard_copies (h, inf)
              }
        }
 
-      return TRUE;
+      /* Make sure undefined weak symbols are output as a dynamic symbol
+        in PIEs.  */
+      if (h->non_got_ref
+         && h->root.type == bfd_link_hash_undefweak
+         && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
+         && h->dynindx == -1
+         && !h->forced_local)
+       {
+         if (! bfd_elf_link_record_dynamic_symbol (info, h))
+           return false;
+       }
+
+      return true;
     }
 
   for (s = elf_m68k_hash_entry (h)->pcrel_relocs_copied;
@@ -3493,7 +3277,7 @@ elf_m68k_discard_copies (h, inf)
        s = s->next)
     s->section->size -= s->count * sizeof (Elf32_External_Rela);
 
-  return TRUE;
+  return true;
 }
 
 
@@ -3570,7 +3354,7 @@ elf_m68k_init_got_entry_static (struct bfd_link_info *info,
       break;
 
     default:
-      BFD_ASSERT (FALSE);
+      BFD_ASSERT (false);
     }
 }
 
@@ -3621,7 +3405,7 @@ elf_m68k_init_got_entry_local_shared (struct bfd_link_info *info,
       break;
 
     default:
-      BFD_ASSERT (FALSE);
+      BFD_ASSERT (false);
     }
 
   /* Offset of the GOT entry.  */
@@ -3637,19 +3421,16 @@ elf_m68k_init_got_entry_local_shared (struct bfd_link_info *info,
 
 /* Relocate an M68K ELF section.  */
 
-static bfd_boolean
-elf_m68k_relocate_section (output_bfd, info, input_bfd, input_section,
-                          contents, relocs, local_syms, local_sections)
-     bfd *output_bfd;
-     struct bfd_link_info *info;
-     bfd *input_bfd;
-     asection *input_section;
-     bfd_byte *contents;
-     Elf_Internal_Rela *relocs;
-     Elf_Internal_Sym *local_syms;
-     asection **local_sections;
+static int
+elf_m68k_relocate_section (bfd *output_bfd,
+                          struct bfd_link_info *info,
+                          bfd *input_bfd,
+                          asection *input_section,
+                          bfd_byte *contents,
+                          Elf_Internal_Rela *relocs,
+                          Elf_Internal_Sym *local_syms,
+                          asection **local_sections)
 {
-  bfd *dynobj;
   Elf_Internal_Shdr *symtab_hdr;
   struct elf_link_hash_entry **sym_hashes;
   asection *sgot;
@@ -3660,7 +3441,6 @@ elf_m68k_relocate_section (output_bfd, info, input_bfd, input_section,
   Elf_Internal_Rela *rel;
   Elf_Internal_Rela *relend;
 
-  dynobj = elf_hash_table (info)->dynobj;
   symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
   sym_hashes = elf_sym_hashes (input_bfd);
 
@@ -3682,14 +3462,15 @@ elf_m68k_relocate_section (output_bfd, info, input_bfd, input_section,
       Elf_Internal_Sym *sym;
       asection *sec;
       bfd_vma relocation;
-      bfd_boolean unresolved_reloc;
+      bool unresolved_reloc;
       bfd_reloc_status_type r;
+      bool resolved_to_zero;
 
       r_type = ELF32_R_TYPE (rel->r_info);
       if (r_type < 0 || r_type >= (int) R_68K_max)
        {
          bfd_set_error (bfd_error_bad_value);
-         return FALSE;
+         return false;
        }
       howto = howto_table + r_type;
 
@@ -3698,7 +3479,7 @@ elf_m68k_relocate_section (output_bfd, info, input_bfd, input_section,
       h = NULL;
       sym = NULL;
       sec = NULL;
-      unresolved_reloc = FALSE;
+      unresolved_reloc = false;
 
       if (r_symndx < symtab_hdr->sh_info)
        {
@@ -3708,28 +3489,24 @@ elf_m68k_relocate_section (output_bfd, info, input_bfd, input_section,
        }
       else
        {
-         bfd_boolean warned;
+         bool warned, ignored;
 
          RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel,
                                   r_symndx, symtab_hdr, sym_hashes,
                                   h, sec, relocation,
-                                  unresolved_reloc, warned);
+                                  unresolved_reloc, warned, ignored);
        }
 
-      if (sec != NULL && elf_discarded_section (sec))
-       {
-         /* For relocs against symbols from removed linkonce sections,
-            or sections discarded by a linker script, we just want the
-            section contents zeroed.  Avoid any special processing.  */
-         _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
-         rel->r_info = 0;
-         rel->r_addend = 0;
-         continue;
-       }
+      if (sec != NULL && discarded_section (sec))
+       RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+                                        rel, 1, relend, howto, 0, contents);
 
-      if (info->relocatable)
+      if (bfd_link_relocatable (info))
        continue;
 
+      resolved_to_zero = (h != NULL
+                         && UNDEFWEAK_NO_DYNAMIC_RELOC (info, h));
+
       switch (r_type)
        {
        case R_68K_GOT8:
@@ -3745,21 +3522,16 @@ elf_m68k_relocate_section (output_bfd, info, input_bfd, input_section,
                  bfd_vma sgot_output_offset;
                  bfd_vma got_offset;
 
-                 if (sgot == NULL)
-                   {
-                     sgot = bfd_get_section_by_name (dynobj, ".got");
+                 sgot = elf_hash_table (info)->sgot;
 
-                     if (sgot != NULL)
-                       sgot_output_offset = sgot->output_offset;
-                     else
-                       /* In this case we have a reference to
-                          _GLOBAL_OFFSET_TABLE_, but the GOT itself is
-                          empty.
-                          ??? Issue a warning?  */
-                       sgot_output_offset = 0;
-                   }
-                 else
+                 if (sgot != NULL)
                    sgot_output_offset = sgot->output_offset;
+                 else
+                   /* In this case we have a reference to
+                      _GLOBAL_OFFSET_TABLE_, but the GOT itself is
+                      empty.
+                      ??? Issue a warning?  */
+                   sgot_output_offset = 0;
 
                  if (got == NULL)
                    {
@@ -3820,19 +3592,13 @@ elf_m68k_relocate_section (output_bfd, info, input_bfd, input_section,
            bfd_vma *off_ptr;
            bfd_vma off;
 
-           if (sgot == NULL)
-             {
-               sgot = bfd_get_section_by_name (dynobj, ".got");
-               BFD_ASSERT (sgot != NULL);
-             }
+           sgot = elf_hash_table (info)->sgot;
+           BFD_ASSERT (sgot != NULL);
 
            if (got == NULL)
-             {
-               got = elf_m68k_get_bfd2got_entry (elf_m68k_multi_got (info),
-                                                 input_bfd, MUST_FIND,
-                                                 NULL)->got;
-               BFD_ASSERT (got != NULL);
-             }
+             got = elf_m68k_get_bfd2got_entry (elf_m68k_multi_got (info),
+                                               input_bfd, MUST_FIND,
+                                               NULL)->got;
 
            /* Get GOT offset for this symbol.  */
            elf_m68k_init_got_entry_key (&key_, h, input_bfd, r_symndx,
@@ -3854,13 +3620,16 @@ elf_m68k_relocate_section (output_bfd, info, input_bfd, input_section,
                       itself.  */
                    && elf_m68k_reloc_got_type (r_type) != R_68K_TLS_LDM32)
                  {
-                   bfd_boolean dyn;
+                   bool dyn;
 
                    dyn = elf_hash_table (info)->dynamic_sections_created;
-                   if (!WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h)
-                       || (info->shared
+                   if (!WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn,
+                                                         bfd_link_pic (info),
+                                                         h)
+                       || (bfd_link_pic (info)
                            && SYMBOL_REFERENCES_LOCAL (info, h))
-                       || (ELF_ST_VISIBILITY (h->other)
+                       || ((ELF_ST_VISIBILITY (h->other)
+                            || resolved_to_zero)
                            && h->root.type == bfd_link_hash_undefweak))
                      {
                        /* This is actually a static link, or it is a
@@ -3886,16 +3655,13 @@ elf_m68k_relocate_section (output_bfd, info, input_bfd, input_section,
                        *off_ptr |= 1;
                      }
                    else
-                     unresolved_reloc = FALSE;
+                     unresolved_reloc = false;
                  }
-               else if (info->shared) /* && h == NULL */
+               else if (bfd_link_pic (info)) /* && h == NULL */
                  /* Process local symbol during dynamic link.  */
                  {
-                   if (srela == NULL)
-                     {
-                       srela = bfd_get_section_by_name (dynobj, ".rela.got");
-                       BFD_ASSERT (srela != NULL);
-                     }
+                   srela = elf_hash_table (info)->srelgot;
+                   BFD_ASSERT (srela != NULL);
 
                    elf_m68k_init_got_entry_local_shared (info,
                                                          output_bfd,
@@ -3907,7 +3673,7 @@ elf_m68k_relocate_section (output_bfd, info, input_bfd, input_section,
 
                    *off_ptr |= 1;
                  }
-               else /* h == NULL && !info->shared */
+               else /* h == NULL && !bfd_link_pic (info) */
                  {
                    elf_m68k_init_got_entry_static (info,
                                                    output_bfd,
@@ -3961,14 +3727,16 @@ elf_m68k_relocate_section (output_bfd, info, input_bfd, input_section,
        case R_68K_TLS_LE32:
        case R_68K_TLS_LE16:
        case R_68K_TLS_LE8:
-         if (info->shared)
+         if (bfd_link_dll (info))
            {
-             (*_bfd_error_handler)
-               (_("%B(%A+0x%lx): R_68K_TLS_LE32 relocation not permitted "
-                  "in shared object"),
-                input_bfd, input_section, (long) rel->r_offset, howto->name);
-
-             return FALSE;
+             _bfd_error_handler
+               /* xgettext:c-format */
+               (_("%pB(%pA+%#" PRIx64 "): "
+                  "%s relocation not permitted in shared object"),
+                input_bfd, input_section, (uint64_t) rel->r_offset,
+                howto->name);
+
+             return false;
            }
          else
            relocation -= tpoff_base (info);
@@ -3995,16 +3763,13 @@ elf_m68k_relocate_section (output_bfd, info, input_bfd, input_section,
              break;
            }
 
-         if (splt == NULL)
-           {
-             splt = bfd_get_section_by_name (dynobj, ".plt");
-             BFD_ASSERT (splt != NULL);
-           }
+         splt = elf_hash_table (info)->splt;
+         BFD_ASSERT (splt != NULL);
 
          relocation = (splt->output_section->vma
                        + splt->output_offset
                        + h->plt.offset);
-         unresolved_reloc = FALSE;
+         unresolved_reloc = false;
          break;
 
        case R_68K_PLT8O:
@@ -4014,14 +3779,11 @@ elf_m68k_relocate_section (output_bfd, info, input_bfd, input_section,
             the procedure linkage table.  */
          BFD_ASSERT (h != NULL && h->plt.offset != (bfd_vma) -1);
 
-         if (splt == NULL)
-           {
-             splt = bfd_get_section_by_name (dynobj, ".plt");
-             BFD_ASSERT (splt != NULL);
-           }
+         splt = elf_hash_table (info)->splt;
+         BFD_ASSERT (splt != NULL);
 
          relocation = h->plt.offset;
-         unresolved_reloc = FALSE;
+         unresolved_reloc = false;
 
          /* This relocation does not use the addend.  */
          rel->r_addend = 0;
@@ -4034,11 +3796,12 @@ elf_m68k_relocate_section (output_bfd, info, input_bfd, input_section,
        case R_68K_PC8:
        case R_68K_PC16:
        case R_68K_PC32:
-         if (info->shared
-             && r_symndx != 0
+         if (bfd_link_pic (info)
+             && r_symndx != STN_UNDEF
              && (input_section->flags & SEC_ALLOC) != 0
              && (h == NULL
-                 || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
+                 || (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
+                     && !resolved_to_zero)
                  || h->root.type != bfd_link_hash_undefweak)
              && ((r_type != R_68K_PC8
                   && r_type != R_68K_PC16
@@ -4047,22 +3810,22 @@ elf_m68k_relocate_section (output_bfd, info, input_bfd, input_section,
            {
              Elf_Internal_Rela outrel;
              bfd_byte *loc;
-             bfd_boolean skip, relocate;
+             bool skip, relocate;
 
              /* When generating a shared object, these relocations
                 are copied into the output file to be resolved at run
                 time.  */
 
-             skip = FALSE;
-             relocate = FALSE;
+             skip = false;
+             relocate = false;
 
              outrel.r_offset =
                _bfd_elf_section_offset (output_bfd, info, input_section,
                                         rel->r_offset);
              if (outrel.r_offset == (bfd_vma) -1)
-               skip = TRUE;
+               skip = true;
              else if (outrel.r_offset == (bfd_vma) -2)
-               skip = TRUE, relocate = TRUE;
+               skip = true, relocate = true;
              outrel.r_offset += (input_section->output_section->vma
                                  + input_section->output_offset);
 
@@ -4073,8 +3836,8 @@ elf_m68k_relocate_section (output_bfd, info, input_bfd, input_section,
                       && (r_type == R_68K_PC8
                           || r_type == R_68K_PC16
                           || r_type == R_68K_PC32
-                          || !info->shared
-                          || !info->symbolic
+                          || !bfd_link_pic (info)
+                          || !SYMBOLIC_BIND (info, h)
                           || !h->def_regular))
                {
                  outrel.r_info = ELF32_R_INFO (h->dynindx, r_type);
@@ -4087,7 +3850,7 @@ elf_m68k_relocate_section (output_bfd, info, input_bfd, input_section,
 
                  if (r_type == R_68K_32)
                    {
-                     relocate = TRUE;
+                     relocate = true;
                      outrel.r_info = ELF32_R_INFO (0, R_68K_RELATIVE);
                    }
                  else
@@ -4099,7 +3862,7 @@ elf_m68k_relocate_section (output_bfd, info, input_bfd, input_section,
                      else if (sec == NULL || sec->owner == NULL)
                        {
                          bfd_set_error (bfd_error_bad_value);
-                         return FALSE;
+                         return false;
                        }
                      else
                        {
@@ -4135,9 +3898,9 @@ elf_m68k_relocate_section (output_bfd, info, input_bfd, input_section,
              bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
 
              /* This reloc will be computed at runtime, so there's no
-                 need to do anything now, except for R_68K_32
-                 relocations that have been turned into
-                 R_68K_RELATIVE.  */
+                need to do anything now, except for R_68K_32
+                relocations that have been turned into
+                R_68K_RELATIVE.  */
              if (!relocate)
                continue;
            }
@@ -4158,19 +3921,23 @@ elf_m68k_relocate_section (output_bfd, info, input_bfd, input_section,
         not process them.  */
       if (unresolved_reloc
          && !((input_section->flags & SEC_DEBUGGING) != 0
-              && h->def_dynamic))
+              && h->def_dynamic)
+         && _bfd_elf_section_offset (output_bfd, info, input_section,
+                                     rel->r_offset) != (bfd_vma) -1)
        {
-         (*_bfd_error_handler)
-           (_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
+         _bfd_error_handler
+           /* xgettext:c-format */
+           (_("%pB(%pA+%#" PRIx64 "): "
+              "unresolvable %s relocation against symbol `%s'"),
             input_bfd,
             input_section,
-            (long) rel->r_offset,
+            (uint64_t) rel->r_offset,
             howto->name,
             h->root.root.string);
-         return FALSE;
+         return false;
        }
 
-      if (r_symndx != 0
+      if (r_symndx != STN_UNDEF
          && r_type != R_68K_NONE
          && (h == NULL
              || h->root.type == bfd_link_hash_defined
@@ -4191,16 +3958,18 @@ elf_m68k_relocate_section (output_bfd, info, input_bfd, input_section,
                  name = (bfd_elf_string_from_elf_section
                          (input_bfd, symtab_hdr->sh_link, sym->st_name));
                  if (name == NULL || *name == '\0')
-                   name = bfd_section_name (input_bfd, sec);
+                   name = bfd_section_name (sec);
                }
 
-             (*_bfd_error_handler)
+             _bfd_error_handler
                ((sym_type == STT_TLS
-                 ? _("%B(%A+0x%lx): %s used with TLS symbol %s")
-                 : _("%B(%A+0x%lx): %s used with non-TLS symbol %s")),
+                 /* xgettext:c-format */
+                 ? _("%pB(%pA+%#" PRIx64 "): %s used with TLS symbol %s")
+                 /* xgettext:c-format */
+                 : _("%pB(%pA+%#" PRIx64 "): %s used with non-TLS symbol %s")),
                 input_bfd,
                 input_section,
-                (long) rel->r_offset,
+                (uint64_t) rel->r_offset,
                 howto->name,
                 name);
            }
@@ -4222,31 +3991,28 @@ elf_m68k_relocate_section (output_bfd, info, input_bfd, input_section,
                                                      symtab_hdr->sh_link,
                                                      sym->st_name);
              if (name == NULL)
-               return FALSE;
+               return false;
              if (*name == '\0')
-               name = bfd_section_name (input_bfd, sec);
+               name = bfd_section_name (sec);
            }
 
          if (r == bfd_reloc_overflow)
-           {
-             if (!(info->callbacks->reloc_overflow
-                   (info, (h ? &h->root : NULL), name, howto->name,
-                    (bfd_vma) 0, input_bfd, input_section,
-                    rel->r_offset)))
-               return FALSE;
-           }
+           (*info->callbacks->reloc_overflow)
+             (info, (h ? &h->root : NULL), name, howto->name,
+              (bfd_vma) 0, input_bfd, input_section, rel->r_offset);
          else
            {
-             (*_bfd_error_handler)
-               (_("%B(%A+0x%lx): reloc against `%s': error %d"),
+             _bfd_error_handler
+               /* xgettext:c-format */
+               (_("%pB(%pA+%#" PRIx64 "): reloc against `%s': error %d"),
                 input_bfd, input_section,
-                (long) rel->r_offset, name, (int) r);
-             return FALSE;
+                (uint64_t) rel->r_offset, name, (int) r);
+             return false;
            }
        }
     }
 
-  return TRUE;
+  return true;
 }
 
 /* Install an M_68K_PC32 relocation against VALUE at offset OFFSET
@@ -4267,12 +4033,11 @@ elf_m68k_install_pc32 (asection *sec, bfd_vma offset, bfd_vma value)
 /* Finish up dynamic symbol handling.  We set the contents of various
    dynamic sections here.  */
 
-static bfd_boolean
-elf_m68k_finish_dynamic_symbol (output_bfd, info, h, sym)
-     bfd *output_bfd;
-     struct bfd_link_info *info;
-     struct elf_link_hash_entry *h;
-     Elf_Internal_Sym *sym;
+static bool
+elf_m68k_finish_dynamic_symbol (bfd *output_bfd,
+                               struct bfd_link_info *info,
+                               struct elf_link_hash_entry *h,
+                               Elf_Internal_Sym *sym)
 {
   bfd *dynobj;
 
@@ -4295,9 +4060,9 @@ elf_m68k_finish_dynamic_symbol (output_bfd, info, h, sym)
       BFD_ASSERT (h->dynindx != -1);
 
       plt_info = elf_m68k_hash_table (info)->plt_info;
-      splt = bfd_get_section_by_name (dynobj, ".plt");
-      sgot = bfd_get_section_by_name (dynobj, ".got.plt");
-      srela = bfd_get_section_by_name (dynobj, ".rela.plt");
+      splt = elf_hash_table (info)->splt;
+      sgot = elf_hash_table (info)->sgotplt;
+      srela = elf_hash_table (info)->srelplt;
       BFD_ASSERT (splt != NULL && sgot != NULL && srela != NULL);
 
       /* Get the index in the procedure linkage table which
@@ -4362,8 +4127,8 @@ elf_m68k_finish_dynamic_symbol (output_bfd, info, h, sym)
       /* This symbol has an entry in the global offset table.  Set it
         up.  */
 
-      sgot = bfd_get_section_by_name (dynobj, ".got");
-      srela = bfd_get_section_by_name (dynobj, ".rela.got");
+      sgot = elf_hash_table (info)->sgot;
+      srela = elf_hash_table (info)->srelgot;
       BFD_ASSERT (sgot != NULL && srela != NULL);
 
       got_entry = elf_m68k_hash_entry (h)->glist;
@@ -4381,7 +4146,7 @@ elf_m68k_finish_dynamic_symbol (output_bfd, info, h, sym)
             the symbol was forced to be local because of a version file.
             The entry in the global offset table already have been
             initialized in the relocate_section function.  */
-         if (info->shared
+         if (bfd_link_pic (info)
              && SYMBOL_REFERENCES_LOCAL (info, h))
            {
              bfd_vma relocation;
@@ -4398,6 +4163,11 @@ elf_m68k_finish_dynamic_symbol (output_bfd, info, h, sym)
                  break;
 
                case R_68K_TLS_GD32:
+                 /* The value for this relocation is actually put in
+                    the second GOT slot.  */
+                 relocation = bfd_get_signed_32 (output_bfd,
+                                                 (sgot->contents
+                                                  + got_entry_offset + 4));
                  relocation += dtpoff_base (info);
                  break;
 
@@ -4406,7 +4176,7 @@ elf_m68k_finish_dynamic_symbol (output_bfd, info, h, sym)
                  break;
 
                default:
-                 BFD_ASSERT (FALSE);
+                 BFD_ASSERT (false);
                }
 
              elf_m68k_init_got_entry_local_shared (info,
@@ -4460,7 +4230,7 @@ elf_m68k_finish_dynamic_symbol (output_bfd, info, h, sym)
                  break;
 
                default:
-                 BFD_ASSERT (FALSE);
+                 BFD_ASSERT (false);
                  break;
                }
            }
@@ -4481,8 +4251,7 @@ elf_m68k_finish_dynamic_symbol (output_bfd, info, h, sym)
                  && (h->root.type == bfd_link_hash_defined
                      || h->root.type == bfd_link_hash_defweak));
 
-      s = bfd_get_section_by_name (h->root.u.def.section->owner,
-                                  ".rela.bss");
+      s = bfd_get_linker_section (dynobj, ".rela.bss");
       BFD_ASSERT (s != NULL);
 
       rela.r_offset = (h->root.u.def.value
@@ -4494,20 +4263,13 @@ elf_m68k_finish_dynamic_symbol (output_bfd, info, h, sym)
       bfd_elf32_swap_reloca_out (output_bfd, &rela, loc);
     }
 
-  /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute.  */
-  if (strcmp (h->root.root.string, "_DYNAMIC") == 0
-      || h == elf_hash_table (info)->hgot)
-    sym->st_shndx = SHN_ABS;
-
-  return TRUE;
+  return true;
 }
 
 /* Finish up the dynamic sections.  */
 
-static bfd_boolean
-elf_m68k_finish_dynamic_sections (output_bfd, info)
-     bfd *output_bfd;
-     struct bfd_link_info *info;
+static bool
+elf_m68k_finish_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
 {
   bfd *dynobj;
   asection *sgot;
@@ -4515,16 +4277,16 @@ elf_m68k_finish_dynamic_sections (output_bfd, info)
 
   dynobj = elf_hash_table (info)->dynobj;
 
-  sgot = bfd_get_section_by_name (dynobj, ".got.plt");
+  sgot = elf_hash_table (info)->sgotplt;
   BFD_ASSERT (sgot != NULL);
-  sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
+  sdyn = bfd_get_linker_section (dynobj, ".dynamic");
 
   if (elf_hash_table (info)->dynamic_sections_created)
     {
       asection *splt;
       Elf32_External_Dyn *dyncon, *dynconend;
 
-      splt = bfd_get_section_by_name (dynobj, ".plt");
+      splt = elf_hash_table (info)->splt;
       BFD_ASSERT (splt != NULL && sdyn != NULL);
 
       dyncon = (Elf32_External_Dyn *) sdyn->contents;
@@ -4532,7 +4294,6 @@ elf_m68k_finish_dynamic_sections (output_bfd, info)
       for (; dyncon < dynconend; dyncon++)
        {
          Elf_Internal_Dyn dyn;
-         const char *name;
          asection *s;
 
          bfd_elf32_swap_dyn_in (dynobj, dyncon, &dyn);
@@ -4543,37 +4304,20 @@ elf_m68k_finish_dynamic_sections (output_bfd, info)
              break;
 
            case DT_PLTGOT:
-             name = ".got";
+             s = elf_hash_table (info)->sgotplt;
              goto get_vma;
            case DT_JMPREL:
-             name = ".rela.plt";
+             s = elf_hash_table (info)->srelplt;
            get_vma:
-             s = bfd_get_section_by_name (output_bfd, name);
-             BFD_ASSERT (s != NULL);
-             dyn.d_un.d_ptr = s->vma;
+             dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
              bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
              break;
 
            case DT_PLTRELSZ:
-             s = bfd_get_section_by_name (output_bfd, ".rela.plt");
-             BFD_ASSERT (s != NULL);
+             s = elf_hash_table (info)->srelplt;
              dyn.d_un.d_val = s->size;
              bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
              break;
-
-           case DT_RELASZ:
-             /* The procedure linkage table relocs (DT_JMPREL) should
-                not be included in the overall relocs (DT_RELA).
-                Therefore, we override the DT_RELASZ entry here to
-                make it not include the JMPREL relocs.  Since the
-                linker script arranges for .rela.plt to follow all
-                other relocation sections, we don't have to worry
-                about changing the DT_RELA entry.  */
-             s = bfd_get_section_by_name (output_bfd, ".rela.plt");
-             if (s != NULL)
-               dyn.d_un.d_val -= s->size;
-             bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
-             break;
            }
        }
 
@@ -4615,7 +4359,7 @@ elf_m68k_finish_dynamic_sections (output_bfd, info)
 
   elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 4;
 
-  return TRUE;
+  return true;
 }
 
 /* Given a .data section and a .emreloc in-memory section, store
@@ -4625,13 +4369,10 @@ elf_m68k_finish_dynamic_sections (output_bfd, info)
    after the add_symbols entry point has been called for all the
    objects, and before the final_link entry point is called.  */
 
-bfd_boolean
-bfd_m68k_elf32_create_embedded_relocs (abfd, info, datasec, relsec, errmsg)
-     bfd *abfd;
-     struct bfd_link_info *info;
-     asection *datasec;
-     asection *relsec;
-     char **errmsg;
+bool
+bfd_m68k_elf32_create_embedded_relocs (bfd *abfd, struct bfd_link_info *info,
+                                      asection *datasec, asection *relsec,
+                                      char **errmsg)
 {
   Elf_Internal_Shdr *symtab_hdr;
   Elf_Internal_Sym *isymbuf = NULL;
@@ -4640,18 +4381,18 @@ bfd_m68k_elf32_create_embedded_relocs (abfd, info, datasec, relsec, errmsg)
   bfd_byte *p;
   bfd_size_type amt;
 
-  BFD_ASSERT (! info->relocatable);
+  BFD_ASSERT (! bfd_link_relocatable (info));
 
   *errmsg = NULL;
 
   if (datasec->reloc_count == 0)
-    return TRUE;
+    return true;
 
   symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
 
   /* Get a copy of the native relocations.  */
   internal_relocs = (_bfd_elf_link_read_relocs
-                    (abfd, datasec, (PTR) NULL, (Elf_Internal_Rela *) NULL,
+                    (abfd, datasec, NULL, (Elf_Internal_Rela *) NULL,
                      info->keep_memory));
   if (internal_relocs == NULL)
     goto error_return;
@@ -4677,7 +4418,7 @@ bfd_m68k_elf32_create_embedded_relocs (abfd, info, datasec, relsec, errmsg)
       /* We can only relocate absolute longword relocs at run time.  */
       if (ELF32_R_TYPE (irel->r_info) != (int) R_68K_32)
        {
-         *errmsg = _("unsupported reloc type");
+         *errmsg = _("unsupported relocation type");
          bfd_set_error (bfd_error_bad_value);
          goto error_return;
        }
@@ -4725,20 +4466,18 @@ bfd_m68k_elf32_create_embedded_relocs (abfd, info, datasec, relsec, errmsg)
        strncpy ((char *) p + 4, targetsec->output_section->name, 8);
     }
 
-  if (isymbuf != NULL && symtab_hdr->contents != (unsigned char *) isymbuf)
+  if (symtab_hdr->contents != (unsigned char *) isymbuf)
     free (isymbuf);
-  if (internal_relocs != NULL
-      && elf_section_data (datasec)->relocs != internal_relocs)
+  if (elf_section_data (datasec)->relocs != internal_relocs)
     free (internal_relocs);
-  return TRUE;
+  return true;
 
-error_return:
-  if (isymbuf != NULL && symtab_hdr->contents != (unsigned char *) isymbuf)
+ error_return:
+  if (symtab_hdr->contents != (unsigned char *) isymbuf)
     free (isymbuf);
-  if (internal_relocs != NULL
-      && elf_section_data (datasec)->relocs != internal_relocs)
+  if (elf_section_data (datasec)->relocs != internal_relocs)
     free (internal_relocs);
-  return FALSE;
+  return false;
 }
 
 /* Set target options.  */
@@ -4747,40 +4486,51 @@ void
 bfd_elf_m68k_set_target_options (struct bfd_link_info *info, int got_handling)
 {
   struct elf_m68k_link_hash_table *htab;
-
-  htab = elf_m68k_hash_table (info);
+  bool use_neg_got_offsets_p;
+  bool allow_multigot_p;
+  bool local_gp_p;
 
   switch (got_handling)
     {
     case 0:
       /* --got=single.  */
-      htab->local_gp_p = FALSE;
-      htab->use_neg_got_offsets_p = FALSE;
-      htab->allow_multigot_p = FALSE;
+      local_gp_p = false;
+      use_neg_got_offsets_p = false;
+      allow_multigot_p = false;
       break;
 
     case 1:
       /* --got=negative.  */
-      htab->local_gp_p = TRUE;
-      htab->use_neg_got_offsets_p = TRUE;
-      htab->allow_multigot_p = FALSE;
+      local_gp_p = true;
+      use_neg_got_offsets_p = true;
+      allow_multigot_p = false;
       break;
 
     case 2:
       /* --got=multigot.  */
-      htab->local_gp_p = TRUE;
-      htab->use_neg_got_offsets_p = TRUE;
-      htab->allow_multigot_p = TRUE;
+      local_gp_p = true;
+      use_neg_got_offsets_p = true;
+      allow_multigot_p = true;
       break;
 
     default:
-      BFD_ASSERT (FALSE);
+      BFD_ASSERT (false);
+      return;
+    }
+
+  htab = elf_m68k_hash_table (info);
+  if (htab != NULL)
+    {
+      htab->local_gp_p = local_gp_p;
+      htab->use_neg_got_offsets_p = use_neg_got_offsets_p;
+      htab->allow_multigot_p = allow_multigot_p;
     }
 }
 
 static enum elf_reloc_type_class
-elf32_m68k_reloc_type_class (rela)
-     const Elf_Internal_Rela *rela;
+elf32_m68k_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSED,
+                            const asection *rel_sec ATTRIBUTE_UNUSED,
+                            const Elf_Internal_Rela *rela)
 {
   switch ((int) ELF32_R_TYPE (rela->r_info))
     {
@@ -4805,7 +4555,70 @@ elf_m68k_plt_sym_val (bfd_vma i, const asection *plt,
   return plt->vma + (i + 1) * elf_m68k_get_plt_info (plt->owner)->size;
 }
 
-#define TARGET_BIG_SYM                 bfd_elf32_m68k_vec
+/* Support for core dump NOTE sections.  */
+
+static bool
+elf_m68k_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
+{
+  int offset;
+  size_t size;
+
+  switch (note->descsz)
+    {
+    default:
+      return false;
+
+    case 154:          /* Linux/m68k */
+      /* pr_cursig */
+      elf_tdata (abfd)->core->signal = bfd_get_16 (abfd, note->descdata + 12);
+
+      /* pr_pid */
+      elf_tdata (abfd)->core->lwpid = bfd_get_32 (abfd, note->descdata + 22);
+
+      /* pr_reg */
+      offset = 70;
+      size = 80;
+
+      break;
+    }
+
+  /* Make a ".reg/999" section.  */
+  return _bfd_elfcore_make_pseudosection (abfd, ".reg",
+                                         size, note->descpos + offset);
+}
+
+static bool
+elf_m68k_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
+{
+  switch (note->descsz)
+    {
+    default:
+      return false;
+
+    case 124:          /* Linux/m68k elf_prpsinfo.  */
+      elf_tdata (abfd)->core->pid
+       = bfd_get_32 (abfd, note->descdata + 12);
+      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 (n > 0 && command[n - 1] == ' ')
+      command[n - 1] = '\0';
+  }
+
+  return true;
+}
+
+#define TARGET_BIG_SYM                 m68k_elf32_vec
 #define TARGET_BIG_NAME                        "elf32-m68k"
 #define ELF_MACHINE_CODE               EM_68K
 #define ELF_MAXPAGESIZE                        0x2000
@@ -4813,18 +4626,14 @@ elf_m68k_plt_sym_val (bfd_vma i, const asection *plt,
                                        _bfd_elf_create_dynamic_sections
 #define bfd_elf32_bfd_link_hash_table_create \
                                        elf_m68k_link_hash_table_create
-/* ??? Should it be this macro or bfd_elfNN_bfd_link_hash_table_create?  */
-#define bfd_elf32_bfd_link_hash_table_free \
-                                       elf_m68k_link_hash_table_free
 #define bfd_elf32_bfd_final_link       bfd_elf_final_link
 
 #define elf_backend_check_relocs       elf_m68k_check_relocs
-#define elf_backend_always_size_sections \
-                                       elf_m68k_always_size_sections
+#define elf_backend_early_size_sections \
+                                       elf_m68k_early_size_sections
 #define elf_backend_adjust_dynamic_symbol \
                                        elf_m68k_adjust_dynamic_symbol
-#define elf_backend_size_dynamic_sections \
-                                       elf_m68k_size_dynamic_sections
+#define elf_backend_late_size_sections elf_m68k_late_size_sections
 #define elf_backend_final_write_processing     elf_m68k_final_write_processing
 #define elf_backend_init_index_section _bfd_elf_init_1_index_section
 #define elf_backend_relocate_section   elf_m68k_relocate_section
@@ -4833,17 +4642,18 @@ elf_m68k_plt_sym_val (bfd_vma i, const asection *plt,
 #define elf_backend_finish_dynamic_sections \
                                        elf_m68k_finish_dynamic_sections
 #define elf_backend_gc_mark_hook       elf_m68k_gc_mark_hook
-#define elf_backend_gc_sweep_hook      elf_m68k_gc_sweep_hook
 #define elf_backend_copy_indirect_symbol elf_m68k_copy_indirect_symbol
 #define bfd_elf32_bfd_merge_private_bfd_data \
-                                        elf32_m68k_merge_private_bfd_data
+                                       elf32_m68k_merge_private_bfd_data
 #define bfd_elf32_bfd_set_private_flags \
-                                        elf32_m68k_set_private_flags
+                                       elf32_m68k_set_private_flags
 #define bfd_elf32_bfd_print_private_bfd_data \
-                                        elf32_m68k_print_private_bfd_data
+                                       elf32_m68k_print_private_bfd_data
 #define elf_backend_reloc_type_class   elf32_m68k_reloc_type_class
 #define elf_backend_plt_sym_val                elf_m68k_plt_sym_val
 #define elf_backend_object_p           elf32_m68k_object_p
+#define elf_backend_grok_prstatus      elf_m68k_grok_prstatus
+#define elf_backend_grok_psinfo                elf_m68k_grok_psinfo
 
 #define elf_backend_can_gc_sections 1
 #define elf_backend_can_refcount 1
@@ -4852,5 +4662,8 @@ elf_m68k_plt_sym_val (bfd_vma i, const asection *plt,
 #define elf_backend_want_plt_sym 0
 #define elf_backend_got_header_size    12
 #define elf_backend_rela_normal                1
+#define elf_backend_dtrel_excludes_plt 1
+
+#define elf_backend_linux_prpsinfo32_ugid16    true
 
 #include "elf32-target.h"