Correct spelling of "relocatable".
[deliverable/binutils-gdb.git] / bfd / elf32-sh.c
index 703ac4016be3e51e80669edb1eab67b0ca544372..af8dd6718a65c70358b6c2546e928ac24055f89d 100644 (file)
@@ -1,23 +1,23 @@
-/* Hitachi SH specific support for 32-bit ELF
-   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002
+/* Renesas / SuperH SH specific support for 32-bit ELF
+   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
    Free Software Foundation, Inc.
    Contributed by Ian Lance Taylor, Cygnus Support.
 
-This file is part of BFD, the Binary File Descriptor library.
+   This file is part of BFD, the Binary File Descriptor library.
 
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
 
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
 
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
 #include "bfd.h"
 #include "sysdep.h"
@@ -34,69 +34,83 @@ static reloc_howto_type *sh_elf_reloc_type_lookup
   PARAMS ((bfd *, bfd_reloc_code_real_type));
 static void sh_elf_info_to_howto
   PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
-static boolean sh_elf_set_private_flags
+static bfd_boolean sh_elf_set_private_flags
   PARAMS ((bfd *, flagword));
-static boolean sh_elf_copy_private_data
+static bfd_boolean sh_elf_copy_private_data
   PARAMS ((bfd *, bfd *));
-static boolean sh_elf_merge_private_data
+static bfd_boolean sh_elf_merge_private_data
   PARAMS ((bfd *, bfd *));
-static boolean sh_elf_set_mach_from_flags
+static bfd_boolean sh_elf_set_mach_from_flags
   PARAMS ((bfd *));
-static boolean sh_elf_relax_section
-  PARAMS ((bfd *, asection *, struct bfd_link_info *, boolean *));
-static boolean sh_elf_relax_delete_bytes
+static bfd_boolean sh_elf_relax_section
+  PARAMS ((bfd *, asection *, struct bfd_link_info *, bfd_boolean *));
+static bfd_boolean sh_elf_relax_delete_bytes
   PARAMS ((bfd *, asection *, bfd_vma, int));
-static boolean sh_elf_align_loads
-  PARAMS ((bfd *, asection *, Elf_Internal_Rela *, bfd_byte *, boolean *));
-static boolean sh_elf_swap_insns
+static bfd_boolean sh_elf_align_loads
+  PARAMS ((bfd *, asection *, Elf_Internal_Rela *, bfd_byte *, bfd_boolean *));
+static bfd_boolean sh_elf_swap_insns
   PARAMS ((bfd *, asection *, PTR, bfd_byte *, bfd_vma));
-static boolean sh_elf_relocate_section
+static bfd_boolean sh_elf_relocate_section
   PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
           Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
 static bfd_byte *sh_elf_get_relocated_section_contents
   PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *,
-          bfd_byte *, boolean, asymbol **));
+          bfd_byte *, bfd_boolean, asymbol **));
 static void sh_elf_copy_indirect_symbol
   PARAMS ((struct elf_backend_data *, struct elf_link_hash_entry *,
           struct elf_link_hash_entry *));
-static boolean sh_elf_check_relocs
+static int sh_elf_optimized_tls_reloc
+  PARAMS ((struct bfd_link_info *, int, int));
+static bfd_boolean sh_elf_mkobject
+  PARAMS ((bfd *));
+static bfd_boolean sh_elf_object_p
+  PARAMS ((bfd *));
+static bfd_boolean sh_elf_check_relocs
   PARAMS ((bfd *, struct bfd_link_info *, asection *,
           const Elf_Internal_Rela *));
 static struct bfd_hash_entry *sh_elf_link_hash_newfunc
   PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
 static struct bfd_link_hash_table *sh_elf_link_hash_table_create
   PARAMS ((bfd *));
-static boolean sh_elf_adjust_dynamic_symbol
+static bfd_boolean sh_elf_adjust_dynamic_symbol
   PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
-static boolean sh_elf_size_dynamic_sections
+static bfd_boolean sh_elf_size_dynamic_sections
   PARAMS ((bfd *, struct bfd_link_info *));
-static boolean sh_elf_finish_dynamic_symbol
+static bfd_boolean sh_elf_finish_dynamic_symbol
   PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *,
           Elf_Internal_Sym *));
-static boolean sh_elf_finish_dynamic_sections
+static bfd_boolean sh_elf_finish_dynamic_sections
   PARAMS ((bfd *, struct bfd_link_info *));
 static bfd_reloc_status_type sh_elf_reloc_loop
   PARAMS ((int, bfd *, asection *, bfd_byte *, bfd_vma, asection *,
           bfd_vma, bfd_vma));
-static boolean create_got_section
-  PARAMS((bfd *, struct bfd_link_info *));
-static boolean sh_elf_create_dynamic_sections
+static bfd_boolean create_got_section
   PARAMS ((bfd *, struct bfd_link_info *));
+static bfd_boolean sh_elf_create_dynamic_sections
+  PARAMS ((bfd *, struct bfd_link_info *));
+static bfd_vma dtpoff_base
+  PARAMS ((struct bfd_link_info *));
+static bfd_vma tpoff
+  PARAMS ((struct bfd_link_info *, bfd_vma));
 static asection * sh_elf_gc_mark_hook
   PARAMS ((asection *, struct bfd_link_info *, Elf_Internal_Rela *,
           struct elf_link_hash_entry *, Elf_Internal_Sym *));
-static boolean sh_elf_gc_sweep_hook
+static bfd_boolean sh_elf_gc_sweep_hook
   PARAMS ((bfd *, struct bfd_link_info *, asection *,
           const Elf_Internal_Rela *));
-static boolean allocate_dynrelocs
+static bfd_boolean allocate_dynrelocs
   PARAMS ((struct elf_link_hash_entry *, PTR));
-static boolean readonly_dynrelocs
+static bfd_boolean readonly_dynrelocs
   PARAMS ((struct elf_link_hash_entry *, PTR));
 static enum elf_reloc_type_class sh_elf_reloc_type_class
   PARAMS ((const Elf_Internal_Rela *));
 #ifdef INCLUDE_SHMEDIA
 inline static void movi_shori_putval PARAMS ((bfd *, unsigned long, char *));
 #endif
+static bfd_boolean elf32_shlin_grok_prstatus
+  PARAMS ((bfd *abfd, Elf_Internal_Note *note));
+static bfd_boolean elf32_shlin_grok_psinfo
+  PARAMS ((bfd *abfd, Elf_Internal_Note *note));
 
 /* The name of the dynamic interpreter.  This is put in the .interp
    section.  */
@@ -110,106 +124,108 @@ static reloc_howto_type sh_elf_howto_table[] =
         0,                     /* rightshift */
         0,                     /* size (0 = byte, 1 = short, 2 = long) */
         0,                     /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_dont, /* complain_on_overflow */
         sh_elf_ignore_reloc,   /* special_function */
         "R_SH_NONE",           /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0,                     /* dst_mask */
-        false),                /* pcrel_offset */
+        FALSE),                /* pcrel_offset */
 
-  /* 32 bit absolute relocation.  Setting partial_inplace to true and
+  /* 32 bit absolute relocation.  Setting partial_inplace to TRUE and
      src_mask to a non-zero value is similar to the COFF toolchain.  */
   HOWTO (R_SH_DIR32,           /* type */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         32,                    /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_bitfield, /* complain_on_overflow */
         sh_elf_reloc,          /* special_function */
         "R_SH_DIR32",          /* name */
-        true,                  /* partial_inplace */
+        TRUE,                  /* partial_inplace */
         0xffffffff,            /* src_mask */
         0xffffffff,            /* dst_mask */
-        false),                /* pcrel_offset */
+        FALSE),                /* pcrel_offset */
 
   /* 32 bit PC relative relocation.  */
   HOWTO (R_SH_REL32,           /* type */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         32,                    /* bitsize */
-        true,                  /* pc_relative */
+        TRUE,                  /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_signed, /* complain_on_overflow */
         sh_elf_ignore_reloc,   /* special_function */
         "R_SH_REL32",          /* name */
-        true,                  /* partial_inplace */
+        TRUE,                  /* partial_inplace */
         0xffffffff,            /* src_mask */
         0xffffffff,            /* dst_mask */
-        true),                 /* pcrel_offset */
+        TRUE),                 /* pcrel_offset */
 
   /* 8 bit PC relative branch divided by 2.  */
   HOWTO (R_SH_DIR8WPN,         /* type */
         1,                     /* rightshift */
         1,                     /* size (0 = byte, 1 = short, 2 = long) */
         8,                     /* bitsize */
-        true,                  /* pc_relative */
+        TRUE,                  /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_signed, /* complain_on_overflow */
         sh_elf_ignore_reloc,   /* special_function */
         "R_SH_DIR8WPN",        /* name */
-        true,                  /* partial_inplace */
+        TRUE,                  /* partial_inplace */
         0xff,                  /* src_mask */
         0xff,                  /* dst_mask */
-        true),                 /* pcrel_offset */
+        TRUE),                 /* pcrel_offset */
 
   /* 12 bit PC relative branch divided by 2.  */
+  /* This cannot be partial_inplace because relaxation can't know the
+     eventual value of a symbol.  */
   HOWTO (R_SH_IND12W,          /* type */
         1,                     /* rightshift */
         1,                     /* size (0 = byte, 1 = short, 2 = long) */
         12,                    /* bitsize */
-        true,                  /* pc_relative */
+        TRUE,                  /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_signed, /* complain_on_overflow */
-        sh_elf_reloc,          /* special_function */
+        NULL,                  /* special_function */
         "R_SH_IND12W",         /* name */
-        true,                  /* partial_inplace */
-        0xfff,                 /* src_mask */
+        FALSE,                 /* partial_inplace */
+        0x0,                   /* src_mask */
         0xfff,                 /* dst_mask */
-        true),                 /* pcrel_offset */
+        TRUE),                 /* pcrel_offset */
 
   /* 8 bit unsigned PC relative divided by 4.  */
   HOWTO (R_SH_DIR8WPL,         /* type */
         2,                     /* rightshift */
         1,                     /* size (0 = byte, 1 = short, 2 = long) */
         8,                     /* bitsize */
-        true,                  /* pc_relative */
+        TRUE,                  /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_unsigned, /* complain_on_overflow */
         sh_elf_ignore_reloc,   /* special_function */
         "R_SH_DIR8WPL",        /* name */
-        true,                  /* partial_inplace */
+        TRUE,                  /* partial_inplace */
         0xff,                  /* src_mask */
         0xff,                  /* dst_mask */
-        true),                 /* pcrel_offset */
+        TRUE),                 /* pcrel_offset */
 
   /* 8 bit unsigned PC relative divided by 2.  */
   HOWTO (R_SH_DIR8WPZ,         /* type */
         1,                     /* rightshift */
         1,                     /* size (0 = byte, 1 = short, 2 = long) */
         8,                     /* bitsize */
-        true,                  /* pc_relative */
+        TRUE,                  /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_unsigned, /* complain_on_overflow */
         sh_elf_ignore_reloc,   /* special_function */
         "R_SH_DIR8WPZ",        /* name */
-        true,                  /* partial_inplace */
+        TRUE,                  /* partial_inplace */
         0xff,                  /* src_mask */
         0xff,                  /* dst_mask */
-        true),                 /* pcrel_offset */
+        TRUE),                 /* pcrel_offset */
 
   /* 8 bit GBR relative.  FIXME: This only makes sense if we have some
      special symbol for the GBR relative area, and that is not
@@ -218,15 +234,15 @@ static reloc_howto_type sh_elf_howto_table[] =
         0,                     /* rightshift */
         1,                     /* size (0 = byte, 1 = short, 2 = long) */
         8,                     /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_unsigned, /* complain_on_overflow */
         sh_elf_ignore_reloc,   /* special_function */
         "R_SH_DIR8BP",         /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0xff,                  /* dst_mask */
-        true),                 /* pcrel_offset */
+        TRUE),                 /* pcrel_offset */
 
   /* 8 bit GBR relative divided by 2.  FIXME: This only makes sense if
      we have some special symbol for the GBR relative area, and that
@@ -235,15 +251,15 @@ static reloc_howto_type sh_elf_howto_table[] =
         1,                     /* rightshift */
         1,                     /* size (0 = byte, 1 = short, 2 = long) */
         8,                     /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_unsigned, /* complain_on_overflow */
         sh_elf_ignore_reloc,   /* special_function */
         "R_SH_DIR8W",          /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0xff,                  /* dst_mask */
-        true),                 /* pcrel_offset */
+        TRUE),                 /* pcrel_offset */
 
   /* 8 bit GBR relative divided by 4.  FIXME: This only makes sense if
      we have some special symbol for the GBR relative area, and that
@@ -252,15 +268,15 @@ static reloc_howto_type sh_elf_howto_table[] =
         2,                     /* rightshift */
         1,                     /* size (0 = byte, 1 = short, 2 = long) */
         8,                     /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_unsigned, /* complain_on_overflow */
         sh_elf_ignore_reloc,   /* special_function */
         "R_SH_DIR8L",          /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0xff,                  /* dst_mask */
-        true),                 /* pcrel_offset */
+        TRUE),                 /* pcrel_offset */
 
   EMPTY_HOWTO (10),
   EMPTY_HOWTO (11),
@@ -290,15 +306,15 @@ static reloc_howto_type sh_elf_howto_table[] =
         0,                     /* rightshift */
         1,                     /* size (0 = byte, 1 = short, 2 = long) */
         16,                    /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_unsigned, /* complain_on_overflow */
         sh_elf_ignore_reloc,   /* special_function */
         "R_SH_SWITCH16",       /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0,                     /* dst_mask */
-        true),                 /* pcrel_offset */
+        TRUE),                 /* pcrel_offset */
 
   /* A 32 bit switch table entry.  This is generated for an expression
      such as ``.long L1 - L2''.  The offset holds the difference
@@ -307,15 +323,15 @@ static reloc_howto_type sh_elf_howto_table[] =
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         32,                    /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_unsigned, /* complain_on_overflow */
         sh_elf_ignore_reloc,   /* special_function */
         "R_SH_SWITCH32",       /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0,                     /* dst_mask */
-        true),                 /* pcrel_offset */
+        TRUE),                 /* pcrel_offset */
 
   /* Indicates a .uses pseudo-op.  The compiler will generate .uses
      pseudo-ops when it finds a function call which can be relaxed.
@@ -325,15 +341,15 @@ static reloc_howto_type sh_elf_howto_table[] =
         0,                     /* rightshift */
         1,                     /* size (0 = byte, 1 = short, 2 = long) */
         0,                     /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_unsigned, /* complain_on_overflow */
         sh_elf_ignore_reloc,   /* special_function */
         "R_SH_USES",           /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0,                     /* dst_mask */
-        true),                 /* pcrel_offset */
+        TRUE),                 /* pcrel_offset */
 
   /* The assembler will generate this reloc for addresses referred to
      by the register loads associated with USES relocs.  The offset
@@ -343,15 +359,15 @@ static reloc_howto_type sh_elf_howto_table[] =
         0,                     /* rightshift */
         1,                     /* size (0 = byte, 1 = short, 2 = long) */
         0,                     /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_unsigned, /* complain_on_overflow */
         sh_elf_ignore_reloc,   /* special_function */
         "R_SH_COUNT",          /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0,                     /* dst_mask */
-        true),                 /* pcrel_offset */
+        TRUE),                 /* pcrel_offset */
 
   /* Indicates an alignment statement.  The offset field is the power
      of 2 to which subsequent portions of the object file must be
@@ -360,15 +376,15 @@ static reloc_howto_type sh_elf_howto_table[] =
         0,                     /* rightshift */
         1,                     /* size (0 = byte, 1 = short, 2 = long) */
         0,                     /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_unsigned, /* complain_on_overflow */
         sh_elf_ignore_reloc,   /* special_function */
         "R_SH_ALIGN",  /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0,                     /* dst_mask */
-        true),                 /* pcrel_offset */
+        TRUE),                 /* pcrel_offset */
 
   /* The assembler will generate this reloc before a block of
      instructions.  A section should be processed as assumining it
@@ -377,15 +393,15 @@ static reloc_howto_type sh_elf_howto_table[] =
         0,                     /* rightshift */
         1,                     /* size (0 = byte, 1 = short, 2 = long) */
         0,                     /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_unsigned, /* complain_on_overflow */
         sh_elf_ignore_reloc,   /* special_function */
         "R_SH_CODE",           /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0,                     /* dst_mask */
-        true),                 /* pcrel_offset */
+        TRUE),                 /* pcrel_offset */
 
   /* The assembler will generate this reloc after a block of
      instructions when it sees data that is not instructions.  */
@@ -393,15 +409,15 @@ static reloc_howto_type sh_elf_howto_table[] =
         0,                     /* rightshift */
         1,                     /* size (0 = byte, 1 = short, 2 = long) */
         0,                     /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_unsigned, /* complain_on_overflow */
         sh_elf_ignore_reloc,   /* special_function */
         "R_SH_DATA",           /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0,                     /* dst_mask */
-        true),                 /* pcrel_offset */
+        TRUE),                 /* pcrel_offset */
 
   /* The assembler generates this reloc for each label within a block
      of instructions.  This permits the linker to avoid swapping
@@ -410,15 +426,15 @@ static reloc_howto_type sh_elf_howto_table[] =
         0,                     /* rightshift */
         1,                     /* size (0 = byte, 1 = short, 2 = long) */
         0,                     /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_unsigned, /* complain_on_overflow */
         sh_elf_ignore_reloc,   /* special_function */
         "R_SH_LABEL",          /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0,                     /* dst_mask */
-        true),                 /* pcrel_offset */
+        TRUE),                 /* pcrel_offset */
 
   /* An 8 bit switch table entry.  This is generated for an expression
      such as ``.word L1 - L2''.  The offset holds the difference
@@ -427,75 +443,75 @@ static reloc_howto_type sh_elf_howto_table[] =
         0,                     /* rightshift */
         0,                     /* size (0 = byte, 1 = short, 2 = long) */
         8,                     /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_unsigned, /* complain_on_overflow */
         sh_elf_ignore_reloc,   /* special_function */
         "R_SH_SWITCH8",        /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0,                     /* dst_mask */
-        true),                 /* pcrel_offset */
+        TRUE),                 /* pcrel_offset */
 
   /* GNU extension to record C++ vtable hierarchy */
   HOWTO (R_SH_GNU_VTINHERIT, /* type */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         0,                     /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_dont, /* complain_on_overflow */
         NULL,                  /* special_function */
         "R_SH_GNU_VTINHERIT", /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0,                     /* dst_mask */
-        false),                /* pcrel_offset */
+        FALSE),                /* pcrel_offset */
 
   /* GNU extension to record C++ vtable member usage */
   HOWTO (R_SH_GNU_VTENTRY,     /* type */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         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_SH_GNU_VTENTRY",   /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0,                     /* dst_mask */
-        false),                /* pcrel_offset */
+        FALSE),                /* pcrel_offset */
 
   /* 8 bit PC relative divided by 2 - but specified in a very odd way.  */
   HOWTO (R_SH_LOOP_START,      /* type */
         1,                     /* rightshift */
         1,                     /* size (0 = byte, 1 = short, 2 = long) */
         8,                     /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_signed, /* complain_on_overflow */
         sh_elf_ignore_reloc,   /* special_function */
         "R_SH_LOOP_START",     /* name */
-        true,                  /* partial_inplace */
+        TRUE,                  /* partial_inplace */
         0xff,                  /* src_mask */
         0xff,                  /* dst_mask */
-        true),                 /* pcrel_offset */
+        TRUE),                 /* pcrel_offset */
 
   /* 8 bit PC relative divided by 2 - but specified in a very odd way.  */
   HOWTO (R_SH_LOOP_END,                /* type */
         1,                     /* rightshift */
         1,                     /* size (0 = byte, 1 = short, 2 = long) */
         8,                     /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_signed, /* complain_on_overflow */
         sh_elf_ignore_reloc,   /* special_function */
         "R_SH_LOOP_END",       /* name */
-        true,                  /* partial_inplace */
+        TRUE,                  /* partial_inplace */
         0xff,                  /* src_mask */
         0xff,                  /* dst_mask */
-        true),                 /* pcrel_offset */
+        TRUE),                 /* pcrel_offset */
 
   EMPTY_HOWTO (38),
   EMPTY_HOWTO (39),
@@ -511,105 +527,105 @@ static reloc_howto_type sh_elf_howto_table[] =
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         5,                     /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         10,                    /* bitpos */
         complain_overflow_unsigned, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_SH_DIR5U",          /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0xfc00,                /* dst_mask */
