1999-06-16 10:11:50 +08:00
|
|
|
|
/* Motorola MCore specific support for 32-bit ELF
|
2007-03-07 16:54:35 +08:00
|
|
|
|
Copyright 1994, 1995, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
|
|
|
|
|
2007 Free Software Foundation, Inc.
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-07-01 19:16:33 +08:00
|
|
|
|
This file is part of BFD, the Binary File Descriptor library.
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-07-01 19:16:33 +08:00
|
|
|
|
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
|
2007-07-03 22:26:43 +08:00
|
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
2005-07-01 19:16:33 +08:00
|
|
|
|
(at your option) any later version.
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-07-01 19:16:33 +08:00
|
|
|
|
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.
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-07-01 19:16:33 +08:00
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program; if not, write to the Free Software
|
2007-07-03 22:26:43 +08:00
|
|
|
|
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
|
|
|
|
|
MA 02110-1301, USA. */
|
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
/* This file is based on a preliminary RCE ELF ABI. The
|
|
|
|
|
information may not match the final RCE ELF ABI. */
|
|
|
|
|
|
|
|
|
|
#include "sysdep.h"
|
2007-04-26 22:47:00 +08:00
|
|
|
|
#include "bfd.h"
|
1999-05-03 15:29:11 +08:00
|
|
|
|
#include "bfdlink.h"
|
|
|
|
|
#include "libbfd.h"
|
|
|
|
|
#include "elf-bfd.h"
|
|
|
|
|
#include "elf/mcore.h"
|
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
2002-07-23 20:29:33 +08:00
|
|
|
|
/* RELA relocs are used here... */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-07-01 19:16:33 +08:00
|
|
|
|
/* Function to set whether a module needs the -mrelocatable bit set. */
|
|
|
|
|
|
|
|
|
|
static bfd_boolean
|
|
|
|
|
mcore_elf_set_private_flags (bfd * abfd, flagword flags)
|
|
|
|
|
{
|
|
|
|
|
BFD_ASSERT (! elf_flags_init (abfd)
|
|
|
|
|
|| elf_elfheader (abfd)->e_flags == flags);
|
|
|
|
|
|
|
|
|
|
elf_elfheader (abfd)->e_flags = flags;
|
|
|
|
|
elf_flags_init (abfd) = TRUE;
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Merge backend specific data from an object file to the output
|
|
|
|
|
object file when linking. */
|
|
|
|
|
|
|
|
|
|
static bfd_boolean
|
|
|
|
|
mcore_elf_merge_private_bfd_data (bfd * ibfd, bfd * obfd)
|
|
|
|
|
{
|
|
|
|
|
flagword old_flags;
|
|
|
|
|
flagword new_flags;
|
|
|
|
|
|
|
|
|
|
/* Check if we have the same endianess. */
|
|
|
|
|
if (! _bfd_generic_verify_endian_match (ibfd, obfd))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
if ( bfd_get_flavour (ibfd) != bfd_target_elf_flavour
|
|
|
|
|
|| bfd_get_flavour (obfd) != bfd_target_elf_flavour)
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
new_flags = elf_elfheader (ibfd)->e_flags;
|
|
|
|
|
old_flags = elf_elfheader (obfd)->e_flags;
|
|
|
|
|
|
|
|
|
|
if (! elf_flags_init (obfd))
|
|
|
|
|
{
|
|
|
|
|
/* First call, no flags set. */
|
|
|
|
|
elf_flags_init (obfd) = TRUE;
|
|
|
|
|
elf_elfheader (obfd)->e_flags = new_flags;
|
|
|
|
|
}
|
|
|
|
|
else if (new_flags == old_flags)
|
|
|
|
|
/* Compatible flags are OK. */
|
|
|
|
|
;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* FIXME */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Don't pretend we can deal with unsupported relocs. */
|
|
|
|
|
|
|
|
|
|
static bfd_reloc_status_type
|
|
|
|
|
mcore_elf_unsupported_reloc (bfd * abfd,
|
|
|
|
|
arelent * reloc_entry,
|
|
|
|
|
asymbol * symbol ATTRIBUTE_UNUSED,
|
|
|
|
|
PTR data ATTRIBUTE_UNUSED,
|
|
|
|
|
asection * input_section ATTRIBUTE_UNUSED,
|
|
|
|
|
bfd * output_bfd ATTRIBUTE_UNUSED,
|
|
|
|
|
char ** error_message ATTRIBUTE_UNUSED)
|
|
|
|
|
{
|
|
|
|
|
BFD_ASSERT (reloc_entry->howto != (reloc_howto_type *)0);
|
|
|
|
|
|
|
|
|
|
_bfd_error_handler (_("%B: Relocation %s (%d) is not currently supported.\n"),
|
|
|
|
|
abfd,
|
|
|
|
|
reloc_entry->howto->name,
|
|
|
|
|
reloc_entry->howto->type);
|
|
|
|
|
|
|
|
|
|
return bfd_reloc_notsupported;
|
|
|
|
|
}
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
static reloc_howto_type * mcore_elf_howto_table [(int) R_MCORE_max];
|
|
|
|
|
|
|
|
|
|
static reloc_howto_type mcore_elf_howto_raw[] =
|
|
|
|
|
{
|
|
|
|
|
/* This reloc does nothing. */
|
|
|
|
|
HOWTO (R_MCORE_NONE, /* type */
|
|
|
|
|
0, /* rightshift */
|
|
|
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
1999-06-16 10:11:50 +08:00
|
|
|
|
32, /* bitsize */
|
2002-11-30 16:39:46 +08:00
|
|
|
|
FALSE, /* pc_relative */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
0, /* bitpos */
|
|
|
|
|
complain_overflow_bitfield, /* complain_on_overflow */
|
1999-06-16 10:11:50 +08:00
|
|
|
|
NULL, /* special_function */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
"R_MCORE_NONE", /* name */
|
2002-11-30 16:39:46 +08:00
|
|
|
|
FALSE, /* partial_inplace */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
0, /* src_mask */
|
|
|
|
|
0, /* dst_mask */
|
2002-11-30 16:39:46 +08:00
|
|
|
|
FALSE), /* pcrel_offset */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
/* A standard 32 bit relocation. */
|
|
|
|
|
HOWTO (R_MCORE_ADDR32, /* type */
|
|
|
|
|
0, /* rightshift */
|
|
|
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
|
|
|
|
32, /* bitsize */
|
2002-11-30 16:39:46 +08:00
|
|
|
|
FALSE, /* pc_relative */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
0, /* bitpos */
|
|
|
|
|
complain_overflow_bitfield, /* complain_on_overflow */
|
|
|
|
|
bfd_elf_generic_reloc, /* special_function */
|
2003-11-28 02:49:39 +08:00
|
|
|
|
"ADDR32", /* name *//* For compatibility with coff/pe port. */
|
2002-11-30 16:39:46 +08:00
|
|
|
|
FALSE, /* partial_inplace */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
0x0, /* src_mask */
|
|
|
|
|
0xffffffff, /* dst_mask */
|
2002-11-30 16:39:46 +08:00
|
|
|
|
FALSE), /* pcrel_offset */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
/* 8 bits + 2 zero bits; jmpi/jsri/lrw instructions.
|
2000-12-07 02:59:48 +08:00
|
|
|
|
Should not appear in object files. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
HOWTO (R_MCORE_PCRELIMM8BY4, /* type */
|
|
|
|
|
2, /* rightshift */
|
|
|
|
|
1, /* size (0 = byte, 1 = short, 2 = long) */
|
|
|
|
|
8, /* bitsize */
|
2002-11-30 16:39:46 +08:00
|
|
|
|
TRUE, /* pc_relative */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
0, /* bitpos */
|
|
|
|
|
complain_overflow_bitfield, /* complain_on_overflow */
|
|
|
|
|
mcore_elf_unsupported_reloc, /* special_function */
|
|
|
|
|
"R_MCORE_PCRELIMM8BY4",/* name */
|
2002-11-30 16:39:46 +08:00
|
|
|
|
FALSE, /* partial_inplace */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
0, /* src_mask */
|
|
|
|
|
0, /* dst_mask */
|
2002-11-30 16:39:46 +08:00
|
|
|
|
TRUE), /* pcrel_offset */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2000-12-07 02:59:48 +08:00
|
|
|
|
/* bsr/bt/bf/br instructions; 11 bits + 1 zero bit
|
1999-05-03 15:29:11 +08:00
|
|
|
|
Span 2k instructions == 4k bytes.
|
|
|
|
|
Only useful pieces at the relocated address are the opcode (5 bits) */
|
|
|
|
|
HOWTO (R_MCORE_PCRELIMM11BY2,/* type */
|
|
|
|
|
1, /* rightshift */
|
|
|
|
|
1, /* size (0 = byte, 1 = short, 2 = long) */
|
|
|
|
|
11, /* bitsize */
|
2002-11-30 16:39:46 +08:00
|
|
|
|
TRUE, /* pc_relative */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
0, /* bitpos */
|
|
|
|
|
complain_overflow_signed, /* complain_on_overflow */
|
|
|
|
|
bfd_elf_generic_reloc, /* special_function */
|
|
|
|
|
"R_MCORE_PCRELIMM11BY2",/* name */
|
2002-11-30 16:39:46 +08:00
|
|
|
|
FALSE, /* partial_inplace */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
0x0, /* src_mask */
|
|
|
|
|
0x7ff, /* dst_mask */
|
2002-11-30 16:39:46 +08:00
|
|
|
|
TRUE), /* pcrel_offset */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2000-12-07 02:59:48 +08:00
|
|
|
|
/* 4 bits + 1 zero bit; 'loopt' instruction only; unsupported. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
HOWTO (R_MCORE_PCRELIMM4BY2, /* type */
|
|
|
|
|
1, /* rightshift */
|
|
|
|
|
1, /* size (0 = byte, 1 = short, 2 = long) */
|
|
|
|
|
4, /* bitsize */
|
2002-11-30 16:39:46 +08:00
|
|
|
|
TRUE, /* pc_relative */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
0, /* bitpos */
|
|
|
|
|
complain_overflow_bitfield, /* complain_on_overflow */
|
|
|
|
|
mcore_elf_unsupported_reloc,/* special_function */
|
|
|
|
|
"R_MCORE_PCRELIMM4BY2",/* name */
|
2002-11-30 16:39:46 +08:00
|
|
|
|
FALSE, /* partial_inplace */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
0, /* src_mask */
|
|
|
|
|
0, /* dst_mask */
|
2002-11-30 16:39:46 +08:00
|
|
|
|
TRUE), /* pcrel_offset */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2000-12-07 02:59:48 +08:00
|
|
|
|
/* 32-bit pc-relative. Eventually this will help support PIC code. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
HOWTO (R_MCORE_PCREL32, /* type */
|
|
|
|
|
0, /* rightshift */
|
|
|
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
|
|
|
|
32, /* bitsize */
|
2002-11-30 16:39:46 +08:00
|
|
|
|
TRUE, /* pc_relative */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
0, /* bitpos */
|
|
|
|
|
complain_overflow_bitfield, /* complain_on_overflow */
|
|
|
|
|
bfd_elf_generic_reloc, /* special_function */
|
|
|
|
|
"R_MCORE_PCREL32", /* name */
|
2002-11-30 16:39:46 +08:00
|
|
|
|
FALSE, /* partial_inplace */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
0x0, /* src_mask */
|
|
|
|
|
0xffffffff, /* dst_mask */
|
2002-11-30 16:39:46 +08:00
|
|
|
|
TRUE), /* pcrel_offset */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
/* Like PCRELIMM11BY2, this relocation indicates that there is a
|
|
|
|
|
'jsri' at the specified address. There is a separate relocation
|
2000-12-07 02:59:48 +08:00
|
|
|
|
entry for the literal pool entry that it references, but we
|
1999-05-03 15:29:11 +08:00
|
|
|
|
might be able to change the jsri to a bsr if the target turns out
|
|
|
|
|
to be close enough [even though we won't reclaim the literal pool
|
|
|
|
|
entry, we'll get some runtime efficiency back]. Note that this
|
2000-12-07 02:59:48 +08:00
|
|
|
|
is a relocation that we are allowed to safely ignore. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
HOWTO (R_MCORE_PCRELJSR_IMM11BY2,/* type */
|
|
|
|
|
1, /* rightshift */
|
|
|
|
|
1, /* size (0 = byte, 1 = short, 2 = long) */
|
|
|
|
|
11, /* bitsize */
|
2002-11-30 16:39:46 +08:00
|
|
|
|
TRUE, /* pc_relative */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
0, /* bitpos */
|
|
|
|
|
complain_overflow_signed, /* complain_on_overflow */
|
|
|
|
|
bfd_elf_generic_reloc, /* special_function */
|
|
|
|
|
"R_MCORE_PCRELJSR_IMM11BY2", /* name */
|
2002-11-30 16:39:46 +08:00
|
|
|
|
FALSE, /* partial_inplace */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
0x0, /* src_mask */
|
|
|
|
|
0x7ff, /* dst_mask */
|
2002-11-30 16:39:46 +08:00
|
|
|
|
TRUE), /* pcrel_offset */
|
2000-12-07 02:59:48 +08:00
|
|
|
|
|
2005-07-01 19:16:33 +08:00
|
|
|
|
/* GNU extension to record C++ vtable hierarchy. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
HOWTO (R_MCORE_GNU_VTINHERIT, /* type */
|
|
|
|
|
0, /* rightshift */
|
|
|
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
|
|
|
|
0, /* bitsize */
|
2002-11-30 16:39:46 +08:00
|
|
|
|
FALSE, /* pc_relative */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
0, /* bitpos */
|
|
|
|
|
complain_overflow_dont, /* complain_on_overflow */
|
|
|
|
|
NULL, /* special_function */
|
|
|
|
|
"R_MCORE_GNU_VTINHERIT", /* name */
|
2002-11-30 16:39:46 +08:00
|
|
|
|
FALSE, /* partial_inplace */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
0, /* src_mask */
|
|
|
|
|
0, /* dst_mask */
|
2002-11-30 16:39:46 +08:00
|
|
|
|
FALSE), /* pcrel_offset */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
2005-07-01 19:16:33 +08:00
|
|
|
|
/* GNU extension to record C++ vtable member usage. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
HOWTO (R_MCORE_GNU_VTENTRY, /* type */
|
|
|
|
|
0, /* rightshift */
|
|
|
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
|
|
|
|
0, /* bitsize */
|
2002-11-30 16:39:46 +08:00
|
|
|
|
FALSE, /* pc_relative */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
0, /* bitpos */
|
|
|
|
|
complain_overflow_dont,/* complain_on_overflow */
|
|
|
|
|
_bfd_elf_rel_vtable_reloc_fn, /* special_function */
|
|
|
|
|
"R_MCORE_GNU_VTENTRY", /* name */
|
2002-11-30 16:39:46 +08:00
|
|
|
|
FALSE, /* partial_inplace */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
0, /* src_mask */
|
|
|
|
|
0, /* dst_mask */
|
2002-11-30 16:39:46 +08:00
|
|
|
|
FALSE), /* pcrel_offset */
|
2000-12-07 02:59:48 +08:00
|
|
|
|
|
1999-05-15 23:38:13 +08:00
|
|
|
|
HOWTO (R_MCORE_RELATIVE, /* type */
|
|
|
|
|
0, /* rightshift */
|
|
|
|
|
2, /* size (0 = byte, 1 = short, 2 = long) */
|
|
|
|
|
32, /* bitsize */
|
2002-11-30 16:39:46 +08:00
|
|
|
|
FALSE, /* pc_relative */
|
1999-05-15 23:38:13 +08:00
|
|
|
|
0, /* bitpos */
|
|
|
|
|
complain_overflow_signed, /* complain_on_overflow */
|
|
|
|
|
NULL, /* special_function */
|
|
|
|
|
"R_MCORE_RELATIVE", /* name */
|
2002-11-30 16:39:46 +08:00
|
|
|
|
TRUE, /* partial_inplace */
|
1999-05-15 23:38:13 +08:00
|
|
|
|
0xffffffff, /* src_mask */
|
|
|
|
|
0xffffffff, /* dst_mask */
|
2002-11-30 16:39:46 +08:00
|
|
|
|
FALSE) /* pcrel_offset */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#ifndef NUM_ELEM
|
|
|
|
|
#define NUM_ELEM(a) (sizeof (a) / sizeof (a)[0])
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* Initialize the mcore_elf_howto_table, so that linear accesses can be done. */
|
|
|
|
|
static void
|
2005-07-01 19:16:33 +08:00
|
|
|
|
mcore_elf_howto_init (void)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
|
|
for (i = NUM_ELEM (mcore_elf_howto_raw); i--;)
|
|
|
|
|
{
|
|
|
|
|
unsigned int type;
|
2000-12-07 02:59:48 +08:00
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
|
type = mcore_elf_howto_raw[i].type;
|
2000-12-07 02:59:48 +08:00
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
|
BFD_ASSERT (type < NUM_ELEM (mcore_elf_howto_table));
|
2000-12-07 02:59:48 +08:00
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
|
mcore_elf_howto_table [type] = & mcore_elf_howto_raw [i];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static reloc_howto_type *
|
2005-07-01 19:16:33 +08:00
|
|
|
|
mcore_elf_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
|
|
|
|
|
bfd_reloc_code_real_type code)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
|
|
|
|
enum elf_mcore_reloc_type mcore_reloc = R_MCORE_NONE;
|
|
|
|
|
|
|
|
|
|
switch (code)
|
|
|
|
|
{
|
|
|
|
|
case BFD_RELOC_NONE: mcore_reloc = R_MCORE_NONE; break;
|
|
|
|
|
case BFD_RELOC_32: mcore_reloc = R_MCORE_ADDR32; break;
|
|
|
|
|
case BFD_RELOC_MCORE_PCREL_IMM8BY4: mcore_reloc = R_MCORE_PCRELIMM8BY4; break;
|
|
|
|
|
case BFD_RELOC_MCORE_PCREL_IMM11BY2: mcore_reloc = R_MCORE_PCRELIMM11BY2; break;
|
|
|
|
|
case BFD_RELOC_MCORE_PCREL_IMM4BY2: mcore_reloc = R_MCORE_PCRELIMM4BY2; break;
|
|
|
|
|
case BFD_RELOC_32_PCREL: mcore_reloc = R_MCORE_PCREL32; break;
|
|
|
|
|
case BFD_RELOC_MCORE_PCREL_JSR_IMM11BY2: mcore_reloc = R_MCORE_PCRELJSR_IMM11BY2; break;
|
|
|
|
|
case BFD_RELOC_VTABLE_INHERIT: mcore_reloc = R_MCORE_GNU_VTINHERIT; break;
|
|
|
|
|
case BFD_RELOC_VTABLE_ENTRY: mcore_reloc = R_MCORE_GNU_VTENTRY; break;
|
1999-05-15 23:38:13 +08:00
|
|
|
|
case BFD_RELOC_RVA: mcore_reloc = R_MCORE_RELATIVE; break;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
default:
|
2005-07-01 19:16:33 +08:00
|
|
|
|
return NULL;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
2005-07-01 19:16:33 +08:00
|
|
|
|
if (! mcore_elf_howto_table [R_MCORE_PCRELIMM8BY4])
|
|
|
|
|
/* Initialize howto table if needed. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
mcore_elf_howto_init ();
|
|
|
|
|
|
|
|
|
|
return mcore_elf_howto_table [(int) mcore_reloc];
|
|
|
|
|
};
|
|
|
|
|
|
2007-03-26 20:23:03 +08:00
|
|
|
|
static reloc_howto_type *
|
|
|
|
|
mcore_elf_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
|
|
|
|
|
const char *r_name)
|
|
|
|
|
{
|
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
|
|
for (i = 0;
|
|
|
|
|
i < sizeof (mcore_elf_howto_raw) / sizeof (mcore_elf_howto_raw[0]);
|
|
|
|
|
i++)
|
|
|
|
|
if (mcore_elf_howto_raw[i].name != NULL
|
|
|
|
|
&& strcasecmp (mcore_elf_howto_raw[i].name, r_name) == 0)
|
|
|
|
|
return &mcore_elf_howto_raw[i];
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
|
/* Set the howto pointer for a RCE ELF reloc. */
|
2005-07-01 19:16:33 +08:00
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
|
static void
|
2005-07-01 19:16:33 +08:00
|
|
|
|
mcore_elf_info_to_howto (bfd * abfd ATTRIBUTE_UNUSED,
|
|
|
|
|
arelent * cache_ptr,
|
|
|
|
|
Elf_Internal_Rela * dst)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2005-07-01 19:16:33 +08:00
|
|
|
|
if (! mcore_elf_howto_table [R_MCORE_PCRELIMM8BY4])
|
|
|
|
|
/* Initialize howto table if needed. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
mcore_elf_howto_init ();
|
|
|
|
|
|
|
|
|
|
BFD_ASSERT (ELF32_R_TYPE (dst->r_info) < (unsigned int) R_MCORE_max);
|
2000-12-07 02:59:48 +08:00
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
|
cache_ptr->howto = mcore_elf_howto_table [ELF32_R_TYPE (dst->r_info)];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* The RELOCATE_SECTION function is called by the ELF backend linker
|
|
|
|
|
to handle the relocations for a section.
|
|
|
|
|
|
|
|
|
|
The relocs are always passed as Rela structures; if the section
|
|
|
|
|
actually uses Rel structures, the r_addend field will always be
|
|
|
|
|
zero.
|
|
|
|
|
|
|
|
|
|
This function is responsible for adjust the section contents as
|
|
|
|
|
necessary, and (if using Rela relocs and generating a
|
2003-06-25 14:40:27 +08:00
|
|
|
|
relocatable output file) adjusting the reloc addend as
|
1999-05-03 15:29:11 +08:00
|
|
|
|
necessary.
|
|
|
|
|
|
|
|
|
|
This function does not have to worry about setting the reloc
|
|
|
|
|
address or the reloc symbol index.
|
|
|
|
|
|
|
|
|
|
LOCAL_SYMS is a pointer to the swapped in local symbols.
|
|
|
|
|
|
|
|
|
|
LOCAL_SECTIONS is an array giving the section in the input file
|
|
|
|
|
corresponding to the st_shndx field of each local symbol.
|
|
|
|
|
|
|
|
|
|
The global hash table entry for the global symbols can be found
|
|
|
|
|
via elf_sym_hashes (input_bfd).
|
|
|
|
|
|
2003-06-25 14:40:27 +08:00
|
|
|
|
When generating relocatable output, this function must handle
|
1999-05-03 15:29:11 +08:00
|
|
|
|
STB_LOCAL/STT_SECTION symbols specially. The output symbol is
|
|
|
|
|
going to be the section symbol corresponding to the output
|
|
|
|
|
section, which means that the addend must be adjusted
|
|
|
|
|
accordingly. */
|
|
|
|
|
|
2002-11-30 16:39:46 +08:00
|
|
|
|
static bfd_boolean
|
2005-07-01 19:16:33 +08:00
|
|
|
|
mcore_elf_relocate_section (bfd * output_bfd,
|
|
|
|
|
struct bfd_link_info * info,
|
|
|
|
|
bfd * input_bfd,
|
|
|
|
|
asection * input_section,
|
|
|
|
|
bfd_byte * contents,
|
|
|
|
|
Elf_Internal_Rela * relocs,
|
|
|
|
|
Elf_Internal_Sym * local_syms,
|
|
|
|
|
asection ** local_sections)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2002-11-30 16:39:46 +08:00
|
|
|
|
Elf_Internal_Shdr * symtab_hdr = & elf_tdata (input_bfd)->symtab_hdr;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
struct elf_link_hash_entry ** sym_hashes = elf_sym_hashes (input_bfd);
|
2002-11-30 16:39:46 +08:00
|
|
|
|
Elf_Internal_Rela * rel = relocs;
|
|
|
|
|
Elf_Internal_Rela * relend = relocs + input_section->reloc_count;
|
|
|
|
|
bfd_boolean ret = TRUE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
bfd/
* bfd.c (_bfd_default_error_handler): Handle %A and %B.
(bfd_archive_filename, bfd_get_section_ident): Delete.
* ecofflink.c (bfd_ecoff_debug_accumulate_other): Don't call
bfd_archive_filename.
* elflink.c (elf_link_input_bfd): Don't use callbacks->error_handler
to warn about symbols in discarded sections. Use _bfd_error_handler.
* aout-adobe.c (aout_adobe_callback): See below.
* aout-cris.c (swap_ext_reloc_in): ..
* coff-arm.c (find_thumb_glue, find_arm_glue,
coff_arm_relocate_section, bfd_arm_process_before_allocation,
coff_arm_merge_private_bfd_data, _bfd_coff_arm_set_private_flags,
coff_arm_copy_private_bfd_data): ..
* coff-i860.c (i860_reloc_processing): ..
* coff-mcore.c (mcore_coff_unsupported_reloc,
coff_mcore_relocate_section): ..
* coff-ppc.c (coff_ppc_relocate_section): ..
* coff-rs6000.c (xcoff_create_csect_from_smclas
* coff-sh.c (sh_relax_section, sh_relax_delete_bytes,
sh_swap_insns, sh_relocate_section): ..
* coff-tic54x.c (tic54x_reloc_processing): ..
* coff-tic80.c (coff_tic80_relocate_section): ..
* coff64-rs6000.c (xcoff64_create_csect_from_smclas): ..
* coffcode.h (styp_to_sec_flags, coff_slurp_line_table,
coff_slurp_symbol_table, coff_classify_symbol,
coff_slurp_reloc_table): ..
* coffgen.c (_bfd_coff_read_string_table): ..
* cofflink.c (coff_link_add_symbols, _bfd_coff_link_input_bfd,
_bfd_coff_generic_relocate_section): ..
* cpu-arm.c (bfd_arm_merge_machines): ..
* cpu-sh.c (sh_merge_bfd_arch): ..
* elf-hppa.h (elf_hppa_relocate_section): ..
* elf.c (bfd_elf_string_from_elf_section, setup_group,
_bfd_elf_setup_group_pointers, bfd_section_from_shdr,
assign_section_numbers, _bfd_elf_symbol_from_bfd_symbol,
copy_private_bfd_data, _bfd_elf_validate_reloc): ..
* elf32-arm.h (find_thumb_glue, find_arm_glue,
bfd_elf32_arm_process_before_allocation, elf32_thumb_to_arm_stub,
elf32_arm_to_thumb_stub, elf32_arm_final_link_relocate,
elf32_arm_relocate_section, elf32_arm_set_private_flags,
elf32_arm_copy_private_bfd_data, elf32_arm_merge_private_bfd_data): ..
* elf32-cris.c (cris_elf_relocate_section, cris_elf_check_relocs,
cris_elf_merge_private_bfd_data
* elf32-frv.c (elf32_frv_relocate_section, elf32_frv_check_relocs): ..
* elf32-gen.c (elf32_generic_link_add_symbols): ..
* elf32-hppa.c (hppa_add_stub, hppa_build_one_stub,
elf32_hppa_check_relocs, get_local_syms, final_link_relocate,
elf32_hppa_relocate_section): ..
* elf32-i370.c (i370_elf_merge_private_bfd_data,
i370_elf_check_relocs, i370_elf_relocate_section): ..
* elf32-i386.c (elf_i386_info_to_howto_rel, elf_i386_check_relocs,
elf_i386_relocate_section): ..
* elf32-m32r.c (m32r_elf_relocate_section,
m32r_elf_merge_private_bfd_data): ..
* elf32-m68hc1x.c (m68hc12_add_stub,
_bfd_m68hc11_elf_merge_private_bfd_data): ..
* elf32-m68k.c (elf_m68k_relocate_section): ..
* elf32-mcore.c (mcore_elf_unsupported_reloc,
mcore_elf_relocate_section): ..
* elf32-ppc.c (ppc_elf_merge_private_bfd_data, bad_shared_reloc,
ppc_elf_check_relocs, ppc_elf_relocate_section,
ppc_elf_begin_write_processing): ..
* elf32-s390.c (elf_s390_check_relocs, invalid_tls_insn,
elf_s390_relocate_section): ..
* elf32-sh-symbian.c (sh_symbian_import_as,
sh_symbian_process_embedded_commands,
sh_symbian_relocate_section): ..
* elf32-sh.c (sh_elf_relax_section, sh_elf_relax_delete_bytes,
sh_elf_swap_insns, sh_elf_relocate_section, sh_elf_check_relocs,
sh_elf_merge_private_data): ..
* elf32-sparc.c (elf32_sparc_check_relocs,
elf32_sparc_relocate_section,
elf32_sparc_merge_private_bfd_data): ..
* elf32-v850.c (v850_elf_check_relocs,
v850_elf_merge_private_bfd_data): ..
* elf32-xtensa.c (elf_xtensa_check_relocs,
elf_xtensa_relocate_section, elf_xtensa_merge_private_bfd_data): ..
* elf64-alpha.c (elf64_alpha_relax_with_lituse,
elf64_alpha_relax_got_load, elf64_alpha_size_got_sections,
elf64_alpha_relocate_section_r, elf64_alpha_relocate_section): ..
* elf64-gen.c (elf64_generic_link_add_symbols): ..
* elf64-ppc.c (ppc64_elf_merge_private_bfd_data, ppc_add_stub,
ppc64_elf_check_relocs, ppc64_elf_edit_opd,
ppc64_elf_relocate_section): ..
* elf64-s390.c (elf_s390_check_relocs, invalid_tls_insn,
elf_s390_relocate_section): ..
* elf64-sh64.c (sh_elf64_relocate_section): ..
* elf64-sparc.c (sparc64_elf_check_relocs,
sparc64_elf_add_symbol_hook, sparc64_elf_relocate_section,
sparc64_elf_merge_private_bfd_data): ..
* elf64-x86-64.c (elf64_x86_64_check_relocs,
elf64_x86_64_relocate_section): ..
* elflink.c (_bfd_elf_add_default_symbol,
_bfd_elf_link_assign_sym_version, elf_link_read_relocs_from_section,
_bfd_elf_link_output_relocs, elf_link_add_object_symbols,
bfd_elf_size_dynamic_sections, elf_link_output_extsym,
elf_get_linked_section_vma, elf_fixup_link_order,
bfd_elf_final_link, bfd_elf_gc_record_vtinherit,
bfd_elf_gc_record_vtinherit, _bfd_elf_section_already_linked): ..
* elfxx-ia64.c (elfNN_ia64_relax_section,
elfNN_ia64_relocate_section, elfNN_ia64_merge_private_bfd_data): ..
* elfxx-mips.c (mips_elf_perform_relocation,
_bfd_mips_elf_check_relocs,
_bfd_mips_elf_merge_private_bfd_data): ..
* ieee.c (ieee_slurp_external_symbols): ..
* ihex.c (ihex_bad_byte, ihex_scan, ihex_read_section): ..
* libbfd.c (_bfd_generic_verify_endian_match): ..
* linker.c (_bfd_generic_link_add_one_symbol,
_bfd_generic_section_already_linked): ..
* pdp11.c (translate_to_native_sym_flags): ..
* pe-mips.c (coff_pe_mips_relocate_section): ..
* peicode.h (pe_ILF_build_a_bfd): ..
* srec.c (srec_bad_byte): ..
* stabs.c (_bfd_link_section_stabs): ..
* xcofflink.c (xcoff_link_add_symbols, xcoff_link_input_bfd): ..
Replace all uses of bfd_archive_filename and bfd_get_section_ident
with corresponding %B and %A in _bfd_error_handler format string.
Replace occurrences of "fprintf (stderr," with _bfd_error_handler
calls to use %A and %B. Fix "against symbol .. from section" and
similar error messages. Combine multiple _bfd_error_handler calls
where they were separated due to bfd_archive_filename deficiencies.
* bfd-in2.h: Regenerate.
include/
* bfdlink.h (struct bfd_link_callbacks): Remove "error_handler".
(LD_DEFINITION_IN_DISCARDED_SECTION): Delete.
ld/
* ldmain.c (link_callbacks): Remove "error_handler".
* ldmisc.c: Include elf-bfd.h.
(vfinfo): Sort comment. Handle %A. Use %A instead of
bfd_get_section_indent.
(error_handler): Delete.
* ldmisc.h (error_handler): Delete declaration.
2004-08-13 11:16:01 +08:00
|
|
|
|
_bfd_error_handler
|
|
|
|
|
("mcore_elf_relocate_section called for %B section %A, %ld relocations%s",
|
|
|
|
|
input_bfd,
|
|
|
|
|
input_section,
|
|
|
|
|
(long) input_section->reloc_count,
|
|
|
|
|
(info->relocatable) ? " (relocatable)" : "");
|
1999-05-03 15:29:11 +08:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
if (! mcore_elf_howto_table [R_MCORE_PCRELIMM8BY4]) /* Initialize howto table if needed */
|
|
|
|
|
mcore_elf_howto_init ();
|
|
|
|
|
|
|
|
|
|
for (; rel < relend; rel++)
|
|
|
|
|
{
|
|
|
|
|
enum elf_mcore_reloc_type r_type = (enum elf_mcore_reloc_type) ELF32_R_TYPE (rel->r_info);
|
|
|
|
|
bfd_vma offset = rel->r_offset;
|
|
|
|
|
bfd_vma addend = rel->r_addend;
|
|
|
|
|
bfd_reloc_status_type r = bfd_reloc_other;
|
2005-07-01 19:16:33 +08:00
|
|
|
|
asection * sec = NULL;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
reloc_howto_type * howto;
|
|
|
|
|
bfd_vma relocation;
|
2005-07-01 19:16:33 +08:00
|
|
|
|
Elf_Internal_Sym * sym = NULL;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
unsigned long r_symndx;
|
2005-07-01 19:16:33 +08:00
|
|
|
|
struct elf_link_hash_entry * h = NULL;
|
2000-03-02 04:39:07 +08:00
|
|
|
|
unsigned short oldinst = 0;
|
2000-12-07 02:59:48 +08:00
|
|
|
|
|
2005-07-01 19:16:33 +08:00
|
|
|
|
/* Unknown relocation handling. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
if ((unsigned) r_type >= (unsigned) R_MCORE_max
|
|
|
|
|
|| ! mcore_elf_howto_table [(int)r_type])
|
|
|
|
|
{
|
bfd/
* bfd.c (_bfd_default_error_handler): Handle %A and %B.
(bfd_archive_filename, bfd_get_section_ident): Delete.
* ecofflink.c (bfd_ecoff_debug_accumulate_other): Don't call
bfd_archive_filename.
* elflink.c (elf_link_input_bfd): Don't use callbacks->error_handler
to warn about symbols in discarded sections. Use _bfd_error_handler.
* aout-adobe.c (aout_adobe_callback): See below.
* aout-cris.c (swap_ext_reloc_in): ..
* coff-arm.c (find_thumb_glue, find_arm_glue,
coff_arm_relocate_section, bfd_arm_process_before_allocation,
coff_arm_merge_private_bfd_data, _bfd_coff_arm_set_private_flags,
coff_arm_copy_private_bfd_data): ..
* coff-i860.c (i860_reloc_processing): ..
* coff-mcore.c (mcore_coff_unsupported_reloc,
coff_mcore_relocate_section): ..
* coff-ppc.c (coff_ppc_relocate_section): ..
* coff-rs6000.c (xcoff_create_csect_from_smclas
* coff-sh.c (sh_relax_section, sh_relax_delete_bytes,
sh_swap_insns, sh_relocate_section): ..
* coff-tic54x.c (tic54x_reloc_processing): ..
* coff-tic80.c (coff_tic80_relocate_section): ..
* coff64-rs6000.c (xcoff64_create_csect_from_smclas): ..
* coffcode.h (styp_to_sec_flags, coff_slurp_line_table,
coff_slurp_symbol_table, coff_classify_symbol,
coff_slurp_reloc_table): ..
* coffgen.c (_bfd_coff_read_string_table): ..
* cofflink.c (coff_link_add_symbols, _bfd_coff_link_input_bfd,
_bfd_coff_generic_relocate_section): ..
* cpu-arm.c (bfd_arm_merge_machines): ..
* cpu-sh.c (sh_merge_bfd_arch): ..
* elf-hppa.h (elf_hppa_relocate_section): ..
* elf.c (bfd_elf_string_from_elf_section, setup_group,
_bfd_elf_setup_group_pointers, bfd_section_from_shdr,
assign_section_numbers, _bfd_elf_symbol_from_bfd_symbol,
copy_private_bfd_data, _bfd_elf_validate_reloc): ..
* elf32-arm.h (find_thumb_glue, find_arm_glue,
bfd_elf32_arm_process_before_allocation, elf32_thumb_to_arm_stub,
elf32_arm_to_thumb_stub, elf32_arm_final_link_relocate,
elf32_arm_relocate_section, elf32_arm_set_private_flags,
elf32_arm_copy_private_bfd_data, elf32_arm_merge_private_bfd_data): ..
* elf32-cris.c (cris_elf_relocate_section, cris_elf_check_relocs,
cris_elf_merge_private_bfd_data
* elf32-frv.c (elf32_frv_relocate_section, elf32_frv_check_relocs): ..
* elf32-gen.c (elf32_generic_link_add_symbols): ..
* elf32-hppa.c (hppa_add_stub, hppa_build_one_stub,
elf32_hppa_check_relocs, get_local_syms, final_link_relocate,
elf32_hppa_relocate_section): ..
* elf32-i370.c (i370_elf_merge_private_bfd_data,
i370_elf_check_relocs, i370_elf_relocate_section): ..
* elf32-i386.c (elf_i386_info_to_howto_rel, elf_i386_check_relocs,
elf_i386_relocate_section): ..
* elf32-m32r.c (m32r_elf_relocate_section,
m32r_elf_merge_private_bfd_data): ..
* elf32-m68hc1x.c (m68hc12_add_stub,
_bfd_m68hc11_elf_merge_private_bfd_data): ..
* elf32-m68k.c (elf_m68k_relocate_section): ..
* elf32-mcore.c (mcore_elf_unsupported_reloc,
mcore_elf_relocate_section): ..
* elf32-ppc.c (ppc_elf_merge_private_bfd_data, bad_shared_reloc,
ppc_elf_check_relocs, ppc_elf_relocate_section,
ppc_elf_begin_write_processing): ..
* elf32-s390.c (elf_s390_check_relocs, invalid_tls_insn,
elf_s390_relocate_section): ..
* elf32-sh-symbian.c (sh_symbian_import_as,
sh_symbian_process_embedded_commands,
sh_symbian_relocate_section): ..
* elf32-sh.c (sh_elf_relax_section, sh_elf_relax_delete_bytes,
sh_elf_swap_insns, sh_elf_relocate_section, sh_elf_check_relocs,
sh_elf_merge_private_data): ..
* elf32-sparc.c (elf32_sparc_check_relocs,
elf32_sparc_relocate_section,
elf32_sparc_merge_private_bfd_data): ..
* elf32-v850.c (v850_elf_check_relocs,
v850_elf_merge_private_bfd_data): ..
* elf32-xtensa.c (elf_xtensa_check_relocs,
elf_xtensa_relocate_section, elf_xtensa_merge_private_bfd_data): ..
* elf64-alpha.c (elf64_alpha_relax_with_lituse,
elf64_alpha_relax_got_load, elf64_alpha_size_got_sections,
elf64_alpha_relocate_section_r, elf64_alpha_relocate_section): ..
* elf64-gen.c (elf64_generic_link_add_symbols): ..
* elf64-ppc.c (ppc64_elf_merge_private_bfd_data, ppc_add_stub,
ppc64_elf_check_relocs, ppc64_elf_edit_opd,
ppc64_elf_relocate_section): ..
* elf64-s390.c (elf_s390_check_relocs, invalid_tls_insn,
elf_s390_relocate_section): ..
* elf64-sh64.c (sh_elf64_relocate_section): ..
* elf64-sparc.c (sparc64_elf_check_relocs,
sparc64_elf_add_symbol_hook, sparc64_elf_relocate_section,
sparc64_elf_merge_private_bfd_data): ..
* elf64-x86-64.c (elf64_x86_64_check_relocs,
elf64_x86_64_relocate_section): ..
* elflink.c (_bfd_elf_add_default_symbol,
_bfd_elf_link_assign_sym_version, elf_link_read_relocs_from_section,
_bfd_elf_link_output_relocs, elf_link_add_object_symbols,
bfd_elf_size_dynamic_sections, elf_link_output_extsym,
elf_get_linked_section_vma, elf_fixup_link_order,
bfd_elf_final_link, bfd_elf_gc_record_vtinherit,
bfd_elf_gc_record_vtinherit, _bfd_elf_section_already_linked): ..
* elfxx-ia64.c (elfNN_ia64_relax_section,
elfNN_ia64_relocate_section, elfNN_ia64_merge_private_bfd_data): ..
* elfxx-mips.c (mips_elf_perform_relocation,
_bfd_mips_elf_check_relocs,
_bfd_mips_elf_merge_private_bfd_data): ..
* ieee.c (ieee_slurp_external_symbols): ..
* ihex.c (ihex_bad_byte, ihex_scan, ihex_read_section): ..
* libbfd.c (_bfd_generic_verify_endian_match): ..
* linker.c (_bfd_generic_link_add_one_symbol,
_bfd_generic_section_already_linked): ..
* pdp11.c (translate_to_native_sym_flags): ..
* pe-mips.c (coff_pe_mips_relocate_section): ..
* peicode.h (pe_ILF_build_a_bfd): ..
* srec.c (srec_bad_byte): ..
* stabs.c (_bfd_link_section_stabs): ..
* xcofflink.c (xcoff_link_add_symbols, xcoff_link_input_bfd): ..
Replace all uses of bfd_archive_filename and bfd_get_section_ident
with corresponding %B and %A in _bfd_error_handler format string.
Replace occurrences of "fprintf (stderr," with _bfd_error_handler
calls to use %A and %B. Fix "against symbol .. from section" and
similar error messages. Combine multiple _bfd_error_handler calls
where they were separated due to bfd_archive_filename deficiencies.
* bfd-in2.h: Regenerate.
include/
* bfdlink.h (struct bfd_link_callbacks): Remove "error_handler".
(LD_DEFINITION_IN_DISCARDED_SECTION): Delete.
ld/
* ldmain.c (link_callbacks): Remove "error_handler".
* ldmisc.c: Include elf-bfd.h.
(vfinfo): Sort comment. Handle %A. Use %A instead of
bfd_get_section_indent.
(error_handler): Delete.
* ldmisc.h (error_handler): Delete declaration.
2004-08-13 11:16:01 +08:00
|
|
|
|
_bfd_error_handler (_("%B: Unknown relocation type %d\n"),
|
|
|
|
|
input_bfd, (int) r_type);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
bfd_set_error (bfd_error_bad_value);
|
2002-11-30 16:39:46 +08:00
|
|
|
|
ret = FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
continue;
|
|
|
|
|
}
|
2000-12-07 02:59:48 +08:00
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
|
howto = mcore_elf_howto_table [(int) r_type];
|
|
|
|
|
r_symndx = ELF32_R_SYM (rel->r_info);
|
2000-12-07 02:59:48 +08:00
|
|
|
|
|
2000-08-01 02:49:56 +08:00
|
|
|
|
/* Complain about known relocation that are not yet supported. */
|
1999-05-03 15:29:11 +08:00
|
|
|
|
if (howto->special_function == mcore_elf_unsupported_reloc)
|
|
|
|
|
{
|
bfd/
* bfd.c (_bfd_default_error_handler): Handle %A and %B.
(bfd_archive_filename, bfd_get_section_ident): Delete.
* ecofflink.c (bfd_ecoff_debug_accumulate_other): Don't call
bfd_archive_filename.
* elflink.c (elf_link_input_bfd): Don't use callbacks->error_handler
to warn about symbols in discarded sections. Use _bfd_error_handler.
* aout-adobe.c (aout_adobe_callback): See below.
* aout-cris.c (swap_ext_reloc_in): ..
* coff-arm.c (find_thumb_glue, find_arm_glue,
coff_arm_relocate_section, bfd_arm_process_before_allocation,
coff_arm_merge_private_bfd_data, _bfd_coff_arm_set_private_flags,
coff_arm_copy_private_bfd_data): ..
* coff-i860.c (i860_reloc_processing): ..
* coff-mcore.c (mcore_coff_unsupported_reloc,
coff_mcore_relocate_section): ..
* coff-ppc.c (coff_ppc_relocate_section): ..
* coff-rs6000.c (xcoff_create_csect_from_smclas
* coff-sh.c (sh_relax_section, sh_relax_delete_bytes,
sh_swap_insns, sh_relocate_section): ..
* coff-tic54x.c (tic54x_reloc_processing): ..
* coff-tic80.c (coff_tic80_relocate_section): ..
* coff64-rs6000.c (xcoff64_create_csect_from_smclas): ..
* coffcode.h (styp_to_sec_flags, coff_slurp_line_table,
coff_slurp_symbol_table, coff_classify_symbol,
coff_slurp_reloc_table): ..
* coffgen.c (_bfd_coff_read_string_table): ..
* cofflink.c (coff_link_add_symbols, _bfd_coff_link_input_bfd,
_bfd_coff_generic_relocate_section): ..
* cpu-arm.c (bfd_arm_merge_machines): ..
* cpu-sh.c (sh_merge_bfd_arch): ..
* elf-hppa.h (elf_hppa_relocate_section): ..
* elf.c (bfd_elf_string_from_elf_section, setup_group,
_bfd_elf_setup_group_pointers, bfd_section_from_shdr,
assign_section_numbers, _bfd_elf_symbol_from_bfd_symbol,
copy_private_bfd_data, _bfd_elf_validate_reloc): ..
* elf32-arm.h (find_thumb_glue, find_arm_glue,
bfd_elf32_arm_process_before_allocation, elf32_thumb_to_arm_stub,
elf32_arm_to_thumb_stub, elf32_arm_final_link_relocate,
elf32_arm_relocate_section, elf32_arm_set_private_flags,
elf32_arm_copy_private_bfd_data, elf32_arm_merge_private_bfd_data): ..
* elf32-cris.c (cris_elf_relocate_section, cris_elf_check_relocs,
cris_elf_merge_private_bfd_data
* elf32-frv.c (elf32_frv_relocate_section, elf32_frv_check_relocs): ..
* elf32-gen.c (elf32_generic_link_add_symbols): ..
* elf32-hppa.c (hppa_add_stub, hppa_build_one_stub,
elf32_hppa_check_relocs, get_local_syms, final_link_relocate,
elf32_hppa_relocate_section): ..
* elf32-i370.c (i370_elf_merge_private_bfd_data,
i370_elf_check_relocs, i370_elf_relocate_section): ..
* elf32-i386.c (elf_i386_info_to_howto_rel, elf_i386_check_relocs,
elf_i386_relocate_section): ..
* elf32-m32r.c (m32r_elf_relocate_section,
m32r_elf_merge_private_bfd_data): ..
* elf32-m68hc1x.c (m68hc12_add_stub,
_bfd_m68hc11_elf_merge_private_bfd_data): ..
* elf32-m68k.c (elf_m68k_relocate_section): ..
* elf32-mcore.c (mcore_elf_unsupported_reloc,
mcore_elf_relocate_section): ..
* elf32-ppc.c (ppc_elf_merge_private_bfd_data, bad_shared_reloc,
ppc_elf_check_relocs, ppc_elf_relocate_section,
ppc_elf_begin_write_processing): ..
* elf32-s390.c (elf_s390_check_relocs, invalid_tls_insn,
elf_s390_relocate_section): ..
* elf32-sh-symbian.c (sh_symbian_import_as,
sh_symbian_process_embedded_commands,
sh_symbian_relocate_section): ..
* elf32-sh.c (sh_elf_relax_section, sh_elf_relax_delete_bytes,
sh_elf_swap_insns, sh_elf_relocate_section, sh_elf_check_relocs,
sh_elf_merge_private_data): ..
* elf32-sparc.c (elf32_sparc_check_relocs,
elf32_sparc_relocate_section,
elf32_sparc_merge_private_bfd_data): ..
* elf32-v850.c (v850_elf_check_relocs,
v850_elf_merge_private_bfd_data): ..
* elf32-xtensa.c (elf_xtensa_check_relocs,
elf_xtensa_relocate_section, elf_xtensa_merge_private_bfd_data): ..
* elf64-alpha.c (elf64_alpha_relax_with_lituse,
elf64_alpha_relax_got_load, elf64_alpha_size_got_sections,
elf64_alpha_relocate_section_r, elf64_alpha_relocate_section): ..
* elf64-gen.c (elf64_generic_link_add_symbols): ..
* elf64-ppc.c (ppc64_elf_merge_private_bfd_data, ppc_add_stub,
ppc64_elf_check_relocs, ppc64_elf_edit_opd,
ppc64_elf_relocate_section): ..
* elf64-s390.c (elf_s390_check_relocs, invalid_tls_insn,
elf_s390_relocate_section): ..
* elf64-sh64.c (sh_elf64_relocate_section): ..
* elf64-sparc.c (sparc64_elf_check_relocs,
sparc64_elf_add_symbol_hook, sparc64_elf_relocate_section,
sparc64_elf_merge_private_bfd_data): ..
* elf64-x86-64.c (elf64_x86_64_check_relocs,
elf64_x86_64_relocate_section): ..
* elflink.c (_bfd_elf_add_default_symbol,
_bfd_elf_link_assign_sym_version, elf_link_read_relocs_from_section,
_bfd_elf_link_output_relocs, elf_link_add_object_symbols,
bfd_elf_size_dynamic_sections, elf_link_output_extsym,
elf_get_linked_section_vma, elf_fixup_link_order,
bfd_elf_final_link, bfd_elf_gc_record_vtinherit,
bfd_elf_gc_record_vtinherit, _bfd_elf_section_already_linked): ..
* elfxx-ia64.c (elfNN_ia64_relax_section,
elfNN_ia64_relocate_section, elfNN_ia64_merge_private_bfd_data): ..
* elfxx-mips.c (mips_elf_perform_relocation,
_bfd_mips_elf_check_relocs,
_bfd_mips_elf_merge_private_bfd_data): ..
* ieee.c (ieee_slurp_external_symbols): ..
* ihex.c (ihex_bad_byte, ihex_scan, ihex_read_section): ..
* libbfd.c (_bfd_generic_verify_endian_match): ..
* linker.c (_bfd_generic_link_add_one_symbol,
_bfd_generic_section_already_linked): ..
* pdp11.c (translate_to_native_sym_flags): ..
* pe-mips.c (coff_pe_mips_relocate_section): ..
* peicode.h (pe_ILF_build_a_bfd): ..
* srec.c (srec_bad_byte): ..
* stabs.c (_bfd_link_section_stabs): ..
* xcofflink.c (xcoff_link_add_symbols, xcoff_link_input_bfd): ..
Replace all uses of bfd_archive_filename and bfd_get_section_ident
with corresponding %B and %A in _bfd_error_handler format string.
Replace occurrences of "fprintf (stderr," with _bfd_error_handler
calls to use %A and %B. Fix "against symbol .. from section" and
similar error messages. Combine multiple _bfd_error_handler calls
where they were separated due to bfd_archive_filename deficiencies.
* bfd-in2.h: Regenerate.
include/
* bfdlink.h (struct bfd_link_callbacks): Remove "error_handler".
(LD_DEFINITION_IN_DISCARDED_SECTION): Delete.
ld/
* ldmain.c (link_callbacks): Remove "error_handler".
* ldmisc.c: Include elf-bfd.h.
(vfinfo): Sort comment. Handle %A. Use %A instead of
bfd_get_section_indent.
(error_handler): Delete.
* ldmisc.h (error_handler): Delete declaration.
2004-08-13 11:16:01 +08:00
|
|
|
|
_bfd_error_handler (_("%B: Relocation %s (%d) is not currently supported.\n"),
|
|
|
|
|
input_bfd,
|
1999-05-03 15:29:11 +08:00
|
|
|
|
howto->name,
|
|
|
|
|
(int)r_type);
|
|
|
|
|
|
|
|
|
|
bfd_set_error (bfd_error_bad_value);
|
2002-11-30 16:39:46 +08:00
|
|
|
|
ret = FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (r_symndx < symtab_hdr->sh_info)
|
|
|
|
|
{
|
|
|
|
|
sym = local_syms + r_symndx;
|
|
|
|
|
sec = local_sections [r_symndx];
|
2003-11-05 21:17:09 +08:00
|
|
|
|
relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
|
2001-11-23 20:17:21 +08:00
|
|
|
|
addend = rel->r_addend;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2004-03-21 07:16:43 +08:00
|
|
|
|
bfd_boolean unresolved_reloc, warned;
|
|
|
|
|
|
* elf-bfd.h (RELOC_FOR_GLOBAL_SYMBOL): Add input_bfd, input_section
and rel args. Group input and output args. Wrap to 80 columns.
* elf-m10200.c, elf-m10300.c, elf32-arm.h, elf32-avr.c,
elf32-cris.c, elf32-d10v.c, elf32-fr30.c, elf32-h8300.c,
elf32-hppa.c, elf32-i386.c, elf32-i860.c, elf32-ip2k.c,
elf32-iq2000.c, elf32-m68hc1x.c, elf32-m68k.c, elf32-mcore.c,
elf32-msp430.c, elf32-openrisc.c, elf32-ppc.c, elf32-s390.c,
elf32-sparc.c, elf32-v850.c, elf32-vax.c, elf32-xstormy16.c,
elf32-xtensa.c, elf64-alpha.c, elf64-mmix.c, elf64-ppc.c,
elf64-s390.c, elf64-sparc.c, elf64-x86-64.c, elfxx-ia64.c: Update
RELOC_FOR_GLOBAL_SYMBOL invocation.
2004-03-22 10:28:17 +08:00
|
|
|
|
RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel,
|
|
|
|
|
r_symndx, symtab_hdr, sym_hashes,
|
|
|
|
|
h, sec, relocation,
|
|
|
|
|
unresolved_reloc, warned);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
2007-03-07 16:54:35 +08:00
|
|
|
|
if (sec != NULL && elf_discarded_section (sec))
|
|
|
|
|
{
|
|
|
|
|
/* For relocs against symbols from removed linkonce sections,
|
|
|
|
|
or sections discarded by a linker script, we just want the
|
|
|
|
|
section contents zeroed. Avoid any special processing. */
|
|
|
|
|
_bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
|
|
|
|
|
rel->r_info = 0;
|
|
|
|
|
rel->r_addend = 0;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (info->relocatable)
|
|
|
|
|
continue;
|
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
|
switch (r_type)
|
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case R_MCORE_PCRELJSR_IMM11BY2:
|
|
|
|
|
oldinst = bfd_get_16 (input_bfd, contents + offset);
|
|
|
|
|
#define MCORE_INST_BSR 0xF800
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
bfd_put_16 (input_bfd, (bfd_vma) MCORE_INST_BSR, contents + offset);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
fprintf (stderr, "\ttype = %s (%d), symbol index = %ld, offset = %ld, addend = %ld\n",
|
|
|
|
|
howto->name, r_type, r_symndx, (long) offset, (long) addend);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
r = _bfd_final_link_relocate
|
|
|
|
|
(howto, input_bfd, input_section, contents, offset, relocation, addend);
|
|
|
|
|
|
|
|
|
|
if (r != bfd_reloc_ok && r_type == R_MCORE_PCRELJSR_IMM11BY2)
|
|
|
|
|
{
|
|
|
|
|
/* Wasn't ok, back it out and give up. */
|
Touches most files in bfd/, so likely will be blamed for everything..
o bfd_read and bfd_write lose an unnecessary param and become
bfd_bread and bfd_bwrite.
o bfd_*alloc now all take a bfd_size_type arg, and will error if
size_t is too small. eg. 32 bit host, 64 bit bfd, verrry big files
or bugs in linker scripts etc.
o file_ptr becomes a bfd_signed_vma. Besides matching sizes with
various other types involved in handling sections, this should make
it easier for bfd to support a 64 bit off_t on 32 bit hosts that
provide it.
o I've made the H_GET_* and H_PUT_* macros (which invoke bfd_h_{get,put}_*)
generally available. They now cast their args to bfd_vma and
bfd_byte * as appropriate, which removes a swag of casts from the
source.
o Bug fixes to bfd_get8, aix386_core_vec, elf32_h8_relax_section, and
aout-encap.c.
o Zillions of formatting and -Wconversion fixes.
2001-09-18 17:57:26 +08:00
|
|
|
|
bfd_put_16 (input_bfd, (bfd_vma) oldinst, contents + offset);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
r = bfd_reloc_ok;
|
|
|
|
|
}
|
2000-12-07 02:59:48 +08:00
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
|
if (r != bfd_reloc_ok)
|
|
|
|
|
{
|
2002-11-30 16:39:46 +08:00
|
|
|
|
ret = FALSE;
|
2000-12-07 02:59:48 +08:00
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
|
switch (r)
|
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case bfd_reloc_overflow:
|
|
|
|
|
{
|
|
|
|
|
const char * name;
|
|
|
|
|
|
|
|
|
|
if (h != NULL)
|
2004-10-21 23:28:33 +08:00
|
|
|
|
name = NULL;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
name = bfd_elf_string_from_elf_section
|
|
|
|
|
(input_bfd, symtab_hdr->sh_link, sym->st_name);
|
2000-12-07 02:59:48 +08:00
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
|
if (name == NULL)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
if (* name == '\0')
|
|
|
|
|
name = bfd_section_name (input_bfd, sec);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
(*info->callbacks->reloc_overflow)
|
2004-10-21 23:28:33 +08:00
|
|
|
|
(info, (h ? &h->root : NULL), name, howto->name,
|
|
|
|
|
(bfd_vma) 0, input_bfd, input_section, offset);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
fprintf (stderr, "\n");
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Return the section that should be marked against GC for a given
|
|
|
|
|
relocation. */
|
|
|
|
|
|
|
|
|
|
static asection *
|
* elflink.c (_bfd_elf_gc_mark_hook): New function.
* elf-bfd.h (_bfd_elf_gc_mark_hook): Declare.
* elfxx-target.h (elf_backend_gc_mark_hook): Default to above.
* elf-m10300.c (mn10300_elf_gc_mark_hook): Use _bfd_elf_gc_mark_hook.
* elf32-arm.c (elf32_arm_gc_mark_hook): Likewise.
* elf32-cris.c (cris_elf_gc_mark_hook): Likewise.
* elf32-hppa.c (elf32_hppa_gc_mark_hook): Likewise.
* elf32-i386.c (elf_i386_gc_mark_hook): Likewise.
* elf32-m32r.c (m32r_elf_gc_mark_hook): Likewise.
* elf32-m68k.c (elf_m68k_gc_mark_hook): Likewise.
* elf32-mcore.c (mcore_elf_gc_mark_hook): Likewise.
* elf32-ppc.c (ppc_elf_gc_mark_hook): Likewise.
* elf32-s390.c (elf_s390_gc_mark_hook): Likewise.
* elf32-score.c (_bfd_score_elf_gc_mark_hook): Likewise.
* elf32-sh.c (sh_elf_gc_mark_hook): Likewise.
* elf32-vax.c (elf_vax_gc_mark_hook): Likewise.
* elf32-xtensa.c (elf_xtensa_gc_mark_hook): Likewise.
* elf64-mmix.c (mmix_elf_gc_mark_hook): Likewise.
* elf64-s390.c (elf_s390_gc_mark_hook): Likewise.
* elf64-x86-64.c (elf64_x86_64_gc_mark_hook): Likewise.
* elfxx-mips.c (_bfd_mips_elf_gc_mark_hook): Likewise.
* elfxx-sparc.c (_bfd_sparc_elf_gc_mark_hook): Likewise.
* elf32-bfin.c (bfin_gc_mark_hook): Likewise.
(bfinfdpic_gc_sweep_hook): Delete.
(elf_backend_gc_sweep_hook): Don't define for elf32-bfinfdpic.
* elf32-d10v.c (elf32_d10v_gc_mark_hook): Use _bfd_elf_gc_mark_hook.
(elf32_d10v_gc_sweep_hook): Delete.
(elf_backend_gc_sweep_hook): Don't define.
* elf32-fr30.c (fr30_elf_gc_mark_hook): Use _bfd_elf_gc_mark_hook.
(fr30_elf_gc_sweep_hook): Delete.
(elf_backend_gc_sweep_hook): Don't define.
* elf32-frv.c (elf32_frv_gc_mark_hook): Use _bfd_elf_gc_mark_hook.
(elf32_frv_gc_sweep_hook): Delete.
(elf_backend_gc_sweep_hook): Don't define.
* elf32-iq2000.c (iq2000_elf_gc_mark_hook): Use _bfd_elf_gc_mark_hook.
(iq2000_elf_gc_sweep_hook): Delete.
(elf_backend_gc_sweep_hook): Don't define.
* elf32-openrisc.c (openrisc_elf_gc_mark_hook): Use
_bfd_elf_gc_mark_hook.
(openrisc_elf_gc_sweep_hook): Delete.
(elf_backend_gc_sweep_hook): Don't define.
* elf32-v850.c (v850_elf_gc_mark_hook): Use _bfd_elf_gc_mark_hook.
(v850_elf_gc_sweep_hook): Delete.
(elf_backend_gc_sweep_hook): Don't define.
* elf32-xstormy16.c (xstormy16_elf_gc_mark_hook): Use
_bfd_elf_gc_mark_hook.
(xstormy16_elf_gc_sweep_hook): Delete.
(elf_backend_gc_sweep_hook): Don't define.
* elf64-sh64.c (sh_elf64_gc_mark_hook): Use _bfd_elf_gc_mark_hook.
(sh_elf64_gc_sweep_hook): Delete.
(elf_backend_gc_sweep_hook): Don't define.
* elf32-avr.c (elf32_avr_gc_mark_hook): Delete.
(elf32_avr_gc_sweep_hook): Delete.
(elf_backend_gc_mark_hook, elf_backend_gc_mark_hook): Don't define.
* elf32-cr16c.c (elf32_cr16c_gc_mark_hook): Delete.
(elf32_cr16c_gc_sweep_hook): Delete.
(elf_backend_gc_mark_hook, elf_backend_gc_mark_hook): Don't define.
* elf32-crx.c (elf32_crx_gc_mark_hook): Delete.
(elf32_crx_gc_sweep_hook): Delete.
(elf_backend_gc_mark_hook, elf_backend_gc_mark_hook): Don't define.
* elf32-h8300.c (elf32_h8_gc_mark_hook): Delete.
(elf32_h8_gc_sweep_hook): Delete.
(elf_backend_gc_mark_hook, elf_backend_gc_mark_hook): Don't define.
* elf32-ip2k.c (ip2k_elf_gc_mark_hook): Delete.
(ip2k_elf_gc_sweep_hook): Delete.
(elf_backend_gc_mark_hook, elf_backend_gc_mark_hook): Don't define.
* elf32-m32c.c (m32c_elf_gc_mark_hook, m32c_elf_gc_sweep_hook): Delete.
(elf_backend_gc_mark_hook, elf_backend_gc_mark_hook): Don't define.
* elf32-m68hc11.c (elf_backend_gc_mark_hook): Don't define.
(elf_backend_gc_sweep_hook): Don't define.
* elf32-m68hc12.c (elf_backend_gc_mark_hook): Don't define.
(elf_backend_gc_sweep_hook): Don't define.
* elf32-m68hc1x.c (elf32_m68hc11_gc_mark_hook): Delete.
(elf32_m68hc11_gc_sweep_hook): Delete.
* elf32-m68hc1x.h (elf32_m68hc11_gc_mark_hook): Delete.
(elf32_m68hc11_gc_sweep_hook): Delete.
* elf32-msp430.c (elf32_msp430_gc_mark_hook): Delete.
(elf32_msp430_gc_sweep_hook): Delete.
(elf_backend_gc_mark_hook, elf_backend_gc_mark_hook): Don't define.
* elf32-mt.c (mt_elf_gc_mark_hook, mt_elf_gc_sweep_hook): Delete.
(elf_backend_gc_mark_hook, elf_backend_gc_mark_hook): Don't define.
2006-09-28 21:27:33 +08:00
|
|
|
|
mcore_elf_gc_mark_hook (asection *sec,
|
|
|
|
|
struct bfd_link_info *info,
|
|
|
|
|
Elf_Internal_Rela *rel,
|
|
|
|
|
struct elf_link_hash_entry *h,
|
|
|
|
|
Elf_Internal_Sym *sym)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
* elflink.c (_bfd_elf_gc_mark_hook): New function.
* elf-bfd.h (_bfd_elf_gc_mark_hook): Declare.
* elfxx-target.h (elf_backend_gc_mark_hook): Default to above.
* elf-m10300.c (mn10300_elf_gc_mark_hook): Use _bfd_elf_gc_mark_hook.
* elf32-arm.c (elf32_arm_gc_mark_hook): Likewise.
* elf32-cris.c (cris_elf_gc_mark_hook): Likewise.
* elf32-hppa.c (elf32_hppa_gc_mark_hook): Likewise.
* elf32-i386.c (elf_i386_gc_mark_hook): Likewise.
* elf32-m32r.c (m32r_elf_gc_mark_hook): Likewise.
* elf32-m68k.c (elf_m68k_gc_mark_hook): Likewise.
* elf32-mcore.c (mcore_elf_gc_mark_hook): Likewise.
* elf32-ppc.c (ppc_elf_gc_mark_hook): Likewise.
* elf32-s390.c (elf_s390_gc_mark_hook): Likewise.
* elf32-score.c (_bfd_score_elf_gc_mark_hook): Likewise.
* elf32-sh.c (sh_elf_gc_mark_hook): Likewise.
* elf32-vax.c (elf_vax_gc_mark_hook): Likewise.
* elf32-xtensa.c (elf_xtensa_gc_mark_hook): Likewise.
* elf64-mmix.c (mmix_elf_gc_mark_hook): Likewise.
* elf64-s390.c (elf_s390_gc_mark_hook): Likewise.
* elf64-x86-64.c (elf64_x86_64_gc_mark_hook): Likewise.
* elfxx-mips.c (_bfd_mips_elf_gc_mark_hook): Likewise.
* elfxx-sparc.c (_bfd_sparc_elf_gc_mark_hook): Likewise.
* elf32-bfin.c (bfin_gc_mark_hook): Likewise.
(bfinfdpic_gc_sweep_hook): Delete.
(elf_backend_gc_sweep_hook): Don't define for elf32-bfinfdpic.
* elf32-d10v.c (elf32_d10v_gc_mark_hook): Use _bfd_elf_gc_mark_hook.
(elf32_d10v_gc_sweep_hook): Delete.
(elf_backend_gc_sweep_hook): Don't define.
* elf32-fr30.c (fr30_elf_gc_mark_hook): Use _bfd_elf_gc_mark_hook.
(fr30_elf_gc_sweep_hook): Delete.
(elf_backend_gc_sweep_hook): Don't define.
* elf32-frv.c (elf32_frv_gc_mark_hook): Use _bfd_elf_gc_mark_hook.
(elf32_frv_gc_sweep_hook): Delete.
(elf_backend_gc_sweep_hook): Don't define.
* elf32-iq2000.c (iq2000_elf_gc_mark_hook): Use _bfd_elf_gc_mark_hook.
(iq2000_elf_gc_sweep_hook): Delete.
(elf_backend_gc_sweep_hook): Don't define.
* elf32-openrisc.c (openrisc_elf_gc_mark_hook): Use
_bfd_elf_gc_mark_hook.
(openrisc_elf_gc_sweep_hook): Delete.
(elf_backend_gc_sweep_hook): Don't define.
* elf32-v850.c (v850_elf_gc_mark_hook): Use _bfd_elf_gc_mark_hook.
(v850_elf_gc_sweep_hook): Delete.
(elf_backend_gc_sweep_hook): Don't define.
* elf32-xstormy16.c (xstormy16_elf_gc_mark_hook): Use
_bfd_elf_gc_mark_hook.
(xstormy16_elf_gc_sweep_hook): Delete.
(elf_backend_gc_sweep_hook): Don't define.
* elf64-sh64.c (sh_elf64_gc_mark_hook): Use _bfd_elf_gc_mark_hook.
(sh_elf64_gc_sweep_hook): Delete.
(elf_backend_gc_sweep_hook): Don't define.
* elf32-avr.c (elf32_avr_gc_mark_hook): Delete.
(elf32_avr_gc_sweep_hook): Delete.
(elf_backend_gc_mark_hook, elf_backend_gc_mark_hook): Don't define.
* elf32-cr16c.c (elf32_cr16c_gc_mark_hook): Delete.
(elf32_cr16c_gc_sweep_hook): Delete.
(elf_backend_gc_mark_hook, elf_backend_gc_mark_hook): Don't define.
* elf32-crx.c (elf32_crx_gc_mark_hook): Delete.
(elf32_crx_gc_sweep_hook): Delete.
(elf_backend_gc_mark_hook, elf_backend_gc_mark_hook): Don't define.
* elf32-h8300.c (elf32_h8_gc_mark_hook): Delete.
(elf32_h8_gc_sweep_hook): Delete.
(elf_backend_gc_mark_hook, elf_backend_gc_mark_hook): Don't define.
* elf32-ip2k.c (ip2k_elf_gc_mark_hook): Delete.
(ip2k_elf_gc_sweep_hook): Delete.
(elf_backend_gc_mark_hook, elf_backend_gc_mark_hook): Don't define.
* elf32-m32c.c (m32c_elf_gc_mark_hook, m32c_elf_gc_sweep_hook): Delete.
(elf_backend_gc_mark_hook, elf_backend_gc_mark_hook): Don't define.
* elf32-m68hc11.c (elf_backend_gc_mark_hook): Don't define.
(elf_backend_gc_sweep_hook): Don't define.
* elf32-m68hc12.c (elf_backend_gc_mark_hook): Don't define.
(elf_backend_gc_sweep_hook): Don't define.
* elf32-m68hc1x.c (elf32_m68hc11_gc_mark_hook): Delete.
(elf32_m68hc11_gc_sweep_hook): Delete.
* elf32-m68hc1x.h (elf32_m68hc11_gc_mark_hook): Delete.
(elf32_m68hc11_gc_sweep_hook): Delete.
* elf32-msp430.c (elf32_msp430_gc_mark_hook): Delete.
(elf32_msp430_gc_sweep_hook): Delete.
(elf_backend_gc_mark_hook, elf_backend_gc_mark_hook): Don't define.
* elf32-mt.c (mt_elf_gc_mark_hook, mt_elf_gc_sweep_hook): Delete.
(elf_backend_gc_mark_hook, elf_backend_gc_mark_hook): Don't define.
2006-09-28 21:27:33 +08:00
|
|
|
|
if (h != NULL)
|
|
|
|
|
switch (ELF32_R_TYPE (rel->r_info))
|
|
|
|
|
{
|
|
|
|
|
case R_MCORE_GNU_VTINHERIT:
|
|
|
|
|
case R_MCORE_GNU_VTENTRY:
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Update the got entry reference counts for the section being removed. */
|
|
|
|
|
|
2002-11-30 16:39:46 +08:00
|
|
|
|
static bfd_boolean
|
2005-07-01 19:16:33 +08:00
|
|
|
|
mcore_elf_gc_sweep_hook (bfd * abfd ATTRIBUTE_UNUSED,
|
|
|
|
|
struct bfd_link_info * info ATTRIBUTE_UNUSED,
|
|
|
|
|
asection * sec ATTRIBUTE_UNUSED,
|
|
|
|
|
const Elf_Internal_Rela * relocs ATTRIBUTE_UNUSED)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2002-11-30 16:39:46 +08:00
|
|
|
|
return TRUE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 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. */
|
2000-12-07 02:59:48 +08:00
|
|
|
|
|
2002-11-30 16:39:46 +08:00
|
|
|
|
static bfd_boolean
|
2005-07-01 19:16:33 +08:00
|
|
|
|
mcore_elf_check_relocs (bfd * abfd,
|
|
|
|
|
struct bfd_link_info * info,
|
|
|
|
|
asection * sec,
|
|
|
|
|
const Elf_Internal_Rela * relocs)
|
1999-05-03 15:29:11 +08:00
|
|
|
|
{
|
2002-11-30 16:39:46 +08:00
|
|
|
|
Elf_Internal_Shdr * symtab_hdr;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
struct elf_link_hash_entry ** sym_hashes;
|
2002-11-30 16:39:46 +08:00
|
|
|
|
const Elf_Internal_Rela * rel;
|
|
|
|
|
const Elf_Internal_Rela * rel_end;
|
2000-12-07 02:59:48 +08:00
|
|
|
|
|
2003-06-25 14:40:27 +08:00
|
|
|
|
if (info->relocatable)
|
2002-11-30 16:39:46 +08:00
|
|
|
|
return TRUE;
|
2000-12-07 02:59:48 +08:00
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
|
symtab_hdr = & elf_tdata (abfd)->symtab_hdr;
|
|
|
|
|
sym_hashes = elf_sym_hashes (abfd);
|
2000-12-07 02:59:48 +08:00
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
|
rel_end = relocs + sec->reloc_count;
|
2000-12-07 02:59:48 +08:00
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
|
for (rel = relocs; rel < rel_end; rel++)
|
|
|
|
|
{
|
|
|
|
|
struct elf_link_hash_entry * h;
|
|
|
|
|
unsigned long r_symndx;
|
2000-12-07 02:59:48 +08:00
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
|
r_symndx = ELF32_R_SYM (rel->r_info);
|
2000-12-07 02:59:48 +08:00
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
|
if (r_symndx < symtab_hdr->sh_info)
|
|
|
|
|
h = NULL;
|
|
|
|
|
else
|
2005-06-21 02:12:11 +08:00
|
|
|
|
{
|
|
|
|
|
h = sym_hashes [r_symndx - symtab_hdr->sh_info];
|
|
|
|
|
while (h->root.type == bfd_link_hash_indirect
|
|
|
|
|
|| h->root.type == bfd_link_hash_warning)
|
|
|
|
|
h = (struct elf_link_hash_entry *) h->root.u.i.link;
|
|
|
|
|
}
|
2000-12-07 02:59:48 +08:00
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
|
switch (ELF32_R_TYPE (rel->r_info))
|
|
|
|
|
{
|
|
|
|
|
/* This relocation describes the C++ object vtable hierarchy.
|
|
|
|
|
Reconstruct it for later use during GC. */
|
|
|
|
|
case R_MCORE_GNU_VTINHERIT:
|
* Makefile.am: Remove all mention of elflink.h.
* Makefile.in: Regenerate.
* bfd-in.h (bfd_elf_discard_info): Declare.
(bfd_elf32_discard_info, bfd_elf64_discard_info): Delete.
* bfd-in2.h: Regenerate.
* elf-bfd.h (bfd_elf32_print_symbol, bfd_elf64_print_symbol,
bfd_elf32_link_record_dynamic_symbol,
bfd_elf64_link_record_dynamic_symbol,
_bfd_elf_link_record_dynamic_symbol, bfd_elf32_bfd_final_link,
bfd_elf64_bfd_final_link, elf_link_record_local_dynamic_symbol,
_bfd_elf32_link_record_local_dynamic_symbol,
_bfd_elf64_link_record_local_dynamic_symbol,
_bfd_elf32_gc_sections, _bfd_elf32_gc_common_finalize_got_offsets,
_bfd_elf32_gc_common_final_link, _bfd_elf64_gc_common_final_link,
_bfd_elf32_gc_record_vtinherit, _bfd_elf32_gc_record_vtentry,
_bfd_elf64_gc_sections, _bfd_elf64_gc_common_finalize_got_offsets,
_bfd_elf64_gc_record_vtinherit, _bfd_elf64_gc_record_vtentry,
_bfd_elf32_reloc_symbol_deleted_p,
_bfd_elf64_reloc_symbol_deleted_p): Delete.
(bfd_elf_link_record_dynamic_symbol,
bfd_elf_link_record_local_dynamic_symbol,
bfd_elf_final_link, bfd_elf_gc_sections,
bfd_elf_gc_record_vtinherit, bfd_elf_gc_record_vtentry,
bfd_elf_gc_common_finalize_got_offsets, bfd_elf_gc_common_final_link,
bfd_elf_reloc_symbol_deleted_p): Declare.
(WILL_CALL_FINISH_DYNAMIC_SYMBOL): Define.
* elf32-arm.h: Update for changed function names. Remove local
WILL_CALL_FINISH_DYNAMIC_SECTION define.
* elf-hppa.h, elf-m10300.c, elf32-cris.c, elf32-d10v.c, elf32-dlx.c,
* elf32-fr30.c, elf32-frv.c, elf32-h8300.c, elf32-hppa.c, elf32-i386.c,
* elf32-iq2000.c, elf32-m32r.c, elf32-m68hc1x.c, elf32-m68k.c,
* elf32-mcore.c, elf32-openrisc.c, elf32-ppc.c, elf32-s390.c,
* elf32-sh.c, elf32-sparc.c, elf32-v850.c, elf32-vax.c,
* elf32-xstormy16.c, elf32-xtensa.c, elf64-alpha.c, elf64-hppa.c,
* elf64-mmix.c, elf64-ppc.c, elf64-s390.c, elf64-sh64.c, elf64-sparc.c,
* elf64-x86-64.c, elfxx-ia64.c, elfxx-mips.c, elfxx-target.h: Likewise.
* elfxx-target.h (bfd_elfNN_bfd_final_link): Define.
(bfd_elfNN_print_symbol): Define.
* elfcode.h: Don't include elflink.h.
(elf_bfd_discard_info, elf_reloc_symbol_deleted_p,
elf_link_record_dynamic_symbol, elf_bfd_final_link, elf_gc_sections,
elf_gc_common_finalize_got_offsets, elf_gc_common_final_link,
elf_gc_record_vtinherit, elf_gc_record_vtentry,
elf_link_record_local_dynamic_symbol): Don't define.
* elflink.c: Update for changed function names. Move elflink.h
code here.
* elflink.h: Delete file.
* po/SRC-POTFILES.in: Regenerate.
* po/bfd.pot: Regenerate.
doc/
* bfdint.texi: Remove all mention of elflink.h.
2004-03-27 18:58:09 +08:00
|
|
|
|
if (!bfd_elf_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
|
2002-11-30 16:39:46 +08:00
|
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
break;
|
2000-12-07 02:59:48 +08:00
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
|
/* This relocation describes which C++ vtable entries are actually
|
|
|
|
|
used. Record for later use during GC. */
|
|
|
|
|
case R_MCORE_GNU_VTENTRY:
|
2007-09-26 21:45:32 +08:00
|
|
|
|
BFD_ASSERT (h != NULL);
|
|
|
|
|
if (h != NULL
|
|
|
|
|
&& !bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
|
2002-11-30 16:39:46 +08:00
|
|
|
|
return FALSE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2000-12-07 02:59:48 +08:00
|
|
|
|
|
2002-11-30 16:39:46 +08:00
|
|
|
|
return TRUE;
|
1999-05-03 15:29:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
2005-07-05 14:23:37 +08:00
|
|
|
|
static const struct bfd_elf_special_section mcore_elf_special_sections[]=
|
2003-07-25 22:35:56 +08:00
|
|
|
|
{
|
2006-09-17 02:12:17 +08:00
|
|
|
|
{ STRING_COMMA_LEN (".ctors"), -2, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE },
|
|
|
|
|
{ STRING_COMMA_LEN (".dtors"), -2, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE },
|
|
|
|
|
{ NULL, 0, 0, 0, 0 }
|
2003-07-25 22:35:56 +08:00
|
|
|
|
};
|
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
|
#define TARGET_BIG_SYM bfd_elf32_mcore_big_vec
|
|
|
|
|
#define TARGET_BIG_NAME "elf32-mcore-big"
|
|
|
|
|
#define TARGET_LITTLE_SYM bfd_elf32_mcore_little_vec
|
|
|
|
|
#define TARGET_LITTLE_NAME "elf32-mcore-little"
|
|
|
|
|
|
|
|
|
|
#define ELF_ARCH bfd_arch_mcore
|
|
|
|
|
#define ELF_MACHINE_CODE EM_MCORE
|
|
|
|
|
#define ELF_MAXPAGESIZE 0x1000 /* 4k, if we ever have 'em */
|
|
|
|
|
#define elf_info_to_howto mcore_elf_info_to_howto
|
|
|
|
|
#define elf_info_to_howto_rel NULL
|
|
|
|
|
|
|
|
|
|
#define bfd_elf32_bfd_merge_private_bfd_data mcore_elf_merge_private_bfd_data
|
|
|
|
|
#define bfd_elf32_bfd_set_private_flags mcore_elf_set_private_flags
|
|
|
|
|
#define bfd_elf32_bfd_reloc_type_lookup mcore_elf_reloc_type_lookup
|
2007-03-26 20:23:03 +08:00
|
|
|
|
#define bfd_elf32_bfd_reloc_name_lookup mcore_elf_reloc_name_lookup
|
1999-05-03 15:29:11 +08:00
|
|
|
|
#define elf_backend_relocate_section mcore_elf_relocate_section
|
|
|
|
|
#define elf_backend_gc_mark_hook mcore_elf_gc_mark_hook
|
|
|
|
|
#define elf_backend_gc_sweep_hook mcore_elf_gc_sweep_hook
|
|
|
|
|
#define elf_backend_check_relocs mcore_elf_check_relocs
|
2005-07-08 08:26:53 +08:00
|
|
|
|
#define elf_backend_special_sections mcore_elf_special_sections
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
#define elf_backend_can_gc_sections 1
|
2002-05-07 08:16:53 +08:00
|
|
|
|
#define elf_backend_rela_normal 1
|
1999-05-03 15:29:11 +08:00
|
|
|
|
|
|
|
|
|
#include "elf32-target.h"
|