-        false),                /* pcrel_offset */
+        FALSE),                /* pcrel_offset */
 
   /* Used in SHARI, SHLLI et al.  */
   HOWTO (R_SH_DIR6U,           /* type */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         6,                     /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         10,                    /* bitpos */
         complain_overflow_unsigned, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_SH_DIR6U",          /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0xfc00,                /* dst_mask */
-        false),                /* pcrel_offset */
+        FALSE),                /* pcrel_offset */
 
   /* Used in BxxI, LDHI.L et al.  */
   HOWTO (R_SH_DIR6S,           /* type */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         6,                     /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         10,                    /* bitpos */
         complain_overflow_signed, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_SH_DIR6S",          /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0xfc00,                /* dst_mask */
-        false),                /* pcrel_offset */
+        FALSE),                /* pcrel_offset */
 
   /* Used in ADDI, ANDI et al.  */
   HOWTO (R_SH_DIR10S,          /* type */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         10,                    /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         10,                    /* bitpos */
         complain_overflow_signed, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_SH_DIR10S",         /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0xffc00,               /* dst_mask */
-        false),                /* pcrel_offset */
+        FALSE),                /* pcrel_offset */
 
   /* Used in LD.UW, ST.W et al.         */
   HOWTO (R_SH_DIR10SW, /* type */
         1,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         11,                    /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         10,                    /* bitpos */
         complain_overflow_signed, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_SH_DIR10SW",        /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0xffc00,               /* dst_mask */
-        false),                /* pcrel_offset */
+        FALSE),                /* pcrel_offset */
 
   /* Used in LD.L, FLD.S et al.         */
   HOWTO (R_SH_DIR10SL, /* type */
         2,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         12,                    /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         10,                    /* bitpos */
         complain_overflow_signed, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_SH_DIR10SL",        /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0xffc00,               /* dst_mask */
-        false),                /* pcrel_offset */
+        FALSE),                /* pcrel_offset */
 
   /* Used in FLD.D, FST.P et al.  */
   HOWTO (R_SH_DIR10SQ, /* type */
         3,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         13,                    /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         10,                    /* bitpos */
         complain_overflow_signed, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_SH_DIR10SQ",        /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0xffc00,               /* dst_mask */
-        false),                /* pcrel_offset */
+        FALSE),                /* pcrel_offset */
 
 #else
   EMPTY_HOWTO (45),
@@ -713,14 +729,119 @@ static reloc_howto_type sh_elf_howto_table[] =
   EMPTY_HOWTO (141),
   EMPTY_HOWTO (142),
   EMPTY_HOWTO (143),
-  EMPTY_HOWTO (144),
-  EMPTY_HOWTO (145),
-  EMPTY_HOWTO (146),
-  EMPTY_HOWTO (147),
-  EMPTY_HOWTO (148),
-  EMPTY_HOWTO (149),
-  EMPTY_HOWTO (150),
-  EMPTY_HOWTO (151),
+
+  HOWTO (R_SH_TLS_GD_32,       /* type */
+        0,                     /* rightshift */
+        2,                     /* size (0 = byte, 1 = short, 2 = long) */
+        32,                    /* bitsize */
+        FALSE,                 /* pc_relative */
+        0,                     /* bitpos */
+        complain_overflow_bitfield, /* complain_on_overflow */
+        bfd_elf_generic_reloc, /* */
+        "R_SH_TLS_GD_32",      /* name */
+        TRUE,                  /* partial_inplace */
+        0xffffffff,            /* src_mask */
+        0xffffffff,            /* dst_mask */
+        FALSE),                /* pcrel_offset */
+
+  HOWTO (R_SH_TLS_LD_32,       /* type */
+        0,                     /* rightshift */
+        2,                     /* size (0 = byte, 1 = short, 2 = long) */
+        32,                    /* bitsize */
+        FALSE,                 /* pc_relative */
+        0,                     /* bitpos */
+        complain_overflow_bitfield, /* complain_on_overflow */
+        bfd_elf_generic_reloc, /* */
+        "R_SH_TLS_LD_32",      /* name */
+        TRUE,                  /* partial_inplace */
+        0xffffffff,            /* src_mask */
+        0xffffffff,            /* dst_mask */
+        FALSE),                /* pcrel_offset */
+
+  HOWTO (R_SH_TLS_LDO_32,      /* type */
+        0,                     /* rightshift */
+        2,                     /* size (0 = byte, 1 = short, 2 = long) */
+        32,                    /* bitsize */
+        FALSE,                 /* pc_relative */
+        0,                     /* bitpos */
+        complain_overflow_bitfield, /* complain_on_overflow */
+        bfd_elf_generic_reloc, /* */
+        "R_SH_TLS_LDO_32",     /* name */
+        TRUE,                  /* partial_inplace */
+        0xffffffff,            /* src_mask */
+        0xffffffff,            /* dst_mask */
+        FALSE),                /* pcrel_offset */
+
+  HOWTO (R_SH_TLS_IE_32,       /* type */
+        0,                     /* rightshift */
+        2,                     /* size (0 = byte, 1 = short, 2 = long) */
+        32,                    /* bitsize */
+        FALSE,                 /* pc_relative */
+        0,                     /* bitpos */
+        complain_overflow_bitfield, /* complain_on_overflow */
+        bfd_elf_generic_reloc, /* */
+        "R_SH_TLS_IE_32",      /* name */
+        TRUE,                  /* partial_inplace */
+        0xffffffff,            /* src_mask */
+        0xffffffff,            /* dst_mask */
+        FALSE),                /* pcrel_offset */
+
+  HOWTO (R_SH_TLS_LE_32,       /* type */
+        0,                     /* rightshift */
+        2,                     /* size (0 = byte, 1 = short, 2 = long) */
+        32,                    /* bitsize */
+        FALSE,                 /* pc_relative */
+        0,                     /* bitpos */
+        complain_overflow_bitfield, /* complain_on_overflow */
+        bfd_elf_generic_reloc, /* */
+        "R_SH_TLS_LE_32",      /* name */
+        TRUE,                  /* partial_inplace */
+        0xffffffff,            /* src_mask */
+        0xffffffff,            /* dst_mask */
+        FALSE),                /* pcrel_offset */
+
+  HOWTO (R_SH_TLS_DTPMOD32,    /* type */
+        0,                     /* rightshift */
+        2,                     /* size (0 = byte, 1 = short, 2 = long) */
+        32,                    /* bitsize */
+        FALSE,                 /* pc_relative */
+        0,                     /* bitpos */
+        complain_overflow_bitfield, /* complain_on_overflow */
+        bfd_elf_generic_reloc, /* */
+        "R_SH_TLS_DTPMOD32",   /* name */
+        TRUE,                  /* partial_inplace */
+        0xffffffff,            /* src_mask */
+        0xffffffff,            /* dst_mask */
+        FALSE),                /* pcrel_offset */
+
+  HOWTO (R_SH_TLS_DTPOFF32,    /* type */
+        0,                     /* rightshift */
+        2,                     /* size (0 = byte, 1 = short, 2 = long) */
+        32,                    /* bitsize */
+        FALSE,                 /* pc_relative */
+        0,                     /* bitpos */
+        complain_overflow_bitfield, /* complain_on_overflow */
+        bfd_elf_generic_reloc, /* */
+        "R_SH_TLS_DTPOFF32",   /* name */
+        TRUE,                  /* partial_inplace */
+        0xffffffff,            /* src_mask */
+        0xffffffff,            /* dst_mask */
+        FALSE),                /* pcrel_offset */
+
+  HOWTO (R_SH_TLS_TPOFF32,     /* type */
+        0,                     /* rightshift */
+        2,                     /* size (0 = byte, 1 = short, 2 = long) */
+        32,                    /* bitsize */
+        FALSE,                 /* pc_relative */
+        0,                     /* bitpos */
+        complain_overflow_bitfield, /* complain_on_overflow */
+        bfd_elf_generic_reloc, /* */
+        "R_SH_TLS_TPOFF32",    /* name */
+        TRUE,                  /* partial_inplace */
+        0xffffffff,            /* src_mask */
+        0xffffffff,            /* dst_mask */
+        FALSE),                /* pcrel_offset */
+
   EMPTY_HOWTO (152),
   EMPTY_HOWTO (153),
   EMPTY_HOWTO (154),
@@ -734,127 +855,127 @@ static reloc_howto_type sh_elf_howto_table[] =
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         32,                    /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_bitfield, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* */
         "R_SH_GOT32",          /* name */
-        true,                  /* partial_inplace */
+        TRUE,                  /* partial_inplace */
         0xffffffff,            /* src_mask */
         0xffffffff,            /* dst_mask */
-        false),                /* pcrel_offset */
+        FALSE),                /* pcrel_offset */
 
   HOWTO (R_SH_PLT32,           /* type */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         32,                    /* bitsize */
-        true,                  /* pc_relative */
+        TRUE,                  /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_bitfield, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* */
         "R_SH_PLT32",          /* name */
-        true,                  /* partial_inplace */
+        TRUE,                  /* partial_inplace */
         0xffffffff,            /* src_mask */
         0xffffffff,            /* dst_mask */
-        true),                 /* pcrel_offset */
+        TRUE),                 /* pcrel_offset */
 
   HOWTO (R_SH_COPY,            /* type */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         32,                    /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_bitfield, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* */
         "R_SH_COPY",           /* name */
-        true,                  /* partial_inplace */
+        TRUE,                  /* partial_inplace */
         0xffffffff,            /* src_mask */
         0xffffffff,            /* dst_mask */
-        false),                /* pcrel_offset */
+        FALSE),                /* pcrel_offset */
 
   HOWTO (R_SH_GLOB_DAT,                /* type */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         32,                    /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_bitfield, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* */
         "R_SH_GLOB_DAT",       /* name */
-        true,                  /* partial_inplace */
+        TRUE,                  /* partial_inplace */
         0xffffffff,            /* src_mask */
         0xffffffff,            /* dst_mask */
-        false),                /* pcrel_offset */
+        FALSE),                /* pcrel_offset */
 
   HOWTO (R_SH_JMP_SLOT,                /* type */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         32,                    /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_bitfield, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* */
         "R_SH_JMP_SLOT",       /* name */
-        true,                  /* partial_inplace */
+        TRUE,                  /* partial_inplace */
         0xffffffff,            /* src_mask */
         0xffffffff,            /* dst_mask */
-        false),                /* pcrel_offset */
+        FALSE),                /* pcrel_offset */
 
   HOWTO (R_SH_RELATIVE,                /* type */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         32,                    /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_bitfield, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* */
         "R_SH_RELATIVE",       /* name */
-        true,                  /* partial_inplace */
+        TRUE,                  /* partial_inplace */
         0xffffffff,            /* src_mask */
         0xffffffff,            /* dst_mask */
-        false),                /* pcrel_offset */
+        FALSE),                /* pcrel_offset */
 
   HOWTO (R_SH_GOTOFF,          /* type */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         32,                    /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_bitfield, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* */
         "R_SH_GOTOFF",         /* name */
-        true,                  /* partial_inplace */
+        TRUE,                  /* partial_inplace */
         0xffffffff,            /* src_mask */
         0xffffffff,            /* dst_mask */
-        false),                /* pcrel_offset */
+        FALSE),                /* pcrel_offset */
 
   HOWTO (R_SH_GOTPC,           /* type */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         32,                    /* bitsize */
-        true,                  /* pc_relative */
+        TRUE,                  /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_bitfield, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* */
         "R_SH_GOTPC",          /* name */
-        true,                  /* partial_inplace */
+        TRUE,                  /* partial_inplace */
         0xffffffff,            /* src_mask */
         0xffffffff,            /* dst_mask */
-        true),                 /* pcrel_offset */
+        TRUE),                 /* pcrel_offset */
 
   HOWTO (R_SH_GOTPLT32,                /* type */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         32,                    /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_bitfield, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* */
         "R_SH_GOTPLT32",       /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0xffffffff,            /* src_mask */
         0xffffffff,            /* dst_mask */
-        false),                /* pcrel_offset */
+        FALSE),                /* pcrel_offset */
 
 #ifdef INCLUDE_SHMEDIA
   /* Used in MOVI and SHORI (x & 65536).  */
@@ -862,416 +983,416 @@ static reloc_howto_type sh_elf_howto_table[] =
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         64,                    /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         10,                    /* bitpos */
         complain_overflow_dont, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_SH_GOT_LOW16",      /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0x3fffc00,             /* dst_mask */
-        false),                /* pcrel_offset */
+        FALSE),                /* pcrel_offset */
 
   /* Used in MOVI and SHORI ((x >> 16) & 65536).  */
   HOWTO (R_SH_GOT_MEDLOW16,    /* type */
         16,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         64,                    /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         10,                    /* bitpos */
         complain_overflow_dont, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_SH_GOT_MEDLOW16",   /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0x3fffc00,             /* dst_mask */
-        false),                /* pcrel_offset */
+        FALSE),                /* pcrel_offset */
 
   /* Used in MOVI and SHORI ((x >> 32) & 65536).  */
   HOWTO (R_SH_GOT_MEDHI16,     /* type */
         32,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         64,                    /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         10,                    /* bitpos */
         complain_overflow_dont, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_SH_GOT_MEDHI16",    /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0x3fffc00,             /* dst_mask */
-        false),                /* pcrel_offset */
+        FALSE),                /* pcrel_offset */
 
   /* Used in MOVI and SHORI ((x >> 48) & 65536).  */
   HOWTO (R_SH_GOT_HI16,                /* type */
         48,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         64,                    /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         10,                    /* bitpos */
         complain_overflow_dont, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_SH_GOT_HI16",       /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0x3fffc00,             /* dst_mask */
-        false),                /* pcrel_offset */
+        FALSE),                /* pcrel_offset */
 
   /* Used in MOVI and SHORI (x & 65536).  */
   HOWTO (R_SH_GOTPLT_LOW16,    /* type */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         64,                    /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         10,                    /* bitpos */
         complain_overflow_dont, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_SH_GOTPLT_LOW16",   /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0x3fffc00,             /* dst_mask */
-        false),                /* pcrel_offset */
+        FALSE),                /* pcrel_offset */
 
   /* Used in MOVI and SHORI ((x >> 16) & 65536).  */
   HOWTO (R_SH_GOTPLT_MEDLOW16, /* type */
         16,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         64,                    /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         10,                    /* bitpos */
         complain_overflow_dont, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_SH_GOTPLT_MEDLOW16", /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0x3fffc00,             /* dst_mask */
-        false),                /* pcrel_offset */
+        FALSE),                /* pcrel_offset */
 
   /* Used in MOVI and SHORI ((x >> 32) & 65536).  */
   HOWTO (R_SH_GOTPLT_MEDHI16,  /* type */
         32,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         64,                    /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         10,                    /* bitpos */
         complain_overflow_dont, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_SH_GOTPLT_MEDHI16", /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0x3fffc00,             /* dst_mask */
-        false),                /* pcrel_offset */
+        FALSE),                /* pcrel_offset */
 
   /* Used in MOVI and SHORI ((x >> 48) & 65536).  */
   HOWTO (R_SH_GOTPLT_HI16,     /* type */
         48,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         64,                    /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         10,                    /* bitpos */
         complain_overflow_dont, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_SH_GOTPLT_HI16",    /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0x3fffc00,             /* dst_mask */
-        false),                /* pcrel_offset */
+        FALSE),                /* pcrel_offset */
 
   /* Used in MOVI and SHORI (x & 65536).  */
   HOWTO (R_SH_PLT_LOW16,       /* type */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         64,                    /* bitsize */
-        true,                  /* pc_relative */
+        TRUE,                  /* pc_relative */
         10,                    /* bitpos */
         complain_overflow_dont, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_SH_PLT_LOW16",      /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0x3fffc00,             /* dst_mask */
-        true),                 /* pcrel_offset */
+        TRUE),                 /* pcrel_offset */
 
   /* Used in MOVI and SHORI ((x >> 16) & 65536).  */
   HOWTO (R_SH_PLT_MEDLOW16,    /* type */
         16,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         64,                    /* bitsize */
-        true,                  /* pc_relative */
+        TRUE,                  /* pc_relative */
         10,                    /* bitpos */
         complain_overflow_dont, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_SH_PLT_MEDLOW16",   /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0x3fffc00,             /* dst_mask */
-        true),                 /* pcrel_offset */
+        TRUE),                 /* pcrel_offset */
 
   /* Used in MOVI and SHORI ((x >> 32) & 65536).  */
   HOWTO (R_SH_PLT_MEDHI16,     /* type */
         32,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         64,                    /* bitsize */
-        true,                  /* pc_relative */
+        TRUE,                  /* pc_relative */
         10,                    /* bitpos */
         complain_overflow_dont, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_SH_PLT_MEDHI16",    /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0x3fffc00,             /* dst_mask */
-        true),                 /* pcrel_offset */
+        TRUE),                 /* pcrel_offset */
 
   /* Used in MOVI and SHORI ((x >> 48) & 65536).  */
   HOWTO (R_SH_PLT_HI16,                /* type */
         48,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         64,                    /* bitsize */
-        true,                  /* pc_relative */
+        TRUE,                  /* pc_relative */
         10,                    /* bitpos */
         complain_overflow_dont, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_SH_PLT_HI16",       /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0x3fffc00,             /* dst_mask */
-        true),                 /* pcrel_offset */
+        TRUE),                 /* pcrel_offset */
 
   /* Used in MOVI and SHORI (x & 65536).  */
   HOWTO (R_SH_GOTOFF_LOW16,    /* type */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         64,                    /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         10,                    /* bitpos */
         complain_overflow_dont, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_SH_GOTOFF_LOW16",   /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0x3fffc00,             /* dst_mask */
-        false),                /* pcrel_offset */
+        FALSE),                /* pcrel_offset */
 
   /* Used in MOVI and SHORI ((x >> 16) & 65536).  */
   HOWTO (R_SH_GOTOFF_MEDLOW16, /* type */
         16,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         64,                    /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         10,                    /* bitpos */
         complain_overflow_dont, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_SH_GOTOFF_MEDLOW16", /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0x3fffc00,             /* dst_mask */
-        false),                /* pcrel_offset */
+        FALSE),                /* pcrel_offset */
 
   /* Used in MOVI and SHORI ((x >> 32) & 65536).  */
   HOWTO (R_SH_GOTOFF_MEDHI16,  /* type */
         32,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         64,                    /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         10,                    /* bitpos */
         complain_overflow_dont, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_SH_GOTOFF_MEDHI16", /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0x3fffc00,             /* dst_mask */
-        false),                /* pcrel_offset */
+        FALSE),                /* pcrel_offset */
 
   /* Used in MOVI and SHORI ((x >> 48) & 65536).  */
   HOWTO (R_SH_GOTOFF_HI16,     /* type */
         48,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         64,                    /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         10,                    /* bitpos */
         complain_overflow_dont, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_SH_GOTOFF_HI16",    /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0x3fffc00,             /* dst_mask */
-        false),                /* pcrel_offset */
+        FALSE),                /* pcrel_offset */
 
   /* Used in MOVI and SHORI (x & 65536).  */
   HOWTO (R_SH_GOTPC_LOW16,     /* type */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         64,                    /* bitsize */
-        true,                  /* pc_relative */
+        TRUE,                  /* pc_relative */
         10,                    /* bitpos */
         complain_overflow_dont, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_SH_GOTPC_LOW16",    /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0x3fffc00,             /* dst_mask */
-        true),                 /* pcrel_offset */
+        TRUE),                 /* pcrel_offset */
 
   /* Used in MOVI and SHORI ((x >> 16) & 65536).  */
   HOWTO (R_SH_GOTPC_MEDLOW16,  /* type */
         16,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         64,                    /* bitsize */
-        true,                  /* pc_relative */
+        TRUE,                  /* pc_relative */
         10,                    /* bitpos */
         complain_overflow_dont, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_SH_GOTPC_MEDLOW16", /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0x3fffc00,             /* dst_mask */
-        true),                 /* pcrel_offset */
+        TRUE),                 /* pcrel_offset */
 
   /* Used in MOVI and SHORI ((x >> 32) & 65536).  */
   HOWTO (R_SH_GOTPC_MEDHI16,   /* type */
         32,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         64,                    /* bitsize */
-        true,                  /* pc_relative */
+        TRUE,                  /* pc_relative */
         10,                    /* bitpos */
         complain_overflow_dont, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_SH_GOTPC_MEDHI16",  /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0x3fffc00,             /* dst_mask */
-        true),                 /* pcrel_offset */
+        TRUE),                 /* pcrel_offset */
 
   /* Used in MOVI and SHORI ((x >> 48) & 65536).  */
   HOWTO (R_SH_GOTPC_HI16,      /* type */
         48,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         64,                    /* bitsize */
-        true,                  /* pc_relative */
+        TRUE,                  /* pc_relative */
         10,                    /* bitpos */
         complain_overflow_dont, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_SH_GOTPC_HI16",     /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0x3fffc00,             /* dst_mask */
-        true),                 /* pcrel_offset */
+        TRUE),                 /* pcrel_offset */
 
   /* Used in LD.L, FLD.S et al.         */
   HOWTO (R_SH_GOT10BY4,                /* type */
         2,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         12,                    /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         10,                    /* bitpos */
         complain_overflow_signed, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_SH_GOT10BY4",       /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0xffc00,               /* dst_mask */
-        false),                /* pcrel_offset */
+        FALSE),                /* pcrel_offset */
 
   /* Used in LD.L, FLD.S et al.         */
   HOWTO (R_SH_GOTPLT10BY4,     /* type */
         2,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         12,                    /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         10,                    /* bitpos */
         complain_overflow_signed, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_SH_GOTPLT10BY4",    /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0xffc00,               /* dst_mask */
-        false),                /* pcrel_offset */
+        FALSE),                /* pcrel_offset */
 
   /* Used in FLD.D, FST.P et al.  */
   HOWTO (R_SH_GOT10BY8,                /* type */
         3,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         13,                    /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         10,                    /* bitpos */
         complain_overflow_signed, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_SH_GOT10BY8",       /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0xffc00,               /* dst_mask */
-        false),                /* pcrel_offset */
+        FALSE),                /* pcrel_offset */
 
   /* Used in FLD.D, FST.P et al.  */
   HOWTO (R_SH_GOTPLT10BY8,     /* type */
         3,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         13,                    /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         10,                    /* bitpos */
         complain_overflow_signed, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_SH_GOTPLT10BY8",    /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0xffc00,               /* dst_mask */
-        false),                /* pcrel_offset */
+        FALSE),                /* pcrel_offset */
 
   HOWTO (R_SH_COPY64,          /* type */
         0,                     /* rightshift */
         4,                     /* size (0 = byte, 1 = short, 2 = long) */
         64,                    /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_dont, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_SH_COPY64",         /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         ((bfd_vma) 0) - 1,     /* dst_mask */
-        false),                /* pcrel_offset */
+        FALSE),                /* pcrel_offset */
 
   HOWTO (R_SH_GLOB_DAT64,      /* type */
         0,                     /* rightshift */
         4,                     /* size (0 = byte, 1 = short, 2 = long) */
         64,                    /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_dont, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_SH_GLOB_DAT64",     /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         ((bfd_vma) 0) - 1,     /* dst_mask */
-        false),                /* pcrel_offset */
+        FALSE),                /* pcrel_offset */
 
   HOWTO (R_SH_JMP_SLOT64,      /* type */
         0,                     /* rightshift */
         4,                     /* size (0 = byte, 1 = short, 2 = long) */
         64,                    /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_dont, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_SH_JMP_SLOT64",     /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         ((bfd_vma) 0) - 1,     /* dst_mask */
-        false),                /* pcrel_offset */
+        FALSE),                /* pcrel_offset */
 
   HOWTO (R_SH_RELATIVE64,      /* type */
         0,                     /* rightshift */
         4,                     /* size (0 = byte, 1 = short, 2 = long) */
         64,                    /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_dont, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_SH_RELATIVE64",     /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         ((bfd_vma) 0) - 1,     /* dst_mask */
-        false),                /* pcrel_offset */
+        FALSE),                /* pcrel_offset */
 
   EMPTY_HOWTO (197),
   EMPTY_HOWTO (198),
@@ -1332,15 +1453,15 @@ static reloc_howto_type sh_elf_howto_table[] =
         0,                     /* rightshift */
         1,                     /* size (0 = byte, 1 = short, 2 = long) */
         0,                     /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_unsigned, /* complain_on_overflow */
         sh_elf_ignore_reloc,   /* special_function */
         "R_SH_SHMEDIA_CODE",   /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0,                     /* dst_mask */
-        false),                /* pcrel_offset */
+        FALSE),                /* pcrel_offset */
 
   /* The assembler will generate this reloc at a PTA or PTB instruction,
      and the linker checks the right type of target, or changes a PTA to a
@@ -1349,195 +1470,195 @@ static reloc_howto_type sh_elf_howto_table[] =
         2,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         18,                    /* bitsize */
-        true,                  /* pc_relative */
+        TRUE,                  /* pc_relative */
         10,                    /* bitpos */
         complain_overflow_signed, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_SH_PT_16",          /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0x3fffc00,             /* dst_mask */
-        true),                 /* pcrel_offset */
+        TRUE),                 /* pcrel_offset */
 
   /* Used in unexpanded MOVI.  */
   HOWTO (R_SH_IMMS16,          /* type */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         16,                    /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         10,                    /* bitpos */
         complain_overflow_signed, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_SH_IMMS16",         /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0x3fffc00,             /* dst_mask */
-        false),                /* pcrel_offset */
+        FALSE),                /* pcrel_offset */
 
   /* Used in SHORI.  */
   HOWTO (R_SH_IMMU16,          /* type */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         16,                    /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         10,                    /* bitpos */
         complain_overflow_unsigned, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_SH_IMMU16",         /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0x3fffc00,             /* dst_mask */
-        false),                /* pcrel_offset */
+        FALSE),                /* pcrel_offset */
 
   /* Used in MOVI and SHORI (x & 65536).  */
   HOWTO (R_SH_IMM_LOW16,       /* type */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         64,                    /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         10,                    /* bitpos */
         complain_overflow_dont, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_SH_IMM_LOW16",      /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0x3fffc00,             /* dst_mask */
-        false),                /* pcrel_offset */
+        FALSE),                /* pcrel_offset */
 
   /* Used in MOVI and SHORI ((x - $) & 65536).  */
   HOWTO (R_SH_IMM_LOW16_PCREL, /* type */
         0,                     /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         64,                    /* bitsize */
-        true,                  /* pc_relative */
+        TRUE,                  /* pc_relative */
         10,                    /* bitpos */
         complain_overflow_dont, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_SH_IMM_LOW16_PCREL", /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0x3fffc00,             /* dst_mask */
-        true),                 /* pcrel_offset */
+        TRUE),                 /* pcrel_offset */
 
   /* Used in MOVI and SHORI ((x >> 16) & 65536).  */
   HOWTO (R_SH_IMM_MEDLOW16,    /* type */
         16,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         64,                    /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         10,                    /* bitpos */
         complain_overflow_dont, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_SH_IMM_MEDLOW16",   /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0x3fffc00,             /* dst_mask */
-        false),                /* pcrel_offset */
+        FALSE),                /* pcrel_offset */
 
   /* Used in MOVI and SHORI (((x - $) >> 16) & 65536).  */
   HOWTO (R_SH_IMM_MEDLOW16_PCREL, /* type */
         16,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         64,                    /* bitsize */
-        true,                  /* pc_relative */
+        TRUE,                  /* pc_relative */
         10,                    /* bitpos */
         complain_overflow_dont, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_SH_IMM_MEDLOW16_PCREL", /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0x3fffc00,             /* dst_mask */
-        true),                 /* pcrel_offset */
+        TRUE),                 /* pcrel_offset */
 
   /* Used in MOVI and SHORI ((x >> 32) & 65536).  */
   HOWTO (R_SH_IMM_MEDHI16,     /* type */
         32,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         64,                    /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         10,                    /* bitpos */
         complain_overflow_dont, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_SH_IMM_MEDHI16",    /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0x3fffc00,             /* dst_mask */
-        false),                /* pcrel_offset */
+        FALSE),                /* pcrel_offset */
 
   /* Used in MOVI and SHORI (((x - $) >> 32) & 65536).  */
   HOWTO (R_SH_IMM_MEDHI16_PCREL, /* type */
         32,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         64,                    /* bitsize */
-        true,                  /* pc_relative */
+        TRUE,                  /* pc_relative */
         10,                    /* bitpos */
         complain_overflow_dont, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_SH_IMM_MEDHI16_PCREL", /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0x3fffc00,             /* dst_mask */
-        true),                 /* pcrel_offset */
+        TRUE),                 /* pcrel_offset */
 
   /* Used in MOVI and SHORI ((x >> 48) & 65536).  */
   HOWTO (R_SH_IMM_HI16,                /* type */
         48,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         64,                    /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         10,                    /* bitpos */
         complain_overflow_dont, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_SH_IMM_HI16",       /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0x3fffc00,             /* dst_mask */
-        false),                /* pcrel_offset */
+        FALSE),                /* pcrel_offset */
 
   /* Used in MOVI and SHORI (((x - $) >> 48) & 65536).  */
   HOWTO (R_SH_IMM_HI16_PCREL,  /* type */
         48,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         64,                    /* bitsize */
-        true,                  /* pc_relative */
+        TRUE,                  /* pc_relative */
         10,                    /* bitpos */
         complain_overflow_dont, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_SH_IMM_HI16_PCREL", /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         0x3fffc00,             /* dst_mask */
-        true),                 /* pcrel_offset */
+        TRUE),                 /* pcrel_offset */
 
   /* For the .uaquad pseudo.  */
   HOWTO (R_SH_64,              /* type */
         0,                     /* rightshift */
         4,                     /* size (0 = byte, 1 = short, 2 = long) */
         64,                    /* bitsize */
-        false,                 /* pc_relative */
+        FALSE,                 /* pc_relative */
         0,                     /* bitpos */
         complain_overflow_dont, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_SH_64",             /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         ((bfd_vma) 0) - 1,     /* dst_mask */
-        false),                /* pcrel_offset */
+        FALSE),                /* pcrel_offset */
 
   /* For the .uaquad pseudo, (x - $).  */
   HOWTO (R_SH_64_PCREL,                /* type */
         48,                    /* rightshift */
         2,                     /* size (0 = byte, 1 = short, 2 = long) */
         64,                    /* bitsize */
-        true,                  /* pc_relative */
+        TRUE,                  /* pc_relative */
         10,                    /* bitpos */
         complain_overflow_dont, /* complain_on_overflow */
         bfd_elf_generic_reloc, /* special_function */
         "R_SH_64_PCREL",       /* name */
-        false,                 /* partial_inplace */
+        FALSE,                 /* partial_inplace */
         0,                     /* src_mask */
         ((bfd_vma) 0) - 1,     /* dst_mask */
-        true),                 /* pcrel_offset */
+        TRUE),                 /* pcrel_offset */
 
 #endif
 };
@@ -1776,6 +1897,14 @@ static const struct elf_reloc_map sh_reloc_map[] =
   { BFD_RELOC_VTABLE_ENTRY, R_SH_GNU_VTENTRY },
   { BFD_RELOC_SH_LOOP_START, R_SH_LOOP_START },
   { BFD_RELOC_SH_LOOP_END, R_SH_LOOP_END },
+  { BFD_RELOC_SH_TLS_GD_32, R_SH_TLS_GD_32 },
+  { BFD_RELOC_SH_TLS_LD_32, R_SH_TLS_LD_32 },
+  { BFD_RELOC_SH_TLS_LDO_32, R_SH_TLS_LDO_32 },
+  { BFD_RELOC_SH_TLS_IE_32, R_SH_TLS_IE_32 },
+  { BFD_RELOC_SH_TLS_LE_32, R_SH_TLS_LE_32 },
+  { BFD_RELOC_SH_TLS_DTPMOD32, R_SH_TLS_DTPMOD32 },
+  { BFD_RELOC_SH_TLS_DTPOFF32, R_SH_TLS_DTPOFF32 },
+  { BFD_RELOC_SH_TLS_TPOFF32, R_SH_TLS_TPOFF32 },
   { BFD_RELOC_32_GOT_PCREL, R_SH_GOT32 },
   { BFD_RELOC_32_PLT_PCREL, R_SH_PLT32 },
   { BFD_RELOC_SH_COPY, R_SH_COPY },
@@ -1874,6 +2003,7 @@ sh_elf_info_to_howto (abfd, cache_ptr, dst)
   BFD_ASSERT (r < R_SH_FIRST_INVALID_RELOC_2 || r > R_SH_LAST_INVALID_RELOC_2);
   BFD_ASSERT (r < R_SH_FIRST_INVALID_RELOC_3 || r > R_SH_LAST_INVALID_RELOC_3);
   BFD_ASSERT (r < R_SH_FIRST_INVALID_RELOC_4 || r > R_SH_LAST_INVALID_RELOC_4);
+  BFD_ASSERT (r < R_SH_FIRST_INVALID_RELOC_5 || r > R_SH_LAST_INVALID_RELOC_5);
 
   cache_ptr->howto = &sh_elf_howto_table[r];
 }
@@ -1888,32 +2018,32 @@ sh_elf_info_to_howto (abfd, cache_ptr, dst)
    values; in coff-sh.c they come from include/coff/sh.h, whereas here
    they come from enum elf_sh_reloc_type in include/elf/sh.h.  */
 
-static boolean
+static bfd_boolean
 sh_elf_relax_section (abfd, sec, link_info, again)
      bfd *abfd;
      asection *sec;
      struct bfd_link_info *link_info;
-     boolean *again;
+     bfd_boolean *again;
 {
   Elf_Internal_Shdr *symtab_hdr;
   Elf_Internal_Rela *internal_relocs;
-  boolean have_code;
+  bfd_boolean have_code;
   Elf_Internal_Rela *irel, *irelend;
   bfd_byte *contents = NULL;
   Elf_Internal_Sym *isymbuf = NULL;
 
-  *again = false;
+  *again = FALSE;
 
-  if (link_info->relocateable
+  if (link_info->relocatable
       || (sec->flags & SEC_RELOC) == 0
       || sec->reloc_count == 0)
-    return true;
+    return TRUE;
 
 #ifdef INCLUDE_SHMEDIA
   if (elf_section_data (sec)->this_hdr.sh_flags
       & (SHF_SH5_ISA32 | SHF_SH5_ISA32_MIXED))
     {
-      return true;
+      return TRUE;
     }
 #endif
 
@@ -1924,13 +2054,13 @@ sh_elf_relax_section (abfd, sec, link_info, again)
 
   symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
 
-  internal_relocs = (_bfd_elf32_link_read_relocs
+  internal_relocs = (_bfd_elf_link_read_relocs
                     (abfd, sec, (PTR) NULL, (Elf_Internal_Rela *) NULL,
                      link_info->keep_memory));
   if (internal_relocs == NULL)
     goto error_return;
 
-  have_code = false;
+  have_code = FALSE;
 
   irelend = internal_relocs + sec->reloc_count;
   for (irel = internal_relocs; irel < irelend; irel++)
@@ -1941,7 +2071,7 @@ sh_elf_relax_section (abfd, sec, link_info, again)
       bfd_signed_vma foff;
 
       if (ELF32_R_TYPE (irel->r_info) == (int) R_SH_CODE)
-       have_code = true;
+       have_code = TRUE;
 
       if (ELF32_R_TYPE (irel->r_info) != (int) R_SH_USES)
        continue;
@@ -2106,6 +2236,12 @@ sh_elf_relax_section (abfd, sec, link_info, again)
       /* Change the R_SH_USES reloc into an R_SH_IND12W reloc, and
         replace the jsr with a bsr.  */
       irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irelfn->r_info), R_SH_IND12W);
+      /* We used to test (ELF32_R_SYM (irelfn->r_info) < symtab_hdr->sh_info)
+        here, but that only checks if the symbol is an external symbol,
+        not if the symbol is in a different section.  Besides, we need
+        a consistent meaning for the relocation, so we just assume here that
+        the value of the symbol is not available.  */
+#if 0
       if (ELF32_R_SYM (irelfn->r_info) < symtab_hdr->sh_info)
        {
          /* If this needs to be changed because of future relaxing,
@@ -2116,12 +2252,14 @@ sh_elf_relax_section (abfd, sec, link_info, again)
                      contents + irel->r_offset);
        }
       else
+#endif
        {
          /* We can't fully resolve this yet, because the external
             symbol value may be changed by future relaxing.  We let
             the final link phase handle it.  */
          bfd_put_16 (abfd, (bfd_vma) 0xb000, contents + irel->r_offset);
        }
+      irel->r_addend = -4;
 
       /* See if there is another R_SH_USES reloc referring to the same
         register load.  */
@@ -2153,7 +2291,7 @@ sh_elf_relax_section (abfd, sec, link_info, again)
       /* That will change things, so, just in case it permits some
         other function call to come within range, we should relax
         again.  Note that this is not required, and it may be slow.  */
-      *again = true;
+      *again = TRUE;
 
       /* Now check whether we got a COUNT reloc.  */
       if (irelcount >= irelend)
@@ -2190,9 +2328,10 @@ sh_elf_relax_section (abfd, sec, link_info, again)
 
   /* Look for load and store instructions that we can align on four
      byte boundaries.  */
-  if (have_code)
+  if ((elf_elfheader (abfd)->e_flags & EF_SH_MACH_MASK) != EF_SH4
+      && have_code)
     {
-      boolean swapped;
+      bfd_boolean swapped;
 
       /* Get the section contents.  */
       if (contents == NULL)
@@ -2251,7 +2390,7 @@ sh_elf_relax_section (abfd, sec, link_info, again)
       && elf_section_data (sec)->relocs != internal_relocs)
     free (internal_relocs);
 
-  return true;
+  return TRUE;
 
  error_return:
   if (isymbuf != NULL
@@ -2264,14 +2403,14 @@ sh_elf_relax_section (abfd, sec, link_info, again)
       && elf_section_data (sec)->relocs != internal_relocs)
     free (internal_relocs);
 
-  return false;
+  return FALSE;
 }
 
 /* Delete some bytes from a section while relaxing.  FIXME: There is a
    lot of duplication between this function and sh_relax_delete_bytes
    in coff-sh.c.  */
 
-static boolean
+static bfd_boolean
 sh_elf_relax_delete_bytes (abfd, sec, addr, count)
      bfd *abfd;
      asection *sec;
@@ -2341,7 +2480,7 @@ sh_elf_relax_delete_bytes (abfd, sec, addr, count)
       int insn = 0;
       int off, adjust, oinsn;
       bfd_signed_vma voff = 0;
-      boolean overflow;
+      bfd_boolean overflow;
 
       /* Get the new reloc address.  */
       nraddr = irel->r_offset;
@@ -2416,14 +2555,28 @@ sh_elf_relax_delete_bytes (abfd, sec, addr, count)
          break;
 
        case R_SH_IND12W:
-         if (ELF32_R_SYM (irel->r_info) >= symtab_hdr->sh_info)
-           start = stop = addr;
+         off = insn & 0xfff;
+         if (! off)
+           {
+             /* This has been made by previous relaxation.  Since the
+                relocation will be against an external symbol, the
+                final relocation will just do the right thing.  */
+             start = stop = addr;
+           }
          else
            {
-             off = insn & 0xfff;
              if (off & 0x800)
                off -= 0x1000;
              stop = (bfd_vma) ((bfd_signed_vma) start + 4 + off * 2);
+
+             /* The addend will be against the section symbol, thus
+                for adjusting the addend, the relevant start is the
+                start of the section.
+                N.B. If we want to abandom in-place changes here and
+                test directly using symbol + addend, we have to take into
+                account that the addend has already been adjusted by -4.  */
+             if (stop > addr && stop < toaddr)
+               irel->r_addend -= count;
            }
          break;
 
@@ -2493,7 +2646,7 @@ sh_elf_relax_delete_bytes (abfd, sec, addr, count)
       if (adjust != 0)
        {
          oinsn = insn;
-         overflow = false;
+         overflow = FALSE;
          switch ((enum elf_sh_reloc_type) ELF32_R_TYPE (irel->r_info))
            {
            default:
@@ -2504,14 +2657,14 @@ sh_elf_relax_delete_bytes (abfd, sec, addr, count)
            case R_SH_DIR8WPZ:
              insn += adjust / 2;
              if ((oinsn & 0xff00) != (insn & 0xff00))
-               overflow = true;
+               overflow = TRUE;
              bfd_put_16 (abfd, (bfd_vma) insn, contents + nraddr);
              break;
 
            case R_SH_IND12W:
              insn += adjust / 2;
              if ((oinsn & 0xf000) != (insn & 0xf000))
-               overflow = true;
+               overflow = TRUE;
              bfd_put_16 (abfd, (bfd_vma) insn, contents + nraddr);
              break;
 
@@ -2525,21 +2678,21 @@ sh_elf_relax_delete_bytes (abfd, sec, addr, count)
                    ++insn;
                }
              if ((oinsn & 0xff00) != (insn & 0xff00))
-               overflow = true;
+               overflow = TRUE;
              bfd_put_16 (abfd, (bfd_vma) insn, contents + nraddr);
              break;
 
            case R_SH_SWITCH8:
              voff += adjust;
              if (voff < 0 || voff >= 0xff)
-               overflow = true;
+               overflow = TRUE;
              bfd_put_8 (abfd, voff, contents + nraddr);
              break;
 
            case R_SH_SWITCH16:
              voff += adjust;
              if (voff < - 0x8000 || voff >= 0x8000)
-               overflow = true;
+               overflow = TRUE;
              bfd_put_signed_16 (abfd, (bfd_vma) voff, contents + nraddr);
              break;
 
@@ -2559,7 +2712,7 @@ sh_elf_relax_delete_bytes (abfd, sec, addr, count)
               (_("%s: 0x%lx: fatal: reloc overflow while relaxing"),
                bfd_archive_filename (abfd), (unsigned long) irel->r_offset));
              bfd_set_error (bfd_error_bad_value);
-             return false;
+             return FALSE;
            }
        }
 
@@ -2581,13 +2734,13 @@ sh_elf_relax_delete_bytes (abfd, sec, addr, count)
        continue;
 
       /* We always cache the relocs.  Perhaps, if info->keep_memory is
-        false, we should free them, if we are permitted to, when we
+        FALSE, we should free them, if we are permitted to, when we
         leave sh_coff_relax_section.  */
-      internal_relocs = (_bfd_elf32_link_read_relocs
+      internal_relocs = (_bfd_elf_link_read_relocs
                         (abfd, o, (PTR) NULL, (Elf_Internal_Rela *) NULL,
-                         true));
+                         TRUE));
       if (internal_relocs == NULL)
-       return false;
+       return FALSE;
 
       ocontents = NULL;
       irelscanend = internal_relocs + o->reloc_count;
@@ -2606,16 +2759,16 @@ sh_elf_relax_delete_bytes (abfd, sec, addr, count)
                  else
                    {
                      /* We always cache the section contents.
-                        Perhaps, if info->keep_memory is false, we
+                        Perhaps, if info->keep_memory is FALSE, we
                         should free them, if we are permitted to,
                         when we leave sh_coff_relax_section.  */
                      ocontents = (bfd_byte *) bfd_malloc (o->_raw_size);
                      if (ocontents == NULL)
-                       return false;
+                       return FALSE;
                      if (! bfd_get_section_contents (abfd, o, ocontents,
                                                      (file_ptr) 0,
                                                      o->_raw_size))
-                       return false;
+                       return FALSE;
                      elf_section_data (o)->this_hdr.contents = ocontents;
                    }
                }
@@ -2664,16 +2817,16 @@ sh_elf_relax_delete_bytes (abfd, sec, addr, count)
                  else
                    {
                      /* We always cache the section contents.
-                        Perhaps, if info->keep_memory is false, we
+                        Perhaps, if info->keep_memory is FALSE, we
                         should free them, if we are permitted to,
                         when we leave sh_coff_relax_section.  */
                      ocontents = (bfd_byte *) bfd_malloc (o->_raw_size);
                      if (ocontents == NULL)
-                       return false;
+                       return FALSE;
                      if (! bfd_get_section_contents (abfd, o, ocontents,
                                                      (file_ptr) 0,
                                                      o->_raw_size))
-                       return false;
+                       return FALSE;
                      elf_section_data (o)->this_hdr.contents = ocontents;
                    }
                }
@@ -2732,26 +2885,26 @@ sh_elf_relax_delete_bytes (abfd, sec, addr, count)
        }
     }
 
-  return true;
+  return TRUE;
 }
 
 /* Look for loads and stores which we can align to four byte
    boundaries.  This is like sh_align_loads in coff-sh.c.  */
 
-static boolean
+static bfd_boolean
 sh_elf_align_loads (abfd, sec, internal_relocs, contents, pswapped)
      bfd *abfd ATTRIBUTE_UNUSED;
      asection *sec;
      Elf_Internal_Rela *internal_relocs;
      bfd_byte *contents ATTRIBUTE_UNUSED;
-     boolean *pswapped;
+     bfd_boolean *pswapped;
 {
   Elf_Internal_Rela *irel, *irelend;
   bfd_vma *labels = NULL;
   bfd_vma *label, *label_end;
   bfd_size_type amt;
 
-  *pswapped = false;
+  *pswapped = FALSE;
 
   irelend = internal_relocs + sec->reloc_count;
 
@@ -2802,17 +2955,17 @@ sh_elf_align_loads (abfd, sec, internal_relocs, contents, pswapped)
 
   free (labels);
 
-  return true;
+  return TRUE;
 
  error_return:
   if (labels != NULL)
     free (labels);
-  return false;
+  return FALSE;
 }
 
 /* Swap two SH instructions.  This is like sh_swap_insns in coff-sh.c.  */
 
-static boolean
+static bfd_boolean
 sh_elf_swap_insns (abfd, sec, relocs, contents, addr)
      bfd *abfd;
      asection *sec;
@@ -2881,10 +3034,10 @@ sh_elf_swap_insns (abfd, sec, relocs, contents, addr)
        {
          bfd_byte *loc;
          unsigned short insn, oinsn;
-         boolean overflow;
+         bfd_boolean overflow;
 
          loc = contents + irel->r_offset;
-         overflow = false;
+         overflow = FALSE;
          switch (type)
            {
            default:
@@ -2896,7 +3049,7 @@ sh_elf_swap_insns (abfd, sec, relocs, contents, addr)
              oinsn = insn;
              insn += add / 2;
              if ((oinsn & 0xff00) != (insn & 0xff00))
-               overflow = true;
+               overflow = TRUE;
              bfd_put_16 (abfd, (bfd_vma) insn, loc);
              break;
 
@@ -2905,7 +3058,7 @@ sh_elf_swap_insns (abfd, sec, relocs, contents, addr)
              oinsn = insn;
              insn += add / 2;
              if ((oinsn & 0xf000) != (insn & 0xf000))
-               overflow = true;
+               overflow = TRUE;
              bfd_put_16 (abfd, (bfd_vma) insn, loc);
              break;
 
@@ -2922,7 +3075,7 @@ sh_elf_swap_insns (abfd, sec, relocs, contents, addr)
                  oinsn = insn;
                  insn += add / 2;
                  if ((oinsn & 0xff00) != (insn & 0xff00))
-                   overflow = true;
+                   overflow = TRUE;
                  bfd_put_16 (abfd, (bfd_vma) insn, loc);
                }
 
@@ -2935,12 +3088,12 @@ sh_elf_swap_insns (abfd, sec, relocs, contents, addr)
               (_("%s: 0x%lx: fatal: reloc overflow while relaxing"),
                bfd_archive_filename (abfd), (unsigned long) irel->r_offset));
              bfd_set_error (bfd_error_bad_value);
-             return false;
+             return FALSE;
            }
        }
     }
 
-  return true;
+  return TRUE;
 }
 \f
 #ifdef INCLUDE_SHMEDIA
@@ -3047,7 +3200,7 @@ static const bfd_byte elf_sh_pic_plt_entry_be[PLT_ENTRY_SIZE] =
   0x6f, 0xf0, 0xff, 0xf0, /* nop */
   0x6f, 0xf0, 0xff, 0xf0, /* nop */
   0xce, 0x00, 0x01, 0x10, /* movi  -GOT_BIAS, r17 */
-  0x00, 0xca, 0x45, 0x10, /* sub.l r12, r17, r17 */
+  0x00, 0xc8, 0x45, 0x10, /* add.l r12, r17, r17 */
   0x89, 0x10, 0x09, 0x90, /* ld.l  r17, 8, r25 */
   0x6b, 0xf1, 0x66, 0x00, /* ptabs r25, tr0 */
   0x89, 0x10, 0x05, 0x10, /* ld.l  r17, 4, r17 */
@@ -3067,7 +3220,7 @@ static const bfd_byte elf_sh_pic_plt_entry_le[PLT_ENTRY_SIZE] =
   0xf0, 0xff, 0xf0, 0x6f, /* nop */
   0xf0, 0xff, 0xf0, 0x6f, /* nop */
   0x10, 0x01, 0x00, 0xce, /* movi  -GOT_BIAS, r17 */
-  0x10, 0x45, 0xca, 0x00, /* sub.l r12, r17, r17 */
+  0x10, 0x45, 0xc8, 0x00, /* add.l r12, r17, r17 */
   0x90, 0x09, 0x10, 0x89, /* ld.l  r17, 8, r25 */
   0x00, 0x66, 0xf1, 0x6b, /* ptabs r25, tr0 */
   0x10, 0x05, 0x10, 0x89, /* ld.l  r17, 4, r17 */
@@ -3383,15 +3536,53 @@ struct elf_sh_link_hash_entry
   struct elf_link_hash_entry root;
 
 #ifdef INCLUDE_SHMEDIA
-  bfd_vma datalabel_got_offset;
+  union
+  {
+    bfd_signed_vma refcount;
+    bfd_vma offset;
+  } datalabel_got;
 #endif
 
   /* Track dynamic relocs copied for this symbol.  */
   struct elf_sh_dyn_relocs *dyn_relocs;
 
   bfd_signed_vma gotplt_refcount;
+
+  enum {
+    GOT_UNKNOWN = 0, GOT_NORMAL, GOT_TLS_GD, GOT_TLS_IE
+  } tls_type;
+};
+
+#define sh_elf_hash_entry(ent) ((struct elf_sh_link_hash_entry *)(ent))
+
+struct sh_elf_obj_tdata
+{
+  struct elf_obj_tdata root;
+
+  /* tls_type for each local got entry.  */
+  char *local_got_tls_type;
 };
 
+#define sh_elf_tdata(abfd) \
+  ((struct sh_elf_obj_tdata *) (abfd)->tdata.any)
+
+#define sh_elf_local_got_tls_type(abfd) \
+  (sh_elf_tdata (abfd)->local_got_tls_type)
+
+/* Override the generic function because we need to store sh_elf_obj_tdata
+   as the specific tdata.  */
+
+static bfd_boolean
+sh_elf_mkobject (abfd)
+     bfd *abfd;
+{
+  bfd_size_type amt = sizeof (struct sh_elf_obj_tdata);
+  abfd->tdata.any = bfd_zalloc (abfd, amt);
+  if (abfd->tdata.any == NULL)
+    return FALSE;
+  return TRUE;
+}
+
 /* sh ELF linker hash table.  */
 
 struct elf_sh_link_hash_table
@@ -3409,6 +3600,13 @@ struct elf_sh_link_hash_table
 
   /* Small local sym to section mapping cache.  */
   struct sym_sec_cache sym_sec;
+
+  /* A counter or offset to track a TLS got entry.  */
+  union
+    {
+      bfd_signed_vma refcount;
+      bfd_vma offset;
+    } tls_ldm_got;
 };
 
 /* Traverse an sh ELF linker hash table.  */
@@ -3416,7 +3614,7 @@ struct elf_sh_link_hash_table
 #define sh_elf_link_hash_traverse(table, func, info)                   \
   (elf_link_hash_traverse                                              \
    (&(table)->root,                                                    \
-    (boolean (*) PARAMS ((struct elf_link_hash_entry *, PTR))) (func), \
+    (bfd_boolean (*) PARAMS ((struct elf_link_hash_entry *, PTR))) (func), \
     (info)))
 
 /* Get the sh ELF linker hash table from a link_info structure.  */
@@ -3450,14 +3648,12 @@ sh_elf_link_hash_newfunc (entry, table, string)
                                     table, string));
   if (ret != (struct elf_sh_link_hash_entry *) NULL)
     {
-      struct elf_sh_link_hash_entry *eh;
-
-      eh = (struct elf_sh_link_hash_entry *) ret;
-      eh->dyn_relocs = NULL;
-      eh->gotplt_refcount = 0;
+      ret->dyn_relocs = NULL;
+      ret->gotplt_refcount = 0;
 #ifdef INCLUDE_SHMEDIA
-      ret->datalabel_got_offset = (bfd_vma) -1;
+      ret->datalabel_got.refcount = ret->root.got.refcount;
 #endif
+      ret->tls_type = GOT_UNKNOWN;
     }
 
   return (struct bfd_hash_entry *) ret;
@@ -3491,6 +3687,7 @@ sh_elf_link_hash_table_create (abfd)
   ret->sdynbss = NULL;
   ret->srelbss = NULL;
   ret->sym_sec.abfd = NULL;
+  ret->tls_ldm_got.refcount = 0;
 
   return &ret->root.root;
 }
@@ -3498,7 +3695,7 @@ sh_elf_link_hash_table_create (abfd)
 /* Create .got, .gotplt, and .rela.got sections in DYNOBJ, and set up
    shortcuts to them in our hash table.  */
 
-static boolean
+static bfd_boolean
 create_got_section (dynobj, info)
      bfd *dynobj;
      struct bfd_link_info *info;
@@ -3506,7 +3703,7 @@ create_got_section (dynobj, info)
   struct elf_sh_link_hash_table *htab;
 
   if (! _bfd_elf_create_got_section (dynobj, info))
-    return false;
+    return FALSE;
 
   htab = sh_elf_hash_table (info);
   htab->sgot = bfd_get_section_by_name (dynobj, ".got");
@@ -3524,13 +3721,13 @@ create_got_section (dynobj, info)
                                   | SEC_LINKER_CREATED
                                   | SEC_READONLY))
       || ! bfd_set_section_alignment (dynobj, htab->srelgot, 2))
-    return false;
-  return true;
+    return FALSE;
+  return TRUE;
 }
 
 /* Create dynamic sections when linking against a dynamic object.  */
 
-static boolean
+static bfd_boolean
 sh_elf_create_dynamic_sections (abfd, info)
      bfd *abfd;
      struct bfd_link_info *info;
@@ -3553,7 +3750,7 @@ sh_elf_create_dynamic_sections (abfd, info)
 
     default:
       bfd_set_error (bfd_error_bad_value);
-      return false;
+      return FALSE;
     }
 
   htab = sh_elf_hash_table (info);
@@ -3576,25 +3773,28 @@ sh_elf_create_dynamic_sections (abfd, info)
   if (s == NULL
       || ! bfd_set_section_flags (abfd, s, pltflags)
       || ! bfd_set_section_alignment (abfd, s, bed->plt_alignment))
-    return false;
+    return FALSE;
 
   if (bed->want_plt_sym)
     {
       /* Define the symbol _PROCEDURE_LINKAGE_TABLE_ at the start of the
         .plt section.  */
-      struct elf_link_hash_entry *h = NULL;
+      struct elf_link_hash_entry *h;
+      struct bfd_link_hash_entry *bh = NULL;
+
       if (! (_bfd_generic_link_add_one_symbol
             (info, abfd, "_PROCEDURE_LINKAGE_TABLE_", BSF_GLOBAL, s,
-             (bfd_vma) 0, (const char *) NULL, false,
-             get_elf_backend_data (abfd)->collect,
-             (struct bfd_link_hash_entry **) &h)))
-       return false;
+             (bfd_vma) 0, (const char *) NULL, FALSE,
+             get_elf_backend_data (abfd)->collect, &bh)))
+       return FALSE;
+
+      h = (struct elf_link_hash_entry *) bh;
       h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
       h->type = STT_OBJECT;
 
       if (info->shared
          && ! _bfd_elf_link_record_dynamic_symbol (info, h))
-       return false;
+       return FALSE;
     }
 
   s = bfd_make_section (abfd,
@@ -3603,10 +3803,10 @@ sh_elf_create_dynamic_sections (abfd, info)
   if (s == NULL
       || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
       || ! bfd_set_section_alignment (abfd, s, ptralign))
-    return false;
+    return FALSE;
 
   if (! create_got_section (abfd, info))
-    return false;
+    return FALSE;
 
   {
     const char *secname;
@@ -3628,7 +3828,7 @@ sh_elf_create_dynamic_sections (abfd, info)
        if (s == NULL
            || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
            || ! bfd_set_section_alignment (abfd, s, ptralign))
-         return false;
+         return FALSE;
       }
   }
 
@@ -3644,7 +3844,7 @@ sh_elf_create_dynamic_sections (abfd, info)
       htab->sdynbss = s;
       if (s == NULL
          || ! bfd_set_section_flags (abfd, s, SEC_ALLOC))
-       return false;
+       return FALSE;
 
       /* The .rel[a].bss section holds copy relocs.  This section is not
         normally needed.  We need to create it here, though, so that the
@@ -3666,11 +3866,11 @@ sh_elf_create_dynamic_sections (abfd, info)
          if (s == NULL
              || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
              || ! bfd_set_section_alignment (abfd, s, ptralign))
-           return false;
+           return FALSE;
        }
     }
 
-  return true;
+  return TRUE;
 }
 \f
 /* Adjust a symbol defined by a dynamic object and referenced by a
@@ -3679,7 +3879,7 @@ sh_elf_create_dynamic_sections (abfd, info)
    change the definition to something the rest of the link can
    understand.  */
 
-static boolean
+static bfd_boolean
 sh_elf_adjust_dynamic_symbol (info, h)
      struct bfd_link_info *info;
      struct elf_link_hash_entry *h;
@@ -3726,7 +3926,7 @@ sh_elf_adjust_dynamic_symbol (info, h)
          h->elf_link_hash_flags &= ~ELF_LINK_HASH_NEEDS_PLT;
        }
 
-      return true;
+      return TRUE;
     }
   else
     h->plt.offset = (bfd_vma) -1;
@@ -3740,7 +3940,11 @@ sh_elf_adjust_dynamic_symbol (info, h)
                  || h->weakdef->root.type == bfd_link_hash_defweak);
       h->root.u.def.section = h->weakdef->root.u.def.section;
       h->root.u.def.value = h->weakdef->root.u.def.value;
-      return true;
+      if (info->nocopyreloc)
+       h->elf_link_hash_flags
+         = ((h->elf_link_hash_flags & ~ELF_LINK_NON_GOT_REF)
+            | (h->weakdef->elf_link_hash_flags & ELF_LINK_NON_GOT_REF));
+      return TRUE;
     }
 
   /* This is a reference to a symbol defined by a dynamic object which
@@ -3751,18 +3955,18 @@ sh_elf_adjust_dynamic_symbol (info, h)
      For such cases we need not do anything here; the relocations will
      be handled correctly by relocate_section.  */
   if (info->shared)
-    return true;
+    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->elf_link_hash_flags & ELF_LINK_NON_GOT_REF) == 0)
-    return true;
+    return TRUE;
 
   /* If -z nocopyreloc was given, we won't generate them either.  */
   if (info->nocopyreloc)
     {
       h->elf_link_hash_flags &= ~ELF_LINK_NON_GOT_REF;
-      return true;
+      return TRUE;
     }
 
   eh = (struct elf_sh_link_hash_entry *) h;
@@ -3779,7 +3983,7 @@ sh_elf_adjust_dynamic_symbol (info, h)
   if (p == NULL)
     {
       h->elf_link_hash_flags &= ~ELF_LINK_NON_GOT_REF;
-      return true;
+      return TRUE;
     }
 
   /* We must allocate the symbol in our .dynbss section, which will
@@ -3821,7 +4025,7 @@ sh_elf_adjust_dynamic_symbol (info, h)
   if (power_of_two > bfd_get_section_alignment (dynobj, s))
     {
       if (! bfd_set_section_alignment (dynobj, s, power_of_two))
-       return false;
+       return FALSE;
     }
 
   /* Define the symbol as being at this point in the section.  */
@@ -3831,16 +4035,16 @@ sh_elf_adjust_dynamic_symbol (info, h)
   /* Increment the section size to make room for the symbol.  */
   s->_raw_size += h->size;
 
-  return true;
+  return TRUE;
 }
 
 /* This is the condition under which sh_elf_finish_dynamic_symbol
    will be called from elflink.h.  If elflink.h doesn't call our
    finish_dynamic_symbol routine, we'll need to do something about
    initializing any .plt and .got entries in sh_elf_relocate_section.  */
-#define WILL_CALL_FINISH_DYNAMIC_SYMBOL(DYN, INFO, H) \
+#define WILL_CALL_FINISH_DYNAMIC_SYMBOL(DYN, SHARED, H) \
   ((DYN)                                                               \
-   && ((INFO)->shared                                                  \
+   && ((SHARED)                                                                \
        || ((H)->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)     \
    && ((H)->dynindx != -1                                              \
        || ((H)->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) != 0))
@@ -3848,7 +4052,7 @@ sh_elf_adjust_dynamic_symbol (info, h)
 /* Allocate space in .plt, .got and associated reloc sections for
    dynamic relocs.  */
 
-static boolean
+static bfd_boolean
 allocate_dynrelocs (h, inf)
      struct elf_link_hash_entry *h;
      PTR inf;
@@ -3859,7 +4063,7 @@ allocate_dynrelocs (h, inf)
   struct elf_sh_dyn_relocs *p;
 
   if (h->root.type == bfd_link_hash_indirect)
-    return true;
+    return TRUE;
 
   if (h->root.type == bfd_link_hash_warning)
     /* When warning symbols are created, they **replace** the "real"
@@ -3876,14 +4080,16 @@ allocate_dynrelocs (h, inf)
       && eh->gotplt_refcount > 0)
     {
       /* The symbol has been forced local, or we have some direct got refs,
-         so treat all the gotplt refs as got refs. */
+        so treat all the gotplt refs as got refs. */
       h->got.refcount += eh->gotplt_refcount;
       if (h->plt.refcount >= eh->gotplt_refcount)
        h->plt.refcount -= eh->gotplt_refcount;
     }
 
   if (htab->root.dynamic_sections_created
-      && h->plt.refcount > 0)
+      && h->plt.refcount > 0
+      && (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
+         || h->root.type != bfd_link_hash_undefweak))
     {
       /* Make sure this symbol is output as a dynamic symbol.
         Undefined weak syms won't yet be marked as dynamic.  */
@@ -3891,10 +4097,11 @@ allocate_dynrelocs (h, inf)
          && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)
        {
          if (! bfd_elf32_link_record_dynamic_symbol (info, h))
-           return false;
+           return FALSE;
        }
 
-      if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, info, h))
+      if (info->shared
+         || WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, 0, h))
        {
          asection *s = htab->splt;
 
@@ -3942,7 +4149,8 @@ allocate_dynrelocs (h, inf)
   if (h->got.refcount > 0)
     {
       asection *s;
-      boolean dyn;
+      bfd_boolean dyn;
+      int tls_type = sh_elf_hash_entry (h)->tls_type;
 
       /* Make sure this symbol is output as a dynamic symbol.
         Undefined weak syms won't yet be marked as dynamic.  */
@@ -3950,34 +4158,60 @@ allocate_dynrelocs (h, inf)
          && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)
        {
          if (! bfd_elf32_link_record_dynamic_symbol (info, h))
-           return false;
+           return FALSE;
        }
 
       s = htab->sgot;
+      h->got.offset = s->_raw_size;
+      s->_raw_size += 4;
+      /* R_SH_TLS_GD needs 2 consecutive GOT slots.  */
+      if (tls_type == GOT_TLS_GD)
+       s->_raw_size += 4;
+      dyn = htab->root.dynamic_sections_created;
+      /* R_SH_TLS_IE_32 needs one dynamic relocation if dynamic,
+        R_SH_TLS_GD needs one if local symbol and two if global.  */
+      if ((tls_type == GOT_TLS_GD && h->dynindx == -1)
+         || (tls_type == GOT_TLS_IE && dyn))
+       htab->srelgot->_raw_size += sizeof (Elf32_External_Rela);
+      else if (tls_type == GOT_TLS_GD)
+       htab->srelgot->_raw_size += 2 * sizeof (Elf32_External_Rela);
+      else if ((ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
+               || h->root.type != bfd_link_hash_undefweak)
+              && (info->shared
+                  || WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 0, h)))
+       htab->srelgot->_raw_size += sizeof (Elf32_External_Rela);
+    }
+  else
+    h->got.offset = (bfd_vma) -1;
+
 #ifdef INCLUDE_SHMEDIA
-      if (h->type == STT_DATALABEL)
-       {
-         struct elf_sh_link_hash_entry *hsh;
+  if (eh->datalabel_got.refcount > 0)
+    {
+      asection *s;
+      bfd_boolean dyn;
 
-         h = (struct elf_link_hash_entry *) h->root.u.i.link;
-         hsh = (struct elf_sh_link_hash_entry *)h;
-         hsh->datalabel_got_offset = s->_raw_size;
+      /* Make sure this symbol is output as a dynamic symbol.
+        Undefined weak syms won't yet be marked as dynamic.  */
+      if (h->dynindx == -1
+         && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)
+       {
+         if (! bfd_elf32_link_record_dynamic_symbol (info, h))
+           return FALSE;
        }
-      else
-       h->got.offset = s->_raw_size;
-#else
-      h->got.offset = s->_raw_size;
-#endif
+
+      s = htab->sgot;
+      eh->datalabel_got.offset = s->_raw_size;
       s->_raw_size += 4;
       dyn = htab->root.dynamic_sections_created;
-      if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info, h))
+      if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h))
        htab->srelgot->_raw_size += sizeof (Elf32_External_Rela);
     }
   else
-    h->got.offset = (bfd_vma) -1;
+    eh->datalabel_got.offset = (bfd_vma) -1;
+#endif
 
   if (eh->dyn_relocs == NULL)
-    return true;
+    return TRUE;
 
   /* In the shared -Bsymbolic case, discard space allocated for
      dynamic pc-relative relocs against symbols which turn out to be
@@ -4003,6 +4237,12 @@ allocate_dynrelocs (h, inf)
                pp = &p->next;
            }
        }
+
+      /* Also discard relocs on undefined weak syms with non-default
+        visibility.  */
+      if (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT
+         && h->root.type == bfd_link_hash_undefweak)
+       eh->dyn_relocs = NULL;
     }
   else
     {
@@ -4023,7 +4263,7 @@ allocate_dynrelocs (h, inf)
              && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) == 0)
            {
              if (! bfd_elf32_link_record_dynamic_symbol (info, h))
-               return false;
+               return FALSE;
            }
 
          /* If that succeeded, we know we'll be keeping all the
@@ -4044,12 +4284,12 @@ allocate_dynrelocs (h, inf)
       sreloc->_raw_size += p->count * sizeof (Elf32_External_Rela);
     }
 
-  return true;
+  return TRUE;
 }
 
 /* Find any dynamic relocs that apply to read-only sections.  */
 
-static boolean
+static bfd_boolean
 readonly_dynrelocs (h, inf)
      struct elf_link_hash_entry *h;
      PTR inf;
@@ -4072,15 +4312,15 @@ readonly_dynrelocs (h, inf)
          info->flags |= DF_TEXTREL;
 
          /* Not an error, just cut short the traversal.  */
-         return false;
+         return FALSE;
        }
     }
-  return true;
+  return TRUE;
 }
 
 /* Set the sizes of the dynamic sections.  */
 
-static boolean
+static bfd_boolean
 sh_elf_size_dynamic_sections (output_bfd, info)
      bfd *output_bfd ATTRIBUTE_UNUSED;
      struct bfd_link_info *info;
@@ -4088,7 +4328,7 @@ sh_elf_size_dynamic_sections (output_bfd, info)
   struct elf_sh_link_hash_table *htab;
   bfd *dynobj;
   asection *s;
-  boolean relocs;
+  bfd_boolean relocs;
   bfd *ibfd;
 
   htab = sh_elf_hash_table (info);
@@ -4098,7 +4338,7 @@ sh_elf_size_dynamic_sections (output_bfd, info)
   if (htab->root.dynamic_sections_created)
     {
       /* Set the contents of the .interp section to the interpreter.  */
-      if (! info->shared)
+      if (info->executable)
        {
          s = bfd_get_section_by_name (dynobj, ".interp");
          BFD_ASSERT (s != NULL);
@@ -4113,6 +4353,7 @@ sh_elf_size_dynamic_sections (output_bfd, info)
     {
       bfd_signed_vma *local_got;
       bfd_signed_vma *end_local_got;
+      char *local_tls_type;
       bfd_size_type locsymcount;
       Elf_Internal_Shdr *symtab_hdr;
       asection *srel;
@@ -4158,6 +4399,7 @@ sh_elf_size_dynamic_sections (output_bfd, info)
       locsymcount *= 2;
 #endif
       end_local_got = local_got + locsymcount;
+      local_tls_type = sh_elf_local_got_tls_type (ibfd);
       s = htab->sgot;
       srel = htab->srelgot;
       for (; local_got < end_local_got; ++local_got)
@@ -4166,21 +4408,35 @@ sh_elf_size_dynamic_sections (output_bfd, info)
            {
              *local_got = s->_raw_size;
              s->_raw_size += 4;
+             if (*local_tls_type == GOT_TLS_GD)
+               s->_raw_size += 4;
              if (info->shared)
                srel->_raw_size += sizeof (Elf32_External_Rela);
            }
          else
            *local_got = (bfd_vma) -1;
+         ++local_tls_type;
        }
     }
 
+  if (htab->tls_ldm_got.refcount > 0)
+    {
+      /* Allocate 2 got entries and 1 dynamic reloc for R_SH_TLS_LD_32
+        relocs.  */
+      htab->tls_ldm_got.offset = htab->sgot->_raw_size;
+      htab->sgot->_raw_size += 8;
+      htab->srelgot->_raw_size += sizeof (Elf32_External_Rela);
+    }
+  else
+    htab->tls_ldm_got.offset = -1;
+
   /* Allocate global sym .plt and .got entries, and space for global
      sym dynamic relocs.  */
   elf_link_hash_traverse (&htab->root, allocate_dynrelocs, (PTR) info);
 
   /* We now have determined the sizes of the various dynamic sections.
      Allocate memory for them.  */
-  relocs = false;
+  relocs = FALSE;
   for (s = dynobj->sections; s != NULL; s = s->next)
     {
       if ((s->flags & SEC_LINKER_CREATED) == 0)
@@ -4196,7 +4452,7 @@ sh_elf_size_dynamic_sections (output_bfd, info)
       else if (strncmp (bfd_get_section_name (dynobj, s), ".rela", 5) == 0)
        {
          if (s->_raw_size != 0 && s != htab->srelplt)
-           relocs = true;
+           relocs = TRUE;
 
          /* We use the reloc_count field as a counter if we need
             to copy relocs into the output file.  */
@@ -4231,7 +4487,7 @@ sh_elf_size_dynamic_sections (output_bfd, info)
         of garbage.  */
       s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->_raw_size);
       if (s->contents == NULL)
-       return false;
+       return FALSE;
     }
 
   if (htab->root.dynamic_sections_created)
@@ -4244,10 +4500,10 @@ sh_elf_size_dynamic_sections (output_bfd, info)
 #define add_dynamic_entry(TAG, VAL) \
   bfd_elf32_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL))
 
-      if (! info->shared)
+      if (info->executable)
        {
          if (! add_dynamic_entry (DT_DEBUG, 0))
-           return false;
+           return FALSE;
        }
 
       if (htab->splt->_raw_size != 0)
@@ -4256,7 +4512,7 @@ sh_elf_size_dynamic_sections (output_bfd, info)
              || ! add_dynamic_entry (DT_PLTRELSZ, 0)
              || ! add_dynamic_entry (DT_PLTREL, DT_RELA)
              || ! add_dynamic_entry (DT_JMPREL, 0))
-           return false;
+           return FALSE;
        }
 
       if (relocs)
@@ -4265,7 +4521,7 @@ sh_elf_size_dynamic_sections (output_bfd, info)
              || ! add_dynamic_entry (DT_RELASZ, 0)
              || ! add_dynamic_entry (DT_RELAENT,
                                      sizeof (Elf32_External_Rela)))
-           return false;
+           return FALSE;
 
          /* If any dynamic relocs apply to a read-only section,
             then we need a DT_TEXTREL entry.  */
@@ -4276,18 +4532,18 @@ sh_elf_size_dynamic_sections (output_bfd, info)
          if ((info->flags & DF_TEXTREL) != 0)
            {
              if (! add_dynamic_entry (DT_TEXTREL, 0))
-               return false;
+               return FALSE;
            }
        }
     }
 #undef add_dynamic_entry
 
-  return true;
+  return TRUE;
 }
 \f
 /* Relocate an SH ELF section.  */
 
-static boolean
+static bfd_boolean
 sh_elf_relocate_section (output_bfd, info, input_bfd, input_section,
                         contents, relocs, local_syms, local_sections)
      bfd *output_bfd;
@@ -4309,6 +4565,7 @@ sh_elf_relocate_section (output_bfd, info, input_bfd, input_section,
   asection *sgotplt;
   asection *splt;
   asection *sreloc;
+  asection *srelgot;
 
   htab = sh_elf_hash_table (info);
   symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
@@ -4320,6 +4577,7 @@ sh_elf_relocate_section (output_bfd, info, input_bfd, input_section,
   sgotplt = htab->sgotplt;
   splt = htab->splt;
   sreloc = NULL;
+  srelgot = NULL;
 
   rel = relocs;
   relend = relocs + input_section->reloc_count;
@@ -4335,6 +4593,8 @@ sh_elf_relocate_section (output_bfd, info, input_bfd, input_section,
       bfd_vma addend = (bfd_vma) 0;
       bfd_reloc_status_type r;
       int seen_stt_datalabel = 0;
+      bfd_vma off;
+      int tls_type;
 
       r_symndx = ELF32_R_SYM (rel->r_info);
 
@@ -4356,11 +4616,13 @@ sh_elf_relocate_section (output_bfd, info, input_bfd, input_section,
              && r_type <= (int) R_SH_LAST_INVALID_RELOC_3)
          || (   r_type >= (int) R_SH_FIRST_INVALID_RELOC_4
              && r_type <= (int) R_SH_LAST_INVALID_RELOC_4)
+         || (   r_type >= (int) R_SH_FIRST_INVALID_RELOC_5
+             && r_type <= (int) R_SH_LAST_INVALID_RELOC_5)
          || (r_type >= (int) R_SH_FIRST_INVALID_RELOC_2
              && r_type <= (int) R_SH_LAST_INVALID_RELOC_2))
        {
          bfd_set_error (bfd_error_bad_value);
-         return false;
+         return FALSE;
        }
 
       howto = sh_elf_howto_table + r_type;
@@ -4388,9 +4650,9 @@ sh_elf_relocate_section (output_bfd, info, input_bfd, input_section,
             (info,
              _("Unexpected STO_SH5_ISA32 on local symbol is not handled"),
              input_bfd, input_section, rel->r_offset));
-         if (info->relocateable)
+         if (info->relocatable)
            {
-             /* This is a relocateable link.  We don't have to change
+             /* This is a relocatable link.  We don't have to change
                 anything, unless the reloc is against a section symbol,
                 in which case we have to adjust according to where the
                 section symbol winds up in the output section.  */
@@ -4442,7 +4704,7 @@ sh_elf_relocate_section (output_bfd, info, input_bfd, input_section,
                     bfd_archive_filename (input_bfd),
                     bfd_get_section_name (input_bfd, input_section),
                     (long) rel->r_offset, howto->name);
-                 return false;
+                 return FALSE;
                }
 
              addend = bfd_get_32 (input_bfd, contents + rel->r_offset);
@@ -4459,8 +4721,8 @@ sh_elf_relocate_section (output_bfd, info, input_bfd, input_section,
        {
          /* Section symbol are never (?) placed in the hash table, so
             we can just ignore hash relocations when creating a
-            relocateable object file.  */
-         if (info->relocateable)
+            relocatable object file.  */
+         if (info->relocatable)
            continue;
 
          h = sym_hashes[r_symndx - symtab_hdr->sh_info];
@@ -4478,7 +4740,7 @@ sh_elf_relocate_section (output_bfd, info, input_bfd, input_section,
          if (h->root.type == bfd_link_hash_defined
              || h->root.type == bfd_link_hash_defweak)
            {
-             boolean dyn;
+             bfd_boolean dyn;
 
              dyn = htab->root.dynamic_sections_created;
              sec = h->root.u.def.section;
@@ -4501,7 +4763,7 @@ sh_elf_relocate_section (output_bfd, info, input_bfd, input_section,
                       || r_type == R_SH_GOT_MEDLOW16
                       || r_type == R_SH_GOT_MEDHI16
                       || r_type == R_SH_GOT_HI16)
-                     && WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info, h)
+                     && WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h)
                      && (! info->shared
                          || (! info->symbolic && h->dynindx != -1)
                          || (h->elf_link_hash_flags
@@ -4526,15 +4788,25 @@ sh_elf_relocate_section (output_bfd, info, input_bfd, input_section,
                             with them here.  */
                          || ((input_section->flags & SEC_DEBUGGING) != 0
                              && (h->elf_link_hash_flags
-                                 & ELF_LINK_HASH_DEF_DYNAMIC) != 0))))
+                                 & ELF_LINK_HASH_DEF_DYNAMIC) != 0)))
+                 /* Dynamic relocs are not propagated for SEC_DEBUGGING
+                    sections because such sections are not SEC_ALLOC and
+                    thus ld.so will not process them.  */
+                 || (sec->output_section == NULL
+                     && ((input_section->flags & SEC_DEBUGGING) != 0
+                         && (h->elf_link_hash_flags
+                             & ELF_LINK_HASH_DEF_DYNAMIC) != 0))
+                 || (sec->output_section == NULL
+                     && (sh_elf_hash_entry (h)->tls_type == GOT_TLS_IE
+                         || sh_elf_hash_entry (h)->tls_type == GOT_TLS_GD)))
                relocation = 0;
              else if (sec->output_section == NULL)
                {
                  (*_bfd_error_handler)
-                   (_("%s: warning: unresolvable relocation against symbol `%s' from %s section"),
+                   (_("%s: unresolvable relocation against symbol `%s' from %s section"),
                     bfd_archive_filename (input_bfd), h->root.root.string,
                     bfd_get_section_name (input_bfd, input_section));
-                 relocation = 0;
+                 return FALSE;
                }
              else
                relocation = ((h->root.u.def.value
@@ -4549,7 +4821,6 @@ sh_elf_relocate_section (output_bfd, info, input_bfd, input_section,
          else if (h->root.type == bfd_link_hash_undefweak)
            relocation = 0;
          else if (info->shared
-                  && (! info->symbolic || info->allow_shlib_undefined)
                   && ! info->no_undefined
                   && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
            relocation = 0;
@@ -4560,7 +4831,7 @@ sh_elf_relocate_section (output_bfd, info, input_bfd, input_section,
                      input_section, rel->r_offset,
                      (!info->shared || info->no_undefined
                       || ELF_ST_VISIBILITY (h->other)))))
-               return false;
+               return FALSE;
              relocation = 0;
            }
        }
@@ -4576,7 +4847,6 @@ sh_elf_relocate_section (output_bfd, info, input_bfd, input_section,
          break;
 
        case R_SH_IND12W:
-         relocation -= 4;
          goto final_link_relocate;
 
        case R_SH_DIR8WPN:
@@ -4609,7 +4879,7 @@ sh_elf_relocate_section (output_bfd, info, input_bfd, input_section,
                    bfd_archive_filename (input_section->owner),
                    (unsigned long) rel->r_offset));
                  bfd_set_error (bfd_error_bad_value);
-                 return false;
+                 return FALSE;
                }
              relocation -= 4;
              goto final_link_relocate;
@@ -4624,11 +4894,14 @@ sh_elf_relocate_section (output_bfd, info, input_bfd, input_section,
            goto final_link_relocate;
 #endif
          bfd_set_error (bfd_error_bad_value);
-         return false;
+         return FALSE;
 
        case R_SH_DIR32:
        case R_SH_REL32:
          if (info->shared
+             && (h == NULL
+                 || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT
+                 || h->root.type != bfd_link_hash_undefweak)
              && r_symndx != 0
              && (input_section->flags & SEC_ALLOC) != 0
              && (r_type != R_SH_REL32
@@ -4639,7 +4912,8 @@ sh_elf_relocate_section (output_bfd, info, input_bfd, input_section,
                              & ELF_LINK_HASH_DEF_REGULAR) == 0))))
            {
              Elf_Internal_Rela outrel;
-             boolean skip, relocate;
+             bfd_byte *loc;
+             bfd_boolean skip, relocate;
 
              /* When generating a shared object, these relocations
                 are copied into the output file to be resolved at run
@@ -4654,7 +4928,7 @@ sh_elf_relocate_section (output_bfd, info, input_bfd, input_section,
                           elf_elfheader (input_bfd)->e_shstrndx,
                           elf_section_data (input_section)->rel_hdr.sh_name));
                  if (name == NULL)
-                   return false;
+                   return FALSE;
 
                  BFD_ASSERT (strncmp (name, ".rela", 5) == 0
                              && strcmp (bfd_get_section_name (input_bfd,
@@ -4665,16 +4939,16 @@ sh_elf_relocate_section (output_bfd, info, input_bfd, input_section,
                  BFD_ASSERT (sreloc != NULL);
                }
 
-             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);
 
@@ -4696,7 +4970,7 @@ sh_elf_relocate_section (output_bfd, info, input_bfd, input_section,
                          && (h->elf_link_hash_flags
                              & ELF_LINK_HASH_DEF_REGULAR) != 0))
                    {
-                     relocate = true;
+                     relocate = TRUE;
                      outrel.r_info = ELF32_R_INFO (0, R_SH_RELATIVE);
                      outrel.r_addend
                        = relocation + bfd_get_32 (input_bfd,
@@ -4712,11 +4986,9 @@ sh_elf_relocate_section (output_bfd, info, input_bfd, input_section,
                    }
                }
 
-             bfd_elf32_swap_reloca_out (output_bfd, &outrel,
-                                        (((Elf32_External_Rela *)
-                                          sreloc->contents)
-                                         + sreloc->reloc_count));
-             ++sreloc->reloc_count;
+             loc = sreloc->contents;
+             loc += sreloc->reloc_count++ * sizeof (Elf32_External_Rela);
+             bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
 
              /* If this reloc is against an external symbol, we do
                 not want to fiddle with the addend.  Otherwise, we
@@ -4779,8 +5051,7 @@ sh_elf_relocate_section (output_bfd, info, input_bfd, input_section,
 
          if (h != NULL)
            {
-             bfd_vma off;
-             boolean dyn;
+             bfd_boolean dyn;
 
              off = h->got.offset;
 #ifdef INCLUDE_SHMEDIA
@@ -4789,17 +5060,19 @@ sh_elf_relocate_section (output_bfd, info, input_bfd, input_section,
                  struct elf_sh_link_hash_entry *hsh;
 
                  hsh = (struct elf_sh_link_hash_entry *)h;
-                 off = hsh->datalabel_got_offset;
+                 off = hsh->datalabel_got.offset;
                }
 #endif
              BFD_ASSERT (off != (bfd_vma) -1);
 
              dyn = htab->root.dynamic_sections_created;
-             if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info, h)
+             if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h)
                  || (info->shared
                      && (info->symbolic || h->dynindx == -1
                          || (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL))
-                     && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)))
+                     && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR))
+                 || (ELF_ST_VISIBILITY (h->other)
+                     && h->root.type == bfd_link_hash_undefweak))
                {
                  /* This is actually a static link, or it is a
                     -Bsymbolic link and the symbol is defined
@@ -4825,7 +5098,7 @@ sh_elf_relocate_section (output_bfd, info, input_bfd, input_section,
                          struct elf_sh_link_hash_entry *hsh;
 
                          hsh = (struct elf_sh_link_hash_entry *)h;
-                         hsh->datalabel_got_offset |= 1;
+                         hsh->datalabel_got.offset |= 1;
                        }
                      else
 #endif
@@ -4837,8 +5110,6 @@ sh_elf_relocate_section (output_bfd, info, input_bfd, input_section,
            }
          else
            {
-             bfd_vma off;
-
 #ifdef INCLUDE_SHMEDIA
              if (rel->r_addend)
                {
@@ -4872,22 +5143,24 @@ sh_elf_relocate_section (output_bfd, info, input_bfd, input_section,
 
                  if (info->shared)
                    {
-                     asection *srelgot;
                      Elf_Internal_Rela outrel;
+                     bfd_byte *loc;
 
-                     srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
-                     BFD_ASSERT (srelgot != NULL);
+                     if (srelgot == NULL)
+                       {
+                         srelgot = bfd_get_section_by_name (dynobj,
+                                                            ".rela.got");
+                         BFD_ASSERT (srelgot != NULL);
+                       }
 
                      outrel.r_offset = (sgot->output_section->vma
                                         + sgot->output_offset
                                         + off);
                      outrel.r_info = ELF32_R_INFO (0, R_SH_RELATIVE);
                      outrel.r_addend = relocation;
-                     bfd_elf32_swap_reloca_out (output_bfd, &outrel,
-                                               (((Elf32_External_Rela *)
-                                                 srelgot->contents)
-                                                + srelgot->reloc_count));
-                     ++srelgot->reloc_count;
+                     loc = srelgot->contents;
+                     loc += srelgot->reloc_count++ * sizeof (Elf32_External_Rela);
+                     bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
                    }
 
 #ifdef INCLUDE_SHMEDIA
@@ -5010,6 +5283,398 @@ sh_elf_relocate_section (output_bfd, info, input_bfd, input_section,
                                   rel->r_offset, sec, start, end);
            break;
          }
+
+       case R_SH_TLS_GD_32:
+       case R_SH_TLS_IE_32:
+         r_type = sh_elf_optimized_tls_reloc (info, r_type, h == NULL);
+         tls_type = GOT_UNKNOWN;
+         if (h == NULL && local_got_offsets)
+           tls_type = sh_elf_local_got_tls_type (input_bfd) [r_symndx];
+         else if (h != NULL)
+           {
+             tls_type = sh_elf_hash_entry (h)->tls_type;
+             if (! info->shared
+                 && (h->dynindx == -1
+                     || (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)))
+               r_type = R_SH_TLS_LE_32;
+           }
+
+         if (r_type == R_SH_TLS_GD_32 && tls_type == GOT_TLS_IE)
+           r_type = R_SH_TLS_IE_32;
+
+         if (r_type == R_SH_TLS_LE_32)
+           {
+             bfd_vma offset;
+             unsigned short insn;
+
+             if (ELF32_R_TYPE (rel->r_info) == R_SH_TLS_GD_32)
+               {
+                 /* GD->LE transition:
+                      mov.l 1f,r4; mova 2f,r0; mov.l 2f,r1; add r0,r1;
+                      jsr @r1; add r12,r4; bra 3f; nop; .align 2;
+                      1: .long x$TLSGD; 2: .long __tls_get_addr@PLT; 3:
+                    We change it into:
+                      mov.l 1f,r4; stc gbr,r0; add r4,r0; nop;
+                      nop; nop; ...
+                      1: .long x@TPOFF; 2: .long __tls_get_addr@PLT; 3:.  */
+
+                 offset = rel->r_offset;
+                 BFD_ASSERT (offset >= 16);
+                 /* Size of GD instructions is 16 or 18.  */
+                 offset -= 16;
+                 insn = bfd_get_16 (input_bfd, contents + offset + 0);
+                 if ((insn & 0xff00) == 0xc700)
+                   {
+                     BFD_ASSERT (offset >= 2);
+                     offset -= 2;
+                     insn = bfd_get_16 (input_bfd, contents + offset + 0);
+                   }
+
+                 BFD_ASSERT ((insn & 0xff00) == 0xd400);
+                 insn = bfd_get_16 (input_bfd, contents + offset + 2);
+                 BFD_ASSERT ((insn & 0xff00) == 0xc700);
+                 insn = bfd_get_16 (input_bfd, contents + offset + 4);
+                 BFD_ASSERT ((insn & 0xff00) == 0xd100);
+                 insn = bfd_get_16 (input_bfd, contents + offset + 6);
+                 BFD_ASSERT (insn == 0x310c);
+                 insn = bfd_get_16 (input_bfd, contents + offset + 8);
+                 BFD_ASSERT (insn == 0x410b);
+                 insn = bfd_get_16 (input_bfd, contents + offset + 10);
+                 BFD_ASSERT (insn == 0x34cc);
+
+                 bfd_put_16 (output_bfd, 0x0012, contents + offset + 2);
+                 bfd_put_16 (output_bfd, 0x304c, contents + offset + 4);
+                 bfd_put_16 (output_bfd, 0x0009, contents + offset + 6);
+                 bfd_put_16 (output_bfd, 0x0009, contents + offset + 8);
+                 bfd_put_16 (output_bfd, 0x0009, contents + offset + 10);
+               }
+             else
+               {
+                 int index;
+
+                 /* IE->LE transition:
+                    mov.l 1f,r0; stc gbr,rN; mov.l @(r0,r12),rM;
+                    bra 2f; add ...; .align 2; 1: x@GOTTPOFF; 2:
+                    We change it into:
+                    mov.l .Ln,rM; stc gbr,rN; nop; ...;
+                    1: x@TPOFF; 2:.  */
+
+                 offset = rel->r_offset;
+                 BFD_ASSERT (offset >= 16);
+                 /* Size of IE instructions is 10 or 12.  */
+                 offset -= 10;
+                 insn = bfd_get_16 (input_bfd, contents + offset + 0);
+                 if ((insn & 0xf0ff) == 0x0012)
+                   {
+                     BFD_ASSERT (offset >= 2);
+                     offset -= 2;
+                     insn = bfd_get_16 (input_bfd, contents + offset + 0);
+                   }
+
+                 BFD_ASSERT ((insn & 0xff00) == 0xd000);
+                 index = insn & 0x00ff;
+                 insn = bfd_get_16 (input_bfd, contents + offset + 2);
+                 BFD_ASSERT ((insn & 0xf0ff) == 0x0012);
+                 insn = bfd_get_16 (input_bfd, contents + offset + 4);
+                 BFD_ASSERT ((insn & 0xf0ff) == 0x00ce);
+                 insn = 0xd000 | (insn & 0x0f00) | index;
+                 bfd_put_16 (output_bfd, insn, contents + offset + 0);
+                 bfd_put_16 (output_bfd, 0x0009, contents + offset + 4);
+               }
+
+             bfd_put_32 (output_bfd, tpoff (info, relocation),
+                         contents + rel->r_offset);
+             continue;
+           }
+
+         sgot = htab->sgot;
+         if (sgot == NULL)
+           abort ();
+
+         if (h != NULL)
+           off = h->got.offset;
+         else
+           {
+             if (local_got_offsets == NULL)
+               abort ();
+
+             off = local_got_offsets[r_symndx];
+           }
+
+         /* Relocate R_SH_TLS_IE_32 directly when statically linking.  */
+         if (r_type == R_SH_TLS_IE_32
+             && ! htab->root.dynamic_sections_created)
+           {
+             off &= ~1;
+             bfd_put_32 (output_bfd, tpoff (info, relocation),
+                         sgot->contents + off);
+             bfd_put_32 (output_bfd, sgot->output_offset + off,
+                         contents + rel->r_offset);
+             continue;
+           }
+
+         if ((off & 1) != 0)
+           off &= ~1;
+         else
+           {
+             Elf_Internal_Rela outrel;
+             bfd_byte *loc;
+             int dr_type, indx;
+
+             if (srelgot == NULL)
+               {
+                 srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
+                 BFD_ASSERT (srelgot != NULL);
+               }
+
+             outrel.r_offset = (sgot->output_section->vma
+                                + sgot->output_offset + off);
+
+             if (h == NULL || h->dynindx == -1)
+               indx = 0;
+             else
+               indx = h->dynindx;
+
+             dr_type = (r_type == R_SH_TLS_GD_32 ? R_SH_TLS_DTPMOD32 :
+                        R_SH_TLS_TPOFF32);
+             if (dr_type == R_SH_TLS_TPOFF32 && indx == 0)
+               outrel.r_addend = relocation - dtpoff_base (info);
+             else
+               outrel.r_addend = 0;
+             outrel.r_info = ELF32_R_INFO (indx, dr_type);
+             loc = srelgot->contents;
+             loc += srelgot->reloc_count++ * sizeof (Elf32_External_Rela);
+             bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
+
+             if (r_type == R_SH_TLS_GD_32)
+               {
+                 if (indx == 0)
+                   {
+                     bfd_put_32 (output_bfd,
+                                 relocation - dtpoff_base (info),
+                                 sgot->contents + off + 4);
+                   }
+                 else
+                   {
+                     outrel.r_info = ELF32_R_INFO (indx,
+                                                   R_SH_TLS_DTPOFF32);
+                     outrel.r_offset += 4;
+                     outrel.r_addend = 0;
+                     srelgot->reloc_count++;
+                     loc += sizeof (Elf32_External_Rela);
+                     bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
+                   }
+               }
+
+             if (h != NULL)
+               h->got.offset |= 1;
+             else
+               local_got_offsets[r_symndx] |= 1;
+           }
+
+         if (off >= (bfd_vma) -2)
+           abort ();
+
+         if (r_type == (int) ELF32_R_TYPE (rel->r_info))
+           relocation = sgot->output_offset + off;
+         else
+           {
+             bfd_vma offset;
+             unsigned short insn;
+
+             /* GD->IE transition:
+                  mov.l 1f,r4; mova 2f,r0; mov.l 2f,r1; add r0,r1;
+                  jsr @r1; add r12,r4; bra 3f; nop; .align 2;
+                  1: .long x$TLSGD; 2: .long __tls_get_addr@PLT; 3:
+                We change it into:
+                  mov.l 1f,r0; stc gbr,r4; mov.l @(r0,r12),r0; add r4,r0;
+                  nop; nop; bra 3f; nop; .align 2;
+                  1: .long x@TPOFF; 2:...; 3:.  */
+
+             offset = rel->r_offset;
+             BFD_ASSERT (offset >= 16);
+             /* Size of GD instructions is 16 or 18.  */
+             offset -= 16;
+             insn = bfd_get_16 (input_bfd, contents + offset + 0);
+             if ((insn & 0xff00) == 0xc700)
+               {
+                 BFD_ASSERT (offset >= 2);
+                 offset -= 2;
+                 insn = bfd_get_16 (input_bfd, contents + offset + 0);
+               }
+
+             BFD_ASSERT ((insn & 0xff00) == 0xd400);
+
+             /* Replace mov.l 1f,R4 with mov.l 1f,r0.  */
+             bfd_put_16 (output_bfd, insn & 0xf0ff, contents + offset);
+
+             insn = bfd_get_16 (input_bfd, contents + offset + 2);
+             BFD_ASSERT ((insn & 0xff00) == 0xc700);
+             insn = bfd_get_16 (input_bfd, contents + offset + 4);
+             BFD_ASSERT ((insn & 0xff00) == 0xd100);
+             insn = bfd_get_16 (input_bfd, contents + offset + 6);
+             BFD_ASSERT (insn == 0x310c);
+             insn = bfd_get_16 (input_bfd, contents + offset + 8);
+             BFD_ASSERT (insn == 0x410b);
+             insn = bfd_get_16 (input_bfd, contents + offset + 10);
+             BFD_ASSERT (insn == 0x34cc);
+
+             bfd_put_16 (output_bfd, 0x0412, contents + offset + 2);
+             bfd_put_16 (output_bfd, 0x00ce, contents + offset + 4);
+             bfd_put_16 (output_bfd, 0x304c, contents + offset + 6);
+             bfd_put_16 (output_bfd, 0x0009, contents + offset + 8);
+             bfd_put_16 (output_bfd, 0x0009, contents + offset + 10);
+
+             bfd_put_32 (output_bfd, sgot->output_offset + off,
+                         contents + rel->r_offset);
+
+             continue;
+         }
+
+         addend = rel->r_addend;
+
+         goto final_link_relocate;
+
+       case R_SH_TLS_LD_32:
+         if (! info->shared)
+           {
+             bfd_vma offset;
+             unsigned short insn;
+
+             /* LD->LE transition:
+                  mov.l 1f,r4; mova 2f,r0; mov.l 2f,r1; add r0,r1;
+                  jsr @r1; add r12,r4; bra 3f; nop; .align 2;
+                  1: .long x$TLSLD; 2: .long __tls_get_addr@PLT; 3:
+                We change it into:
+                  stc gbr,r0; nop; nop; nop;
+                  nop; nop; bra 3f; ...; 3:.  */
+
+             offset = rel->r_offset;
+             BFD_ASSERT (offset >= 16);
+             /* Size of LD instructions is 16 or 18.  */
+             offset -= 16;
+             insn = bfd_get_16 (input_bfd, contents + offset + 0);
+             if ((insn & 0xff00) == 0xc700)
+               {
+                 BFD_ASSERT (offset >= 2);
+                 offset -= 2;
+                 insn = bfd_get_16 (input_bfd, contents + offset + 0);
+               }
+
+             BFD_ASSERT ((insn & 0xff00) == 0xd400);
+             insn = bfd_get_16 (input_bfd, contents + offset + 2);
+             BFD_ASSERT ((insn & 0xff00) == 0xc700);
+             insn = bfd_get_16 (input_bfd, contents + offset + 4);
+             BFD_ASSERT ((insn & 0xff00) == 0xd100);
+             insn = bfd_get_16 (input_bfd, contents + offset + 6);
+             BFD_ASSERT (insn == 0x310c);
+             insn = bfd_get_16 (input_bfd, contents + offset + 8);
+             BFD_ASSERT (insn == 0x410b);
+             insn = bfd_get_16 (input_bfd, contents + offset + 10);
+             BFD_ASSERT (insn == 0x34cc);
+
+             bfd_put_16 (output_bfd, 0x0012, contents + offset + 0);
+             bfd_put_16 (output_bfd, 0x0009, contents + offset + 2);
+             bfd_put_16 (output_bfd, 0x0009, contents + offset + 4);
+             bfd_put_16 (output_bfd, 0x0009, contents + offset + 6);
+             bfd_put_16 (output_bfd, 0x0009, contents + offset + 8);
+             bfd_put_16 (output_bfd, 0x0009, contents + offset + 10);
+
+             continue;
+           }
+
+         sgot = htab->sgot;
+         if (sgot == NULL)
+           abort ();
+
+         off = htab->tls_ldm_got.offset;
+         if (off & 1)
+           off &= ~1;
+         else
+           {
+             Elf_Internal_Rela outrel;
+             bfd_byte *loc;
+
+             srelgot = htab->srelgot;
+             if (srelgot == NULL)
+               abort ();
+
+             outrel.r_offset = (sgot->output_section->vma
+                                + sgot->output_offset + off);
+             outrel.r_addend = 0;
+             outrel.r_info = ELF32_R_INFO (0, R_SH_TLS_DTPMOD32);
+             loc = srelgot->contents;
+             loc += srelgot->reloc_count++ * sizeof (Elf32_External_Rela);
+             bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
+             htab->tls_ldm_got.offset |= 1;
+           }
+
+         relocation = sgot->output_offset + off;
+         addend = rel->r_addend;
+
+         goto final_link_relocate;
+
+       case R_SH_TLS_LDO_32:
+         if (! info->shared)
+           relocation = tpoff (info, relocation);
+         else
+           relocation -= dtpoff_base (info);
+
+         addend = rel->r_addend;
+         goto final_link_relocate;
+
+       case R_SH_TLS_LE_32:
+         {
+           int indx;
+           Elf_Internal_Rela outrel;
+           bfd_byte *loc;
+
+           if (! info->shared)
+             {
+               relocation = tpoff (info, relocation);
+               addend = rel->r_addend;
+               goto final_link_relocate;
+             }
+
+           if (sreloc == NULL)
+             {
+               const char *name;
+
+               name = (bfd_elf_string_from_elf_section
+                       (input_bfd,
+                        elf_elfheader (input_bfd)->e_shstrndx,
+                        elf_section_data (input_section)->rel_hdr.sh_name));
+               if (name == NULL)
+                 return FALSE;
+
+               BFD_ASSERT (strncmp (name, ".rela", 5) == 0
+                           && strcmp (bfd_get_section_name (input_bfd,
+                                                            input_section),
+                                      name + 5) == 0);
+
+               sreloc = bfd_get_section_by_name (dynobj, name);
+               BFD_ASSERT (sreloc != NULL);
+             }
+
+           if (h == NULL || h->dynindx == -1)
+             indx = 0;
+           else
+             indx = h->dynindx;
+
+           outrel.r_offset = (input_section->output_section->vma
+                              + input_section->output_offset
+                              + rel->r_offset);
+           outrel.r_info = ELF32_R_INFO (indx, R_SH_TLS_TPOFF32);
+           if (indx == 0)
+             outrel.r_addend = relocation - dtpoff_base (info);
+           else
+             outrel.r_addend = 0;
+
+           loc = sreloc->contents;
+           loc += sreloc->reloc_count++ * sizeof (Elf32_External_Rela);
+           bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc);
+           continue;
+         }
        }
 
     relocation_done:
@@ -5031,21 +5696,21 @@ sh_elf_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)
-                     return false;
+                     return FALSE;
                    if (*name == '\0')
                      name = bfd_section_name (input_bfd, sec);
                  }
                if (! ((*info->callbacks->reloc_overflow)
                       (info, name, howto->name, (bfd_vma) 0,
                        input_bfd, input_section, rel->r_offset)))
-                 return false;
+                 return FALSE;
              }
              break;
            }
        }
     }
 
-  return true;
+  return TRUE;
 }
 
 /* This is a version of bfd_generic_get_relocated_section_contents
@@ -5053,12 +5718,12 @@ sh_elf_relocate_section (output_bfd, info, input_bfd, input_section,
 
 static bfd_byte *
 sh_elf_get_relocated_section_contents (output_bfd, link_info, link_order,
-                                      data, relocateable, symbols)
+                                      data, relocatable, symbols)
      bfd *output_bfd;
      struct bfd_link_info *link_info;
      struct bfd_link_order *link_order;
      bfd_byte *data;
-     boolean relocateable;
+     bfd_boolean relocatable;
      asymbol **symbols;
 {
   Elf_Internal_Shdr *symtab_hdr;
@@ -5070,11 +5735,11 @@ sh_elf_get_relocated_section_contents (output_bfd, link_info, link_order,
 
   /* We only need to handle the case of relaxing, or of having a
      particular set of section contents, specially.  */
-  if (relocateable
+  if (relocatable
       || elf_section_data (input_section)->this_hdr.contents == NULL)
     return bfd_generic_get_relocated_section_contents (output_bfd, link_info,
                                                       link_order, data,
-                                                      relocateable,
+                                                      relocatable,
                                                       symbols);
 
   symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
@@ -5089,9 +5754,9 @@ sh_elf_get_relocated_section_contents (output_bfd, link_info, link_order,
       Elf_Internal_Sym *isym, *isymend;
       bfd_size_type amt;
 
-      internal_relocs = (_bfd_elf32_link_read_relocs
+      internal_relocs = (_bfd_elf_link_read_relocs
                         (input_bfd, input_section, (PTR) NULL,
-                         (Elf_Internal_Rela *) NULL, false));
+                         (Elf_Internal_Rela *) NULL, FALSE));
       if (internal_relocs == NULL)
        goto error_return;
 
@@ -5157,13 +5822,42 @@ sh_elf_get_relocated_section_contents (output_bfd, link_info, link_order,
   return NULL;
 }
 
-static asection *
-sh_elf_gc_mark_hook (sec, info, rel, h, sym)
-     asection *sec;
-     struct bfd_link_info *info ATTRIBUTE_UNUSED;
-     Elf_Internal_Rela *rel;
-     struct elf_link_hash_entry *h;
-     Elf_Internal_Sym *sym;
+/* Return the base VMA address which should be subtracted from real addresses
+   when resolving @dtpoff relocation.
+   This is PT_TLS segment p_vaddr.  */
+
+static bfd_vma
+dtpoff_base (info)
+     struct bfd_link_info *info;
+{
+  /* If tls_segment is NULL, we should have signalled an error already.  */
+  if (elf_hash_table (info)->tls_segment == NULL)
+    return 0;
+  return elf_hash_table (info)->tls_segment->start;
+}
+
+/* Return the relocation value for R_SH_TLS_TPOFF32..  */
+
+static bfd_vma
+tpoff (info, address)
+     struct bfd_link_info *info;
+     bfd_vma address;
+{
+  /* If tls_segment is NULL, we should have signalled an error already.  */
+  if (elf_hash_table (info)->tls_segment == NULL)
+    return 0;
+  /* SH TLS ABI is variant I and static TLS block start just after tcbhead
+     structure which has 2 pointer fields.  */
+  return (address - dtpoff_base (info) + 8);
+}
+
+static asection *
+sh_elf_gc_mark_hook (sec, info, rel, h, sym)
+     asection *sec;
+     struct bfd_link_info *info ATTRIBUTE_UNUSED;
+     Elf_Internal_Rela *rel;
+     struct elf_link_hash_entry *h;
+     Elf_Internal_Sym *sym;
 {
   if (h != NULL)
     {
@@ -5201,7 +5895,7 @@ sh_elf_gc_mark_hook (sec, info, rel, h, sym)
 
 /* Update the got entry reference counts for the section being removed.  */
 
-static boolean
+static bfd_boolean
 sh_elf_gc_sweep_hook (abfd, info, sec, relocs)
      bfd *abfd;
      struct bfd_link_info *info;
@@ -5212,9 +5906,6 @@ sh_elf_gc_sweep_hook (abfd, info, sec, relocs)
   struct elf_link_hash_entry **sym_hashes;
   bfd_signed_vma *local_got_refcounts;
   const Elf_Internal_Rela *rel, *relend;
-  unsigned long r_symndx;
-  struct elf_link_hash_entry *h;
-  struct elf_sh_link_hash_entry *eh;
 
   elf_section_data (sec)->local_dynrel = NULL;
 
@@ -5224,121 +5915,169 @@ sh_elf_gc_sweep_hook (abfd, info, sec, relocs)
 
   relend = relocs + sec->reloc_count;
   for (rel = relocs; rel < relend; rel++)
-    switch (ELF32_R_TYPE (rel->r_info))
-      {
-      case R_SH_GOT32:
-      case R_SH_GOTOFF:
-      case R_SH_GOTPC:
+    {
+      unsigned long r_symndx;
+      unsigned int r_type;
+      struct elf_link_hash_entry *h = NULL;
 #ifdef INCLUDE_SHMEDIA
-      case R_SH_GOT_LOW16:
-      case R_SH_GOT_MEDLOW16:
-      case R_SH_GOT_MEDHI16:
-      case R_SH_GOT_HI16:
-      case R_SH_GOT10BY4:
-      case R_SH_GOT10BY8:
-      case R_SH_GOTOFF_LOW16:
-      case R_SH_GOTOFF_MEDLOW16:
-      case R_SH_GOTOFF_MEDHI16:
-      case R_SH_GOTOFF_HI16:
-      case R_SH_GOTPC_LOW16:
-      case R_SH_GOTPC_MEDLOW16:
-      case R_SH_GOTPC_MEDHI16:
-      case R_SH_GOTPC_HI16:
+      int seen_stt_datalabel = 0;
 #endif
-       r_symndx = ELF32_R_SYM (rel->r_info);
-       if (r_symndx >= symtab_hdr->sh_info)
-         {
-           h = sym_hashes[r_symndx - symtab_hdr->sh_info];
-           if (h->got.refcount > 0)
-             h->got.refcount -= 1;
-         }
-       else if (local_got_refcounts != NULL)
-         {
-           if (local_got_refcounts[r_symndx] > 0)
-             local_got_refcounts[r_symndx] -= 1;
-         }
-       break;
-
-      case R_SH_DIR32:
-      case R_SH_REL32:
-       r_symndx = ELF32_R_SYM (rel->r_info);
-       if (r_symndx >= symtab_hdr->sh_info)
-         {
-           struct elf_sh_link_hash_entry *eh;
-           struct elf_sh_dyn_relocs **pp;
-           struct elf_sh_dyn_relocs *p;
 
-           h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+      r_symndx = ELF32_R_SYM (rel->r_info);
+      if (r_symndx >= symtab_hdr->sh_info)
+       {
+         struct elf_sh_link_hash_entry *eh;
+         struct elf_sh_dyn_relocs **pp;
+         struct elf_sh_dyn_relocs *p;
 
-           if (!info->shared && h->plt.refcount > 0)
-             h->plt.refcount -= 1;
+         h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+#ifdef INCLUDE_SHMEDIA
+         while (h->root.type == bfd_link_hash_indirect
+                || h->root.type == bfd_link_hash_warning)
+           {
+             seen_stt_datalabel |= h->type == STT_DATALABEL;
+             h = (struct elf_link_hash_entry *) h->root.u.i.link;
+           }
+#endif
+         eh = (struct elf_sh_link_hash_entry *) h;
+         for (pp = &eh->dyn_relocs; (p = *pp) != NULL; pp = &p->next)
+           if (p->sec == sec)
+             {
+               /* Everything must go for SEC.  */
+               *pp = p->next;
+               break;
+             }
+       }
 
-           eh = (struct elf_sh_link_hash_entry *) h;
+      r_type = ELF32_R_TYPE (rel->r_info);
+      switch (sh_elf_optimized_tls_reloc (info, r_type, h != NULL))
+       {
+       case R_SH_TLS_LD_32:
+         if (sh_elf_hash_table (info)->tls_ldm_got.refcount > 0)
+           sh_elf_hash_table (info)->tls_ldm_got.refcount -= 1;
+         break;
 
-           for (pp = &eh->dyn_relocs; (p = *pp) != NULL; pp = &p->next)
-             if (p->sec == sec)
+       case R_SH_GOT32:
+       case R_SH_GOTOFF:
+       case R_SH_GOTPC:
+#ifdef INCLUDE_SHMEDIA
+       case R_SH_GOT_LOW16:
+       case R_SH_GOT_MEDLOW16:
+       case R_SH_GOT_MEDHI16:
+       case R_SH_GOT_HI16:
+       case R_SH_GOT10BY4:
+       case R_SH_GOT10BY8:
+       case R_SH_GOTOFF_LOW16:
+       case R_SH_GOTOFF_MEDLOW16:
+       case R_SH_GOTOFF_MEDHI16:
+       case R_SH_GOTOFF_HI16:
+       case R_SH_GOTPC_LOW16:
+       case R_SH_GOTPC_MEDLOW16:
+       case R_SH_GOTPC_MEDHI16:
+       case R_SH_GOTPC_HI16:
+#endif
+       case R_SH_TLS_GD_32:
+       case R_SH_TLS_IE_32:
+         if (h != NULL)
+           {
+#ifdef INCLUDE_SHMEDIA
+             if (seen_stt_datalabel)
                {
-                 if (ELF32_R_TYPE (rel->r_info) == R_SH_REL32)
-                   p->pc_count -= 1;
-                 p->count -= 1;
-                 if (p->count == 0)
-                   *pp = p->next;
-                 break;
+                 struct elf_sh_link_hash_entry *eh;
+                 eh = (struct elf_sh_link_hash_entry *) h;
+                 if (eh->datalabel_got.refcount > 0)
+                   eh->datalabel_got.refcount -= 1;
                }
-         }
-       break;
+             else
+#endif
+               if (h->got.refcount > 0)
+                 h->got.refcount -= 1;
+           }
+         else if (local_got_refcounts != NULL)
+           {
+#ifdef INCLUDE_SHMEDIA
+             if (rel->r_addend & 1)
+               {
+                 if (local_got_refcounts[symtab_hdr->sh_info + r_symndx] > 0)
+                   local_got_refcounts[symtab_hdr->sh_info + r_symndx] -= 1;
+               }
+             else
+#endif
+               if (local_got_refcounts[r_symndx] > 0)
+                 local_got_refcounts[r_symndx] -= 1;
+           }
+         break;
+
+       case R_SH_DIR32:
+       case R_SH_REL32:
+         if (info->shared)
+           break;
+         /* Fall thru */
 
-      case R_SH_PLT32:
+       case R_SH_PLT32:
 #ifdef INCLUDE_SHMEDIA
-      case R_SH_PLT_LOW16:
-      case R_SH_PLT_MEDLOW16:
-      case R_SH_PLT_MEDHI16:
-      case R_SH_PLT_HI16:
+       case R_SH_PLT_LOW16:
+       case R_SH_PLT_MEDLOW16:
+       case R_SH_PLT_MEDHI16:
+       case R_SH_PLT_HI16:
 #endif
-       r_symndx = ELF32_R_SYM (rel->r_info);
-       if (r_symndx >= symtab_hdr->sh_info)
-         {
-           h = sym_hashes[r_symndx - symtab_hdr->sh_info];
-           if (h->plt.refcount > 0)
-             h->plt.refcount -= 1;
-         }
-       break;
+         if (h != NULL)
+           {
+             if (h->plt.refcount > 0)
+               h->plt.refcount -= 1;
+           }
+         break;
 
-      case R_SH_GOTPLT32:
+       case R_SH_GOTPLT32:
 #ifdef INCLUDE_SHMEDIA
-      case R_SH_GOTPLT_LOW16:
-      case R_SH_GOTPLT_MEDLOW16:
-      case R_SH_GOTPLT_MEDHI16:
-      case R_SH_GOTPLT_HI16:
-      case R_SH_GOTPLT10BY4:
-      case R_SH_GOTPLT10BY8:
+       case R_SH_GOTPLT_LOW16:
+       case R_SH_GOTPLT_MEDLOW16:
+       case R_SH_GOTPLT_MEDHI16:
+       case R_SH_GOTPLT_HI16:
+       case R_SH_GOTPLT10BY4:
+       case R_SH_GOTPLT10BY8:
 #endif
-       r_symndx = ELF32_R_SYM (rel->r_info);
-       if (r_symndx >= symtab_hdr->sh_info)
-         {
-           h = sym_hashes[r_symndx - symtab_hdr->sh_info];
-           eh = (struct elf_sh_link_hash_entry *) h;
-           if (eh->gotplt_refcount > 0)
-             {
-               eh->gotplt_refcount -= 1;
-               if (h->plt.refcount > 0)
-                 h->plt.refcount -= 1;
-             }
-           else if (h->got.refcount > 0)
-             h->got.refcount -= 1;
-         }
-       else if (local_got_refcounts != NULL)
-         {
-           if (local_got_refcounts[r_symndx] > 0)
-             local_got_refcounts[r_symndx] -= 1;
-         }
-       break;
+         if (h != NULL)
+           {
+             struct elf_sh_link_hash_entry *eh;
+             eh = (struct elf_sh_link_hash_entry *) h;
+             if (eh->gotplt_refcount > 0)
+               {
+                 eh->gotplt_refcount -= 1;
+                 if (h->plt.refcount > 0)
+                   h->plt.refcount -= 1;
+               }
+#ifdef INCLUDE_SHMEDIA
+             else if (seen_stt_datalabel)
+               {
+                 if (eh->datalabel_got.refcount > 0)
+                   eh->datalabel_got.refcount -= 1;
+               }
+#endif
+             else if (h->got.refcount > 0)
+               h->got.refcount -= 1;
+           }
+         else if (local_got_refcounts != NULL)
+           {
+#ifdef INCLUDE_SHMEDIA
+             if (rel->r_addend & 1)
+               {
+                 if (local_got_refcounts[symtab_hdr->sh_info + r_symndx] > 0)
+                   local_got_refcounts[symtab_hdr->sh_info + r_symndx] -= 1;
+               }
+             else
+#endif
+               if (local_got_refcounts[r_symndx] > 0)
+                 local_got_refcounts[r_symndx] -= 1;
+           }
+         break;
 
-      default:
-       break;
-      }
+       default:
+         break;
+       }
+    }
 
-  return true;
+  return TRUE;
 }
 
 /* Copy the extra info we tack onto an elf_link_hash_entry.  */
@@ -5349,6 +6088,9 @@ sh_elf_copy_indirect_symbol (bed, dir, ind)
      struct elf_link_hash_entry *dir, *ind;
 {
   struct elf_sh_link_hash_entry *edir, *eind;
+#ifdef INCLUDE_SHMEDIA
+  bfd_signed_vma tmp;
+#endif
 
   edir = (struct elf_sh_link_hash_entry *) dir;
   eind = (struct elf_sh_link_hash_entry *) ind;
@@ -5387,15 +6129,65 @@ sh_elf_copy_indirect_symbol (bed, dir, ind)
     }
   edir->gotplt_refcount = eind->gotplt_refcount;
   eind->gotplt_refcount = 0;
+#ifdef INCLUDE_SHMEDIA
+  tmp = edir->datalabel_got.refcount;
+  if (tmp < 1)
+    {
+      edir->datalabel_got.refcount = eind->datalabel_got.refcount;
+      eind->datalabel_got.refcount = tmp;
+    }
+  else
+    BFD_ASSERT (eind->datalabel_got.refcount < 1);
+#endif
+
+  if (ind->root.type == bfd_link_hash_indirect
+      && dir->got.refcount <= 0)
+    {
+      edir->tls_type = eind->tls_type;
+      eind->tls_type = GOT_UNKNOWN;
+    }
+
+  if (ind->root.type != bfd_link_hash_indirect
+      && (dir->elf_link_hash_flags & ELF_LINK_HASH_DYNAMIC_ADJUSTED) != 0)
+    /* If called to transfer flags for a weakdef during processing
+       of elf_adjust_dynamic_symbol, don't copy ELF_LINK_NON_GOT_REF.
+       We clear it ourselves for ELIMINATE_COPY_RELOCS.  */
+    dir->elf_link_hash_flags |=
+      (ind->elf_link_hash_flags & (ELF_LINK_HASH_REF_DYNAMIC
+                                  | ELF_LINK_HASH_REF_REGULAR
+                                  | ELF_LINK_HASH_REF_REGULAR_NONWEAK));
+  else
+    _bfd_elf_link_hash_copy_indirect (bed, dir, ind);
+}
+
+static int
+sh_elf_optimized_tls_reloc (info, r_type, is_local)
+     struct bfd_link_info *info;
+     int r_type;
+     int is_local;
+{
+  if (info->shared)
+    return r_type;
+
+  switch (r_type)
+    {
+    case R_SH_TLS_GD_32:
+    case R_SH_TLS_IE_32:
+      if (is_local)
+       return R_SH_TLS_LE_32;
+      return R_SH_TLS_IE_32;
+    case R_SH_TLS_LD_32:
+      return R_SH_TLS_LE_32;
+    }
 
-  _bfd_elf_link_hash_copy_indirect (bed, dir, ind);
+  return r_type;
 }
 
 /* Look through the relocs for a section during the first phase.
    Since we don't do .gots or .plts, we just need to consider the
    virtual table relocs for gc.  */
 
-static boolean
+static bfd_boolean
 sh_elf_check_relocs (abfd, info, sec, relocs)
      bfd *abfd;
      struct bfd_link_info *info;
@@ -5412,13 +6204,15 @@ sh_elf_check_relocs (abfd, info, sec, relocs)
   asection *sgot;
   asection *srelgot;
   asection *sreloc;
+  unsigned int r_type;
+  int tls_type, old_tls_type;
 
   sgot = NULL;
   srelgot = NULL;
   sreloc = NULL;
 
-  if (info->relocateable)
-    return true;
+  if (info->relocatable)
+    return TRUE;
 
   symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
   sym_hashes = elf_sym_hashes (abfd);
@@ -5435,17 +6229,42 @@ sh_elf_check_relocs (abfd, info, sec, relocs)
     {
       struct elf_link_hash_entry *h;
       unsigned long r_symndx;
+#ifdef INCLUDE_SHMEDIA
+      int seen_stt_datalabel = 0;
+#endif
 
       r_symndx = ELF32_R_SYM (rel->r_info);
+      r_type = ELF32_R_TYPE (rel->r_info);
+
       if (r_symndx < symtab_hdr->sh_info)
        h = NULL;
       else
-       h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+       {
+         h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+#ifdef INCLUDE_SHMEDIA
+         while (h->root.type == bfd_link_hash_indirect
+                || h->root.type == bfd_link_hash_warning)
+           {
+             seen_stt_datalabel |= h->type == STT_DATALABEL;
+             h = (struct elf_link_hash_entry *) h->root.u.i.link;
+           }
+#endif
+       }
+
+      r_type = sh_elf_optimized_tls_reloc (info, r_type, h == NULL);
+      if (! info->shared
+         && r_type == R_SH_TLS_IE_32
+         && h != NULL
+         && h->root.type != bfd_link_hash_undefined
+         && h->root.type != bfd_link_hash_undefweak
+         && (h->dynindx == -1
+             || (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)))
+       r_type = R_SH_TLS_LE_32;
 
       /* Some relocs require a global offset table.  */
       if (htab->sgot == NULL)
        {
-         switch (ELF32_R_TYPE (rel->r_info))
+         switch (r_type)
            {
            case R_SH_GOTPLT32:
            case R_SH_GOT32:
@@ -5473,10 +6292,13 @@ sh_elf_check_relocs (abfd, info, sec, relocs)
            case R_SH_GOTPC_MEDHI16:
            case R_SH_GOTPC_HI16:
 #endif
+           case R_SH_TLS_GD_32:
+           case R_SH_TLS_LD_32:
+           case R_SH_TLS_IE_32:
              if (dynobj == NULL)
                htab->root.dynobj = dynobj = abfd;
              if (! create_got_section (dynobj, info))
-               return false;
+               return FALSE;
              break;
 
            default:
@@ -5484,23 +6306,29 @@ sh_elf_check_relocs (abfd, info, sec, relocs)
            }
        }
 
-      switch (ELF32_R_TYPE (rel->r_info))
+      switch (r_type)
        {
          /* This relocation describes the C++ object vtable hierarchy.
             Reconstruct it for later use during GC.  */
        case R_SH_GNU_VTINHERIT:
          if (!_bfd_elf32_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_SH_GNU_VTENTRY:
          if (!_bfd_elf32_gc_record_vtentry (abfd, sec, h, rel->r_addend))
-           return false;
+           return FALSE;
          break;
 
+       case R_SH_TLS_IE_32:
+         if (info->shared)
+           info->flags |= DF_STATIC_TLS;
+
+         /* FALLTHROUGH */
        force_got:
+       case R_SH_TLS_GD_32:
        case R_SH_GOT32:
 #ifdef INCLUDE_SHMEDIA
        case R_SH_GOT_LOW16:
@@ -5510,8 +6338,34 @@ sh_elf_check_relocs (abfd, info, sec, relocs)
        case R_SH_GOT10BY4:
        case R_SH_GOT10BY8:
 #endif
+         switch (r_type)
+           {
+           default:
+             tls_type = GOT_NORMAL;
+             break;
+           case R_SH_TLS_GD_32:
+             tls_type = GOT_TLS_GD;
+             break;
+           case R_SH_TLS_IE_32:
+             tls_type = GOT_TLS_IE;
+             break;
+           }
+
          if (h != NULL)
-           h->got.refcount += 1;
+           {
+#ifdef INCLUDE_SHMEDIA
+             if (seen_stt_datalabel)
+               {
+                 struct elf_sh_link_hash_entry *eh
+                   = (struct elf_sh_link_hash_entry *) h;
+
+                 eh->datalabel_got.refcount += 1;
+               }
+             else
+#endif
+               h->got.refcount += 1;
+             old_tls_type = sh_elf_hash_entry (h)->tls_type;
+           }
          else
            {
              bfd_signed_vma *local_got_refcounts;
@@ -5530,14 +6384,59 @@ sh_elf_check_relocs (abfd, info, sec, relocs)
                     codelabel local GOT offsets.  */
                  size *= 2;
 #endif
+                 size += symtab_hdr->sh_info;
                  local_got_refcounts = ((bfd_signed_vma *)
                                         bfd_zalloc (abfd, size));
                  if (local_got_refcounts == NULL)
-                   return false;
+                   return FALSE;
                  elf_local_got_refcounts (abfd) = local_got_refcounts;
+#ifdef         INCLUDE_SHMEDIA
+                 /* Take care of both the datalabel and codelabel local
+                    GOT offsets.  */
+                 sh_elf_local_got_tls_type (abfd)
+                   = (char *) (local_got_refcounts + 2 * symtab_hdr->sh_info);
+#else
+                 sh_elf_local_got_tls_type (abfd)
+                   = (char *) (local_got_refcounts + symtab_hdr->sh_info);
+#endif
+               }
+#ifdef INCLUDE_SHMEDIA
+             if (rel->r_addend & 1)
+               local_got_refcounts[symtab_hdr->sh_info + r_symndx] += 1;
+             else
+#endif
+               local_got_refcounts[r_symndx] += 1;
+             old_tls_type = sh_elf_local_got_tls_type (abfd) [r_symndx];
+           }
+
+         /* If a TLS symbol is accessed using IE at least once,
+            there is no point to use dynamic model for it.  */
+         if (old_tls_type != tls_type && old_tls_type != GOT_UNKNOWN
+             && (old_tls_type != GOT_TLS_GD || tls_type != GOT_TLS_IE))
+           {
+             if (old_tls_type == GOT_TLS_IE && tls_type == GOT_TLS_GD)
+               tls_type = GOT_TLS_IE;
+             else
+               {
+                 (*_bfd_error_handler)
+                   (_("%s: `%s' accessed both as normal and thread local symbol"),
+                    bfd_archive_filename (abfd), h->root.root.string);
+                 return FALSE;
                }
-             local_got_refcounts[r_symndx] += 1;
            }
+
+         if (old_tls_type != tls_type)
+           {
+             if (h != NULL)
+               sh_elf_hash_entry (h)->tls_type = tls_type;
+             else
+               sh_elf_local_got_tls_type (abfd) [r_symndx] = tls_type;
+           }
+
+         break;
+
+       case R_SH_TLS_LD_32:
+         sh_elf_hash_table(info)->tls_ldm_got.refcount += 1;
          break;
 
        case R_SH_GOTPLT32:
@@ -5620,7 +6519,7 @@ sh_elf_check_relocs (abfd, info, sec, relocs)
             symbol.  */
          if ((info->shared
               && (sec->flags & SEC_ALLOC) != 0
-              && (ELF32_R_TYPE (rel->r_info) != R_SH_REL32
+              && (r_type != R_SH_REL32
                   || (h != NULL
                       && (! info->symbolic
                           || h->root.type == bfd_link_hash_defweak
@@ -5651,7 +6550,7 @@ sh_elf_check_relocs (abfd, info, sec, relocs)
                           elf_elfheader (abfd)->e_shstrndx,
                           elf_section_data (sec)->rel_hdr.sh_name));
                  if (name == NULL)
-                   return false;
+                   return FALSE;
 
                  BFD_ASSERT (strncmp (name, ".rela", 5) == 0
                              && strcmp (bfd_get_section_name (abfd, sec),
@@ -5670,7 +6569,7 @@ sh_elf_check_relocs (abfd, info, sec, relocs)
                      if (sreloc == NULL
                          || ! bfd_set_section_flags (dynobj, sreloc, flags)
                          || ! bfd_set_section_alignment (dynobj, sreloc, 2))
-                       return false;
+                       return FALSE;
                    }
                  if (sec->flags & SEC_READONLY)
                    info->flags |= DF_TEXTREL;
@@ -5689,7 +6588,7 @@ sh_elf_check_relocs (abfd, info, sec, relocs)
                  s = bfd_section_from_r_symndx (abfd, &htab->sym_sec,
                                                 sec, r_symndx);
                  if (s == NULL)
-                   return false;
+                   return FALSE;
 
                  head = ((struct elf_sh_dyn_relocs **)
                          &elf_section_data (s)->local_dynrel);
@@ -5701,7 +6600,7 @@ sh_elf_check_relocs (abfd, info, sec, relocs)
                  bfd_size_type amt = sizeof (*p);
                  p = ((struct elf_sh_dyn_relocs *) bfd_alloc (dynobj, amt));
                  if (p == NULL)
-                   return false;
+                   return FALSE;
                  p->next = *head;
                  *head = p;
                  p->sec = sec;
@@ -5710,19 +6609,36 @@ sh_elf_check_relocs (abfd, info, sec, relocs)
                }
 
              p->count += 1;
-             if (ELF32_R_TYPE (rel->r_info) == R_SH_REL32)
+             if (r_type == R_SH_REL32)
                p->pc_count += 1;
            }
 
          break;
+
+       case R_SH_TLS_LE_32:
+         if (info->shared)
+           {
+             (*_bfd_error_handler) (_("%s: TLS local exec code cannot be linked into shared objects"),
+                                    bfd_archive_filename (abfd));
+             return FALSE;
+           }
+
+         break;
+
+       case R_SH_TLS_LDO_32:
+         /* Nothing to do.  */
+         break;
+
+       default:
+         break;
        }
     }
 
-  return true;
+  return TRUE;
 }
 
 #ifndef sh_elf_set_mach_from_flags
-static boolean
+static bfd_boolean
 sh_elf_set_mach_from_flags (abfd)
      bfd *abfd;
 {
@@ -5736,6 +6652,9 @@ sh_elf_set_mach_from_flags (abfd)
     case EF_SH2:
       bfd_default_set_arch_mach (abfd, bfd_arch_sh, bfd_mach_sh2);
       break;
+    case EF_SH2E:
+      bfd_default_set_arch_mach (abfd, bfd_arch_sh, bfd_mach_sh2e);
+      break;
     case EF_SH_DSP:
       bfd_default_set_arch_mach (abfd, bfd_arch_sh, bfd_mach_sh_dsp);
       break;
@@ -5753,16 +6672,16 @@ sh_elf_set_mach_from_flags (abfd)
       bfd_default_set_arch_mach (abfd, bfd_arch_sh, bfd_mach_sh4);
       break;
     default:
-      return false;
+      return FALSE;
     }
-  return true;
+  return TRUE;
 }
 #endif /* not sh_elf_set_mach_from_flags */
 
 #ifndef sh_elf_set_private_flags
 /* Function to keep SH specific file flags.  */
 
-static boolean
+static bfd_boolean
 sh_elf_set_private_flags (abfd, flags)
      bfd *abfd;
      flagword flags;
@@ -5771,7 +6690,7 @@ sh_elf_set_private_flags (abfd, flags)
              || elf_elfheader (abfd)->e_flags == flags);
 
   elf_elfheader (abfd)->e_flags = flags;
-  elf_flags_init (abfd) = true;
+  elf_flags_init (abfd) = TRUE;
   return sh_elf_set_mach_from_flags (abfd);
 }
 #endif /* not sh_elf_set_private_flags */
@@ -5779,14 +6698,14 @@ sh_elf_set_private_flags (abfd, flags)
 #ifndef sh_elf_copy_private_data
 /* Copy backend specific data from one object module to another */
 
-static boolean
+static bfd_boolean
 sh_elf_copy_private_data (ibfd, obfd)
      bfd * ibfd;
      bfd * obfd;
 {
   if (   bfd_get_flavour (ibfd) != bfd_target_elf_flavour
       || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
-    return true;
+    return TRUE;
 
   return sh_elf_set_private_flags (obfd, elf_elfheader (ibfd)->e_flags);
 }
@@ -5796,7 +6715,7 @@ sh_elf_copy_private_data (ibfd, obfd)
 /* This routine checks for linking big and little endian objects
    together, and for linking sh-dsp with sh3e / sh4 objects.  */
 
-static boolean
+static bfd_boolean
 sh_elf_merge_private_data (ibfd, obfd)
      bfd *ibfd;
      bfd *obfd;
@@ -5804,16 +6723,16 @@ sh_elf_merge_private_data (ibfd, obfd)
   flagword old_flags, new_flags;
 
   if (! _bfd_generic_verify_endian_match (ibfd, obfd))
-    return false;
+    return FALSE;
 
   if (   bfd_get_flavour (ibfd) != bfd_target_elf_flavour
       || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
-    return true;
+    return TRUE;
 
   if (! elf_flags_init (obfd))
     {
       /* This happens when ld starts out with a 'blank' output file.  */
-      elf_flags_init (obfd) = true;
+      elf_flags_init (obfd) = TRUE;
       elf_elfheader (obfd)->e_flags = EF_SH1;
     }
   old_flags = elf_elfheader (obfd)->e_flags;
@@ -5827,7 +6746,7 @@ sh_elf_merge_private_data (ibfd, obfd)
         EF_SH_HAS_DSP (new_flags) ? "dsp" : "floating point",
         EF_SH_HAS_DSP (new_flags) ? "floating point" : "dsp");
       bfd_set_error (bfd_error_bad_value);
-      return false;
+      return FALSE;
     }
   elf_elfheader (obfd)->e_flags = EF_SH_MERGE_MACH (old_flags, new_flags);
 
@@ -5835,10 +6754,33 @@ sh_elf_merge_private_data (ibfd, obfd)
 }
 #endif /* not sh_elf_merge_private_data */
 
+/* Override the generic function because we need to store sh_elf_obj_tdata
+   as the specific tdata.  We set also the machine architecture from flags
+   here.  */
+
+static bfd_boolean
+sh_elf_object_p (abfd)
+  bfd *abfd;
+{
+  struct sh_elf_obj_tdata *new_tdata;
+  bfd_size_type amt = sizeof (struct sh_elf_obj_tdata);
+
+  if (!sh_elf_set_mach_from_flags (abfd))
+    return FALSE;
+
+  /* Allocate our special target data.  */
+  new_tdata = bfd_zalloc (abfd, amt);
+  if (new_tdata == NULL)
+    return FALSE;
+  new_tdata->root = *abfd->tdata.elf_obj_data;
+  abfd->tdata.any = new_tdata;
+  return TRUE;
+}
+
 /* Finish up dynamic symbol handling.  We set the contents of various
    dynamic sections here.  */
 
-static boolean
+static bfd_boolean
 sh_elf_finish_dynamic_symbol (output_bfd, info, h, sym)
      bfd *output_bfd;
      struct bfd_link_info *info;
@@ -5860,6 +6802,7 @@ sh_elf_finish_dynamic_symbol (output_bfd, info, h, sym)
       bfd_vma plt_index;
       bfd_vma got_offset;
       Elf_Internal_Rela rel;
+      bfd_byte *loc;
 
       /* This symbol has an entry in the procedure linkage table.  Set
         it up.  */
@@ -5979,9 +6922,8 @@ sh_elf_finish_dynamic_symbol (output_bfd, info, h, sym)
 #ifdef GOT_BIAS
       rel.r_addend = GOT_BIAS;
 #endif
-      bfd_elf32_swap_reloca_out (output_bfd, &rel,
-                               ((Elf32_External_Rela *) srel->contents
-                                + plt_index));
+      loc = srel->contents + plt_index * sizeof (Elf32_External_Rela);
+      bfd_elf32_swap_reloca_out (output_bfd, &rel, loc);
 
       if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
        {
@@ -5991,11 +6933,14 @@ sh_elf_finish_dynamic_symbol (output_bfd, info, h, sym)
        }
     }
 
-  if (h->got.offset != (bfd_vma) -1)
+  if (h->got.offset != (bfd_vma) -1
+      && sh_elf_hash_entry (h)->tls_type != GOT_TLS_GD
+      && sh_elf_hash_entry (h)->tls_type != GOT_TLS_IE)
     {
       asection *sgot;
       asection *srel;
       Elf_Internal_Rela rel;
+      bfd_byte *loc;
 
       /* This symbol has an entry in the global offset table.  Set it
         up.  */
@@ -6031,16 +6976,70 @@ sh_elf_finish_dynamic_symbol (output_bfd, info, h, sym)
          rel.r_addend = 0;
        }
 
-      bfd_elf32_swap_reloca_out (output_bfd, &rel,
-                                ((Elf32_External_Rela *) srel->contents
-                                 + srel->reloc_count));
-      ++srel->reloc_count;
+      loc = srel->contents;
+      loc += srel->reloc_count++ * sizeof (Elf32_External_Rela);
+      bfd_elf32_swap_reloca_out (output_bfd, &rel, loc);
     }
 
+#ifdef INCLUDE_SHMEDIA
+  {
+    struct elf_sh_link_hash_entry *eh;
+
+    eh = (struct elf_sh_link_hash_entry *) h;
+    if (eh->datalabel_got.offset != (bfd_vma) -1)
+      {
+       asection *sgot;
+       asection *srel;
+       Elf_Internal_Rela rel;
+       bfd_byte *loc;
+
+       /* This symbol has a datalabel entry in the global offset table.
+          Set it up.  */
+
+       sgot = htab->sgot;
+       srel = htab->srelgot;
+       BFD_ASSERT (sgot != NULL && srel != NULL);
+
+       rel.r_offset = (sgot->output_section->vma
+                       + sgot->output_offset
+                       + (eh->datalabel_got.offset &~ (bfd_vma) 1));
+
+       /* If this is a static link, or it is a -Bsymbolic link and the
+          symbol is defined locally or was forced to be local because
+          of a version file, we just want to emit a RELATIVE reloc.
+          The entry in the global offset table will already have been
+          initialized in the relocate_section function.  */
+       if (info->shared
+           && (info->symbolic
+               || h->dynindx == -1
+               || (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL))
+           && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR))
+         {
+           rel.r_info = ELF32_R_INFO (0, R_SH_RELATIVE);
+           rel.r_addend = (h->root.u.def.value
+                           + h->root.u.def.section->output_section->vma
+                           + h->root.u.def.section->output_offset);
+         }
+       else
+         {
+           bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents
+                       + eh->datalabel_got.offset);
+           rel.r_info = ELF32_R_INFO (h->dynindx, R_SH_GLOB_DAT);
+           rel.r_addend = 0;
+         }
+
+       loc = srel->contents;
+       loc += srel->reloc_count++ * sizeof (Elf32_External_Rela);
+       bfd_elf32_swap_reloca_out (output_bfd, &rel, loc);
+      }
+  }
+#endif
+
   if ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_COPY) != 0)
     {
       asection *s;
       Elf_Internal_Rela rel;
+      bfd_byte *loc;
 
       /* This symbol needs a copy reloc.  Set it up.  */
 
@@ -6057,10 +7056,8 @@ sh_elf_finish_dynamic_symbol (output_bfd, info, h, sym)
                      + h->root.u.def.section->output_offset);
       rel.r_info = ELF32_R_INFO (h->dynindx, R_SH_COPY);
       rel.r_addend = 0;
-      bfd_elf32_swap_reloca_out (output_bfd, &rel,
-                                ((Elf32_External_Rela *) s->contents
-                                 + s->reloc_count));
-      ++s->reloc_count;
+      loc = s->contents + s->reloc_count++ * sizeof (Elf32_External_Rela);
+      bfd_elf32_swap_reloca_out (output_bfd, &rel, loc);
     }
 
   /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute.  */
@@ -6068,12 +7065,12 @@ sh_elf_finish_dynamic_symbol (output_bfd, info, h, sym)
       || strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0)
     sym->st_shndx = SHN_ABS;
 
-  return true;
+  return TRUE;
 }
 
 /* Finish up the dynamic sections.  */
 
-static boolean
+static bfd_boolean
 sh_elf_finish_dynamic_sections (output_bfd, info)
      bfd *output_bfd;
      struct bfd_link_info *info;
@@ -6126,7 +7123,7 @@ sh_elf_finish_dynamic_sections (output_bfd, info)
                  struct elf_link_hash_entry *h;
 
                  h = elf_link_hash_lookup (&htab->root, name,
-                                           false, false, true);
+                                           FALSE, FALSE, TRUE);
                  if (h != NULL && (h->other & STO_SH5_ISA32))
                    {
                      dyn.d_un.d_val |= 1;
@@ -6242,7 +7239,7 @@ sh_elf_finish_dynamic_sections (output_bfd, info)
       elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 4;
     }
 
-  return true;
+  return TRUE;
 }
 
 static enum elf_reloc_type_class
@@ -6262,7 +7259,71 @@ sh_elf_reloc_type_class (rela)
     }
 }
 
-#ifndef ELF_ARCH
+/* Support for Linux core dump NOTE sections.  */
+static bfd_boolean
+elf32_shlin_grok_prstatus (abfd, note)
+     bfd *abfd;
+     Elf_Internal_Note *note;
+{
+  int offset;
+  unsigned int raw_size;
+
+  switch (note->descsz)
+    {
+      default:
+       return FALSE;
+
+      case 168:                /* Linux/SH */
+       /* pr_cursig */
+       elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
+
+       /* pr_pid */
+       elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 24);
+
+       /* pr_reg */
+       offset = 72;
+       raw_size = 92;
+
+       break;
+    }
+
+  /* Make a ".reg/999" section.  */
+  return _bfd_elfcore_make_pseudosection (abfd, ".reg",
+                                         raw_size, note->descpos + offset);
+}
+
+static bfd_boolean
+elf32_shlin_grok_psinfo (abfd, note)
+     bfd *abfd;
+     Elf_Internal_Note *note;
+{
+  switch (note->descsz)
+    {
+      default:
+       return FALSE;
+
+      case 124:                /* Linux/SH elf_prpsinfo */
+       elf_tdata (abfd)->core_program
+        = _bfd_elfcore_strndup (abfd, note->descdata + 28, 16);
+       elf_tdata (abfd)->core_command
+        = _bfd_elfcore_strndup (abfd, note->descdata + 44, 80);
+    }
+
+  /* Note that for some reason, a spurious space is tacked
+     onto the end of the args in some (at least one anyway)
+     implementations, so strip it off if it exists.  */
+
+  {
+    char *command = elf_tdata (abfd)->core_command;
+    int n = strlen (command);
+
+    if (0 < n && command[n - 1] == ' ')
+      command[n - 1] = '\0';
+  }
+
+  return TRUE;
+}
+
 #define TARGET_BIG_SYM         bfd_elf32_sh_vec
 #define TARGET_BIG_NAME                "elf32-sh"
 #define TARGET_LITTLE_SYM      bfd_elf32_shl_vec
@@ -6272,7 +7333,6 @@ sh_elf_reloc_type_class (rela)
 #define ELF_MAXPAGESIZE                128
 
 #define elf_symbol_leading_char '_'
-#endif /* ELF_ARCH */
 
 #define bfd_elf32_bfd_reloc_type_lookup        sh_elf_reloc_type_lookup
 #define elf_info_to_howto              sh_elf_info_to_howto
@@ -6280,7 +7340,8 @@ sh_elf_reloc_type_class (rela)
 #define elf_backend_relocate_section   sh_elf_relocate_section
 #define bfd_elf32_bfd_get_relocated_section_contents \
                                        sh_elf_get_relocated_section_contents
-#define elf_backend_object_p           sh_elf_set_mach_from_flags
+#define bfd_elf32_mkobject             sh_elf_mkobject
+#define elf_backend_object_p           sh_elf_object_p
 #define bfd_elf32_bfd_set_private_bfd_flags \
                                        sh_elf_set_private_flags
 #define bfd_elf32_bfd_copy_private_bfd_data \
@@ -6315,7 +7376,46 @@ sh_elf_reloc_type_class (rela)
 #define elf_backend_got_header_size    12
 #define elf_backend_plt_header_size    PLT_ENTRY_SIZE
 
-#ifndef ELF32_SH_C_INCLUDED
+#ifndef INCLUDE_SHMEDIA
+
+#include "elf32-target.h"
+
+/* NetBSD support.  */
+#undef TARGET_BIG_SYM
+#define        TARGET_BIG_SYM                  bfd_elf32_shnbsd_vec
+#undef TARGET_BIG_NAME
+#define        TARGET_BIG_NAME                 "elf32-sh-nbsd"
+#undef TARGET_LITTLE_SYM
+#define        TARGET_LITTLE_SYM               bfd_elf32_shlnbsd_vec
+#undef TARGET_LITTLE_NAME
+#define        TARGET_LITTLE_NAME              "elf32-shl-nbsd"
+#undef ELF_MAXPAGESIZE
+#define        ELF_MAXPAGESIZE                 0x10000
+#undef elf_symbol_leading_char
+#define        elf_symbol_leading_char         0
+#undef elf32_bed
+#define        elf32_bed                       elf32_sh_nbsd_bed
+
+#include "elf32-target.h"
+
+
+/* Linux support.  */
+#undef TARGET_BIG_SYM
+#define        TARGET_BIG_SYM                  bfd_elf32_shblin_vec
+#undef TARGET_BIG_NAME
+#define        TARGET_BIG_NAME                 "elf32-shbig-linux"
+#undef TARGET_LITTLE_SYM
+#define        TARGET_LITTLE_SYM               bfd_elf32_shlin_vec
+#undef TARGET_LITTLE_NAME
+#define        TARGET_LITTLE_NAME              "elf32-sh-linux"
+
+#undef elf_backend_grok_prstatus
+#define        elf_backend_grok_prstatus       elf32_shlin_grok_prstatus
+#undef elf_backend_grok_psinfo
+#define        elf_backend_grok_psinfo         elf32_shlin_grok_psinfo
+#undef elf32_bed
+#define        elf32_bed                       elf32_sh_lin_bed
+
 #include "elf32-target.h"
-#endif
 
+#endif /* INCLUDE_SHMEDIA */
This page took 0.109137 seconds and 4 git commands to generate.