2004-03-30 16:04:32 +02:00
|
|
|
/* BFD back-end for National Semiconductor's CR16C ELF
|
2016-01-01 12:25:12 +01:00
|
|
|
Copyright (C) 2004-2016 Free Software Foundation, Inc.
|
2004-03-30 16:04:32 +02:00
|
|
|
|
|
|
|
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
|
2007-07-03 16:26:43 +02:00
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
2004-03-30 16:04:32 +02:00
|
|
|
(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.
|
|
|
|
|
|
|
|
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 16:26:43 +02:00
|
|
|
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
|
|
|
|
MA 02110-1301, USA. */
|
2004-03-30 16:04:32 +02:00
|
|
|
|
|
|
|
#include "sysdep.h"
|
2007-04-26 16:47:00 +02:00
|
|
|
#include "bfd.h"
|
2004-03-30 16:04:32 +02:00
|
|
|
#include "libbfd.h"
|
|
|
|
#include "bfdlink.h"
|
|
|
|
#include "elf/cr16c.h"
|
|
|
|
#include "elf-bfd.h"
|
|
|
|
|
|
|
|
|
|
|
|
#define USE_REL 1 /* CR16C uses REL relocations instead of RELA. */
|
|
|
|
|
2013-01-10 21:03:55 +01:00
|
|
|
/* The following definition is based on EMPTY_HOWTO macro,
|
2004-03-30 16:04:32 +02:00
|
|
|
but also initiates the "name" field in HOWTO struct. */
|
|
|
|
#define ONLY_NAME_HOWTO(C) \
|
|
|
|
HOWTO ((C), 0, 0, 0, FALSE, 0, complain_overflow_dont, NULL, \
|
|
|
|
STRINGX(C), FALSE, 0, 0, FALSE)
|
|
|
|
|
|
|
|
/* reloc_map_index array maps CRASM relocation type into a BFD
|
2013-01-10 21:03:55 +01:00
|
|
|
relocation enum. The array's indices are synchronized with
|
2004-03-30 16:04:32 +02:00
|
|
|
RINDEX_16C_* indices, created in include/elf/cr16c.h.
|
|
|
|
The array is used in:
|
|
|
|
1. elf32-cr16c.c : elf_cr16c_reloc_type_lookup().
|
|
|
|
2. asreloc.c : find_reloc_type(). */
|
|
|
|
|
|
|
|
RELOC_MAP reloc_map_index[RINDEX_16C_MAX] =
|
|
|
|
{
|
|
|
|
{R_16C_NUM08, BFD_RELOC_16C_NUM08},
|
|
|
|
{R_16C_NUM08_C, BFD_RELOC_16C_NUM08_C},
|
|
|
|
{R_16C_NUM16, BFD_RELOC_16C_NUM16},
|
|
|
|
{R_16C_NUM16_C, BFD_RELOC_16C_NUM16_C},
|
|
|
|
{R_16C_NUM32, BFD_RELOC_16C_NUM32},
|
|
|
|
{R_16C_NUM32_C, BFD_RELOC_16C_NUM32_C},
|
|
|
|
{R_16C_DISP04, BFD_RELOC_16C_DISP04},
|
|
|
|
{R_16C_DISP04_C, BFD_RELOC_16C_DISP04_C},
|
|
|
|
{R_16C_DISP08, BFD_RELOC_16C_DISP08},
|
|
|
|
{R_16C_DISP08_C, BFD_RELOC_16C_DISP08_C},
|
|
|
|
{R_16C_DISP16, BFD_RELOC_16C_DISP16},
|
|
|
|
{R_16C_DISP16_C, BFD_RELOC_16C_DISP16_C},
|
|
|
|
{R_16C_DISP24, BFD_RELOC_16C_DISP24},
|
|
|
|
{R_16C_DISP24_C, BFD_RELOC_16C_DISP24_C},
|
|
|
|
{R_16C_DISP24a, BFD_RELOC_16C_DISP24a},
|
|
|
|
{R_16C_DISP24a_C, BFD_RELOC_16C_DISP24a_C},
|
|
|
|
{R_16C_REG04, BFD_RELOC_16C_REG04},
|
|
|
|
{R_16C_REG04_C, BFD_RELOC_16C_REG04_C},
|
|
|
|
{R_16C_REG04a, BFD_RELOC_16C_REG04a},
|
|
|
|
{R_16C_REG04a_C, BFD_RELOC_16C_REG04a_C},
|
|
|
|
{R_16C_REG14, BFD_RELOC_16C_REG14},
|
|
|
|
{R_16C_REG14_C, BFD_RELOC_16C_REG14_C},
|
|
|
|
{R_16C_REG16, BFD_RELOC_16C_REG16},
|
|
|
|
{R_16C_REG16_C, BFD_RELOC_16C_REG16_C},
|
|
|
|
{R_16C_REG20, BFD_RELOC_16C_REG20},
|
|
|
|
{R_16C_REG20_C, BFD_RELOC_16C_REG20_C},
|
|
|
|
{R_16C_ABS20, BFD_RELOC_16C_ABS20},
|
|
|
|
{R_16C_ABS20_C, BFD_RELOC_16C_ABS20_C},
|
|
|
|
{R_16C_ABS24, BFD_RELOC_16C_ABS24},
|
|
|
|
{R_16C_ABS24_C, BFD_RELOC_16C_ABS24_C},
|
|
|
|
{R_16C_IMM04, BFD_RELOC_16C_IMM04},
|
|
|
|
{R_16C_IMM04_C, BFD_RELOC_16C_IMM04_C},
|
|
|
|
{R_16C_IMM16, BFD_RELOC_16C_IMM16},
|
|
|
|
{R_16C_IMM16_C, BFD_RELOC_16C_IMM16_C},
|
|
|
|
{R_16C_IMM20, BFD_RELOC_16C_IMM20},
|
|
|
|
{R_16C_IMM20_C, BFD_RELOC_16C_IMM20_C},
|
|
|
|
{R_16C_IMM24, BFD_RELOC_16C_IMM24},
|
|
|
|
{R_16C_IMM24_C, BFD_RELOC_16C_IMM24_C},
|
|
|
|
{R_16C_IMM32, BFD_RELOC_16C_IMM32},
|
|
|
|
{R_16C_IMM32_C, BFD_RELOC_16C_IMM32_C}
|
|
|
|
};
|
|
|
|
|
|
|
|
static reloc_howto_type elf_howto_table[] =
|
|
|
|
{
|
|
|
|
/* 00 */ ONLY_NAME_HOWTO (RINDEX_16C_NUM08),
|
|
|
|
/* 01 */ ONLY_NAME_HOWTO (RINDEX_16C_NUM08_C),
|
|
|
|
/* 02 */ ONLY_NAME_HOWTO (RINDEX_16C_NUM16),
|
|
|
|
/* 03 */ ONLY_NAME_HOWTO (RINDEX_16C_NUM16_C),
|
|
|
|
/* 04 */ ONLY_NAME_HOWTO (RINDEX_16C_NUM32),
|
|
|
|
/* 05 */ ONLY_NAME_HOWTO (RINDEX_16C_NUM32_C),
|
|
|
|
/* 06 */ ONLY_NAME_HOWTO (RINDEX_16C_DISP04),
|
|
|
|
/* 07 */ ONLY_NAME_HOWTO (RINDEX_16C_DISP04_C),
|
|
|
|
/* 08 */ ONLY_NAME_HOWTO (RINDEX_16C_DISP08),
|
|
|
|
/* 09 */ ONLY_NAME_HOWTO (RINDEX_16C_DISP08_C),
|
|
|
|
/* 10 */ ONLY_NAME_HOWTO (RINDEX_16C_DISP16),
|
|
|
|
/* 11 */ ONLY_NAME_HOWTO (RINDEX_16C_DISP16_C),
|
|
|
|
/* 12 */ ONLY_NAME_HOWTO (RINDEX_16C_DISP24),
|
|
|
|
/* 13 */ ONLY_NAME_HOWTO (RINDEX_16C_DISP24_C),
|
|
|
|
/* 14 */ ONLY_NAME_HOWTO (RINDEX_16C_DISP24a),
|
|
|
|
/* 15 */ ONLY_NAME_HOWTO (RINDEX_16C_DISP24a_C),
|
|
|
|
/* 16 */ ONLY_NAME_HOWTO (RINDEX_16C_REG04),
|
|
|
|
/* 17 */ ONLY_NAME_HOWTO (RINDEX_16C_REG04_C),
|
|
|
|
/* 18 */ ONLY_NAME_HOWTO (RINDEX_16C_REG04a),
|
|
|
|
/* 19 */ ONLY_NAME_HOWTO (RINDEX_16C_REG04a_C),
|
|
|
|
/* 20 */ ONLY_NAME_HOWTO (RINDEX_16C_REG14),
|
|
|
|
/* 21 */ ONLY_NAME_HOWTO (RINDEX_16C_REG14_C),
|
|
|
|
/* 22 */ ONLY_NAME_HOWTO (RINDEX_16C_REG16),
|
|
|
|
/* 23 */ ONLY_NAME_HOWTO (RINDEX_16C_REG16_C),
|
|
|
|
/* 24 */ ONLY_NAME_HOWTO (RINDEX_16C_REG20),
|
|
|
|
/* 25 */ ONLY_NAME_HOWTO (RINDEX_16C_REG20_C),
|
|
|
|
/* 26 */ ONLY_NAME_HOWTO (RINDEX_16C_ABS20),
|
|
|
|
/* 27 */ ONLY_NAME_HOWTO (RINDEX_16C_ABS20_C),
|
|
|
|
/* 28 */ ONLY_NAME_HOWTO (RINDEX_16C_ABS24),
|
|
|
|
/* 29 */ ONLY_NAME_HOWTO (RINDEX_16C_ABS24_C),
|
|
|
|
/* 30 */ ONLY_NAME_HOWTO (RINDEX_16C_IMM04),
|
|
|
|
/* 31 */ ONLY_NAME_HOWTO (RINDEX_16C_IMM04_C),
|
|
|
|
/* 32 */ ONLY_NAME_HOWTO (RINDEX_16C_IMM16),
|
|
|
|
/* 33 */ ONLY_NAME_HOWTO (RINDEX_16C_IMM16_C),
|
|
|
|
/* 34 */ ONLY_NAME_HOWTO (RINDEX_16C_IMM20),
|
|
|
|
/* 35 */ ONLY_NAME_HOWTO (RINDEX_16C_IMM20_C),
|
|
|
|
/* 36 */ ONLY_NAME_HOWTO (RINDEX_16C_IMM24),
|
|
|
|
/* 37 */ ONLY_NAME_HOWTO (RINDEX_16C_IMM24_C),
|
|
|
|
/* 38 */ ONLY_NAME_HOWTO (RINDEX_16C_IMM32),
|
|
|
|
/* 39 */ ONLY_NAME_HOWTO (RINDEX_16C_IMM32_C)
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* Code to turn a code_type into a howto ptr, uses the above howto table. */
|
|
|
|
|
|
|
|
static reloc_howto_type *
|
|
|
|
elf_cr16c_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
|
|
|
|
bfd_reloc_code_real_type code)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
for (i = 0; i < RINDEX_16C_MAX; i++)
|
|
|
|
{
|
|
|
|
if (code == reloc_map_index[i].bfd_reloc_enum)
|
|
|
|
{
|
|
|
|
/* printf ("CR16C Relocation Type is - %x\n", code); */
|
|
|
|
return & elf_howto_table[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* printf ("This relocation Type is not supported - %x\n", code); */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-03-26 14:23:03 +02:00
|
|
|
static reloc_howto_type *
|
|
|
|
elf_cr16c_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
|
|
|
|
const char *r_name)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
for (i = 0; i < sizeof (elf_howto_table) / sizeof (elf_howto_table[0]); i++)
|
|
|
|
if (elf_howto_table[i].name != NULL
|
|
|
|
&& strcasecmp (elf_howto_table[i].name, r_name) == 0)
|
|
|
|
return &elf_howto_table[i];
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2004-03-30 16:04:32 +02:00
|
|
|
static void
|
|
|
|
elf_cr16c_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
|
|
|
|
arelent *cache_ptr ATTRIBUTE_UNUSED,
|
|
|
|
Elf_Internal_Rela *dst ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
abort ();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
elf_cr16c_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED,
|
|
|
|
arelent *cache_ptr,
|
|
|
|
Elf_Internal_Rela *dst)
|
|
|
|
{
|
|
|
|
unsigned int r_type = ELF32_R_TYPE (dst->r_info);
|
|
|
|
|
2014-12-22 21:59:00 +01:00
|
|
|
if (r_type >= RINDEX_16C_MAX)
|
|
|
|
{
|
2016-10-19 15:04:34 +02:00
|
|
|
/* xgettext:c-format */
|
2015-02-03 15:34:54 +01:00
|
|
|
_bfd_error_handler (_("%B: invalid CR16C reloc number: %d"), abfd, r_type);
|
2014-12-22 21:59:00 +01:00
|
|
|
r_type = 0;
|
|
|
|
}
|
2004-03-30 16:04:32 +02:00
|
|
|
cache_ptr->howto = &elf_howto_table[r_type];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Perform a relocation as part of a final link. */
|
|
|
|
|
|
|
|
static bfd_reloc_status_type
|
|
|
|
cr16c_elf_final_link_relocate (reloc_howto_type *howto,
|
|
|
|
bfd *abfd,
|
|
|
|
bfd *output_bfd ATTRIBUTE_UNUSED,
|
|
|
|
asection *input_section,
|
|
|
|
bfd_byte *data,
|
|
|
|
bfd_vma octets,
|
|
|
|
bfd_vma Rvalue,
|
|
|
|
bfd_vma addend ATTRIBUTE_UNUSED,
|
|
|
|
struct bfd_link_info *info ATTRIBUTE_UNUSED,
|
|
|
|
asection *sym_sec ATTRIBUTE_UNUSED,
|
|
|
|
int is_local ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
long value;
|
|
|
|
short sword; /* Extracted from the hole and put back. */
|
|
|
|
unsigned long format, addr_type, code_factor;
|
|
|
|
unsigned short size;
|
|
|
|
unsigned short r_type;
|
|
|
|
|
|
|
|
unsigned long disp20_opcod;
|
|
|
|
char neg = 0;
|
|
|
|
char neg2pos = 0;
|
|
|
|
|
|
|
|
long left_val = 0;
|
|
|
|
long plus_factor = 0; /* To be added to the hole. */
|
|
|
|
|
|
|
|
#define MIN_BYTE ((int) 0xFFFFFF80)
|
|
|
|
#define MIN_WORD ((int) 0xFFFF8000)
|
|
|
|
#define MAX_UWORD ((unsigned) 0x0000FFFF)
|
|
|
|
#define MAX_UBYTE ((unsigned) 0x000000FF)
|
|
|
|
|
|
|
|
r_type = reloc_map_index[howto->type].cr_reloc_type;
|
|
|
|
format = r_type & R_FORMAT;
|
|
|
|
size = r_type & R_SIZESP;
|
|
|
|
addr_type = r_type & R_ADDRTYPE;
|
|
|
|
code_factor = ((addr_type == R_CODE_ADDR) ? 1 : 0);
|
|
|
|
|
|
|
|
switch (format)
|
|
|
|
{
|
|
|
|
case R_NUMBER:
|
|
|
|
switch (size)
|
|
|
|
{
|
|
|
|
case R_S_16C_08: /* One byte. */
|
|
|
|
value = bfd_get_8 (abfd, (char *) data + octets);
|
|
|
|
break;
|
|
|
|
case R_S_16C_16: /* Two bytes. */
|
|
|
|
sword = bfd_get_16 (abfd, (bfd_byte *) data + octets);
|
|
|
|
value = sword;
|
|
|
|
break;
|
|
|
|
case R_S_16C_32: /* Four bytes. */
|
|
|
|
value = bfd_get_32 (abfd, (bfd_byte *) data + octets);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return bfd_reloc_notsupported;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case R_16C_DISPL:
|
|
|
|
switch (size)
|
|
|
|
{
|
|
|
|
case R_S_16C_04: /* word1(4-7). */
|
|
|
|
value = bfd_get_8 (abfd, (char *) data + octets);
|
|
|
|
left_val = value & 0xF;
|
|
|
|
value = (value & 0xF0) >> 4;
|
|
|
|
value++;
|
|
|
|
value <<= 1;
|
|
|
|
break;
|
|
|
|
case R_S_16C_08: /* word1(0-3,8-11). */
|
|
|
|
sword = bfd_get_16 (abfd, (char *) data + octets);
|
|
|
|
value = sword & 0x000F;
|
|
|
|
value |= ((sword & 0x0F00) >> 4);
|
|
|
|
left_val = sword & 0xF0F0;
|
|
|
|
value <<= 1;
|
|
|
|
if (value & 0x100)
|
|
|
|
value |= 0xFFFFFF00;
|
|
|
|
break;
|
|
|
|
case R_S_16C_16: /* word2. */
|
|
|
|
sword = bfd_get_16 (abfd, (bfd_byte *) data + octets);
|
|
|
|
value = sword;
|
|
|
|
value = ((value & 0xFFFE) >> 1) | ((value & 0x1) << 15);
|
|
|
|
value <<= 1;
|
|
|
|
if (value & 0x10000)
|
|
|
|
value |= 0xFFFF0000;
|
|
|
|
break;
|
|
|
|
case R_S_16C_24_a: /* word1(0-7),word2. */
|
|
|
|
value = bfd_get_32 (abfd, (bfd_byte *) data + octets);
|
|
|
|
left_val = value & 0x0000FF00;
|
|
|
|
value = ((value & 0xFFFE0000) >> 17) |
|
|
|
|
((value & 0x00010000) << 7) | ((value & 0x000000FF) << 15);
|
|
|
|
value <<= 1;
|
|
|
|
if (value & 0x1000000)
|
|
|
|
value |= 0xFE000000;
|
|
|
|
break;
|
|
|
|
case R_S_16C_24: /* word2(0-3,8-11),word3. */
|
|
|
|
value = bfd_get_32 (abfd, (bfd_byte *) data + octets);
|
|
|
|
left_val = value & 0x0000F0F0;
|
|
|
|
value = ((value >> 16) & 0x0000FFFF) |
|
|
|
|
((value & 0x00000F00) << 8) | ((value & 0x0000000F) << 20);
|
|
|
|
|
|
|
|
value = ((value & 0x00FFFFFE) >> 1) | ((value & 0x00000001) << 23);
|
|
|
|
|
|
|
|
value <<= 1;
|
|
|
|
if (value & 0x1000000)
|
|
|
|
value |= 0xFE000000;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return bfd_reloc_notsupported;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case R_16C_REGREL:
|
|
|
|
switch (size)
|
|
|
|
{
|
|
|
|
case R_S_16C_04: /* word1(12-15) not scaled. */
|
|
|
|
value = bfd_get_8 (abfd, (char *) data + octets);
|
|
|
|
left_val = value & 0xF0;
|
|
|
|
value = value & 0xF;
|
|
|
|
break;
|
|
|
|
case R_S_16C_04_a: /* word1(12-15) scaled by 2. */
|
|
|
|
value = bfd_get_8 (abfd, (char *) data + octets);
|
|
|
|
left_val = value & 0xF0;
|
|
|
|
value = value & 0xF;
|
|
|
|
value <<= 1;
|
|
|
|
break;
|
|
|
|
case R_S_16C_14: /* word1(4-5),word2(0-3,8-15). */
|
|
|
|
value = bfd_get_32 (abfd, (bfd_byte *) data + octets);
|
|
|
|
left_val = value & 0x00F0FFCF;
|
|
|
|
value = ((value & 0xc0000000) >> 24) |
|
|
|
|
((value & 0x3F000000) >> 16) |
|
|
|
|
((value & 0x000F0000) >> 16) | (value & 0x00000030);
|
|
|
|
break;
|
|
|
|
case R_S_16C_16: /* word2. */
|
|
|
|
sword = bfd_get_16 (abfd, (bfd_byte *) data + octets);
|
|
|
|
value = sword;
|
|
|
|
break;
|
|
|
|
case R_S_16C_20: /* word2(8-11),word3. */
|
|
|
|
value = bfd_get_32 (abfd, (bfd_byte *) data + octets);
|
|
|
|
left_val = value & 0xF0;
|
|
|
|
value = (value & 0xF) << 16;
|
|
|
|
sword = bfd_get_16 (abfd, (bfd_byte *) data + octets + 1);
|
|
|
|
value = value | (unsigned short) sword;
|
|
|
|
disp20_opcod = bfd_get_32 (abfd, (bfd_byte *) data + octets - 3);
|
|
|
|
disp20_opcod |= 0x0FFF0000;
|
|
|
|
if ((disp20_opcod == 0x4FFF0018) || /* loadb -disp20(reg) */
|
|
|
|
(disp20_opcod == 0x5FFF0018) || /* loadb -disp20(rp) */
|
|
|
|
(disp20_opcod == 0x8FFF0018) || /* loadd -disp20(reg) */
|
|
|
|
(disp20_opcod == 0x9FFF0018) || /* loadd -disp20(rp) */
|
|
|
|
(disp20_opcod == 0xCFFF0018) || /* loadw -disp20(reg) */
|
|
|
|
(disp20_opcod == 0xDFFF0018) || /* loadw -disp20(rp) */
|
|
|
|
(disp20_opcod == 0x4FFF0019) || /* storb -disp20(reg) */
|
|
|
|
(disp20_opcod == 0x5FFF0019) || /* storb -disp20(rp) */
|
|
|
|
(disp20_opcod == 0x8FFF0019) || /* stord -disp20(reg) */
|
|
|
|
(disp20_opcod == 0x9FFF0019) || /* stord -disp20(rp) */
|
|
|
|
(disp20_opcod == 0xCFFF0019) || /* storw -disp20(reg) */
|
|
|
|
(disp20_opcod == 0xDFFF0019))
|
|
|
|
{ /* storw -disp20(rp). */
|
|
|
|
neg = 1;
|
|
|
|
value |= 0xFFF00000;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return bfd_reloc_notsupported;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case R_16C_ABS:
|
|
|
|
switch (size)
|
|
|
|
{
|
|
|
|
case R_S_16C_20: /* word1(0-3),word2. */
|
|
|
|
value = bfd_get_32 (abfd, (bfd_byte *) data + octets);
|
|
|
|
left_val = value & 0x0000FFF0;
|
|
|
|
value = ((value & 0xFFFF0000) >> 16) |
|
|
|
|
((value & 0x0000000F) << 16);
|
|
|
|
break;
|
|
|
|
case R_S_16C_24: /* word2(0-3,8-11),word3. */
|
|
|
|
value = bfd_get_32 (abfd, (bfd_byte *) data + octets);
|
|
|
|
left_val = value & 0x0000F0F0;
|
|
|
|
value = ((value & 0xFFFF0000) >> 16) |
|
|
|
|
((value & 0x00000F00) << 8) | ((value & 0x0000000F) << 20);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return bfd_reloc_notsupported;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case R_16C_IMMED:
|
|
|
|
switch (size)
|
|
|
|
{
|
|
|
|
case R_S_16C_04: /* word1/2(4-7). */
|
|
|
|
value = bfd_get_8 (abfd, (char *) data + octets);
|
|
|
|
left_val = value & 0xF;
|
|
|
|
value = (value & 0xF0) >> 4;
|
|
|
|
break;
|
|
|
|
case R_S_16C_16: /* word2. */
|
|
|
|
sword = bfd_get_16 (abfd, (bfd_byte *) data + octets);
|
|
|
|
value = sword;
|
|
|
|
break;
|
|
|
|
case R_S_16C_20: /* word1(0-3),word2. */
|
|
|
|
value = bfd_get_32 (abfd, (bfd_byte *) data + octets);
|
|
|
|
left_val = value & 0x0000FFF0;
|
|
|
|
value = ((value & 0xFFFF0000) >> 16) |
|
|
|
|
((value & 0x0000000F) << 16);
|
|
|
|
break;
|
|
|
|
case R_S_16C_32: /* word2, word3. */
|
|
|
|
value = bfd_get_32 (abfd, (bfd_byte *) data + octets);
|
|
|
|
value = ((value & 0x0000FFFF) << 16) |
|
|
|
|
((value & 0xFFFF0000) >> 16);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return bfd_reloc_notsupported;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return bfd_reloc_notsupported;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch ((r_type & R_RELTO) >> 4)
|
|
|
|
{
|
|
|
|
|
|
|
|
case 0: /* R_ABS. */
|
|
|
|
plus_factor = Rvalue;
|
|
|
|
break;
|
|
|
|
case 1: /* R_PCREL. */
|
|
|
|
plus_factor = Rvalue -
|
|
|
|
(input_section->output_section->vma + input_section->output_offset);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return bfd_reloc_notsupported;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (neg)
|
|
|
|
{
|
|
|
|
if (plus_factor >= -value)
|
|
|
|
neg2pos = 1;
|
|
|
|
/* We need to change load/stor with negative
|
|
|
|
displ opcode to positive disp opcode (CR16C). */
|
|
|
|
}
|
|
|
|
|
|
|
|
value = value + (plus_factor >> code_factor);
|
|
|
|
|
|
|
|
switch (format)
|
|
|
|
{
|
|
|
|
case R_NUMBER:
|
|
|
|
switch (size)
|
|
|
|
{
|
|
|
|
case R_S_16C_08: /* One byte. */
|
|
|
|
if (value > (int) MAX_UBYTE || value < MIN_BYTE)
|
|
|
|
return bfd_reloc_overflow;
|
|
|
|
value &= 0xFF;
|
|
|
|
bfd_put_8 (abfd, (bfd_vma) value, (unsigned char *) data + octets);
|
|
|
|
break;
|
2005-02-23 10:56:44 +01:00
|
|
|
|
2004-03-30 16:04:32 +02:00
|
|
|
case R_S_16C_16: /* Two bytes. */
|
|
|
|
if (value > (int) MAX_UWORD || value < MIN_WORD)
|
|
|
|
return bfd_reloc_overflow;
|
|
|
|
value &= 0xFFFF;
|
|
|
|
sword = value;
|
|
|
|
bfd_put_16 (abfd, (bfd_vma) sword,
|
|
|
|
(unsigned char *) data + octets);
|
|
|
|
break;
|
2005-02-23 10:56:44 +01:00
|
|
|
|
2004-03-30 16:04:32 +02:00
|
|
|
case R_S_16C_32: /* Four bytes. */
|
|
|
|
value &= 0xFFFFFFFF;
|
|
|
|
bfd_put_32 (abfd, (bfd_vma) value, (bfd_byte *) data + octets);
|
|
|
|
break;
|
2005-02-23 10:56:44 +01:00
|
|
|
|
2004-03-30 16:04:32 +02:00
|
|
|
default:
|
|
|
|
return bfd_reloc_notsupported;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case R_16C_DISPL:
|
|
|
|
switch (size)
|
|
|
|
{
|
|
|
|
case R_S_16C_04: /* word1(4-7). */
|
|
|
|
if ((value - 32) > 32 || value < 2)
|
|
|
|
return bfd_reloc_overflow;
|
|
|
|
value >>= 1;
|
|
|
|
value--;
|
|
|
|
value &= 0xF;
|
|
|
|
value <<= 4;
|
|
|
|
value |= left_val;
|
|
|
|
bfd_put_8 (abfd, (bfd_vma) value, (unsigned char *) data + octets);
|
|
|
|
break;
|
2005-02-23 10:56:44 +01:00
|
|
|
|
2004-03-30 16:04:32 +02:00
|
|
|
case R_S_16C_08: /* word1(0-3,8-11). */
|
|
|
|
if (value > 255 || value < -256 || value == 0x80)
|
|
|
|
return bfd_reloc_overflow;
|
|
|
|
value &= 0x1FF;
|
|
|
|
value >>= 1;
|
|
|
|
sword = value & 0x000F;
|
|
|
|
sword |= (value & 0x00F0) << 4;
|
|
|
|
sword |= left_val;
|
|
|
|
bfd_put_16 (abfd, (bfd_vma) sword,
|
|
|
|
(unsigned char *) data + octets);
|
|
|
|
break;
|
2005-02-23 10:56:44 +01:00
|
|
|
|
2004-03-30 16:04:32 +02:00
|
|
|
case R_S_16C_16: /* word2. */
|
|
|
|
if (value > 65535 || value < -65536)
|
|
|
|
return bfd_reloc_overflow;
|
|
|
|
value >>= 1;
|
|
|
|
value &= 0xFFFF;
|
|
|
|
value = ((value & 0x8000) >> 15) | ((value & 0x7FFF) << 1);
|
|
|
|
sword = value;
|
|
|
|
bfd_put_16 (abfd, (bfd_vma) sword,
|
|
|
|
(unsigned char *) data + octets);
|
|
|
|
break;
|
2005-02-23 10:56:44 +01:00
|
|
|
|
2004-03-30 16:04:32 +02:00
|
|
|
case R_S_16C_24_a: /* word1(0-7),word2. */
|
|
|
|
if (value > 16777215 || value < -16777216)
|
|
|
|
return bfd_reloc_overflow;
|
|
|
|
value &= 0x1FFFFFF;
|
|
|
|
value >>= 1;
|
|
|
|
value = ((value & 0x00007FFF) << 17) |
|
|
|
|
((value & 0x00800000) >> 7) | ((value & 0x007F8000) >> 15);
|
|
|
|
value |= left_val;
|
|
|
|
bfd_put_32 (abfd, (bfd_vma) value, (bfd_byte *) data + octets);
|
|
|
|
break;
|
2005-02-23 10:56:44 +01:00
|
|
|
|
2004-03-30 16:04:32 +02:00
|
|
|
case R_S_16C_24: /* word2(0-3,8-11),word3. */
|
|
|
|
if (value > 16777215 || value < -16777216)
|
|
|
|
return bfd_reloc_overflow;
|
|
|
|
value &= 0x1FFFFFF;
|
|
|
|
value >>= 1;
|
|
|
|
|
|
|
|
value = ((value & 0x007FFFFF) << 1) | ((value & 0x00800000) >> 23);
|
|
|
|
|
|
|
|
value = ((value & 0x0000FFFF) << 16) |
|
|
|
|
((value & 0x000F0000) >> 8) | ((value & 0x00F00000) >> 20);
|
|
|
|
value |= left_val;
|
|
|
|
bfd_put_32 (abfd, (bfd_vma) value, (bfd_byte *) data + octets);
|
|
|
|
break;
|
2005-02-23 10:56:44 +01:00
|
|
|
|
2004-03-30 16:04:32 +02:00
|
|
|
default:
|
|
|
|
return bfd_reloc_notsupported;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case R_16C_REGREL:
|
|
|
|
switch (size)
|
|
|
|
{
|
|
|
|
case R_S_16C_04: /* word1(12-15) not scaled. */
|
|
|
|
if (value > 13 || value < 0)
|
|
|
|
return bfd_reloc_overflow;
|
|
|
|
value &= 0xF;
|
|
|
|
value |= left_val;
|
|
|
|
bfd_put_8 (abfd, (bfd_vma) value, (unsigned char *) data + octets);
|
|
|
|
break;
|
2005-02-23 10:56:44 +01:00
|
|
|
|
2004-03-30 16:04:32 +02:00
|
|
|
case R_S_16C_04_a: /* word1(12-15) not scaled. */
|
|
|
|
if (value > 26 || value < 0)
|
|
|
|
return bfd_reloc_overflow;
|
|
|
|
value &= 0x1F;
|
|
|
|
value >>= 1;
|
|
|
|
value |= left_val;
|
|
|
|
bfd_put_8 (abfd, (bfd_vma) value, (unsigned char *) data + octets);
|
|
|
|
break;
|
2005-02-23 10:56:44 +01:00
|
|
|
|
2004-03-30 16:04:32 +02:00
|
|
|
case R_S_16C_14: /* word1(4-5),word2(0-3,8-15). */
|
|
|
|
if (value < 0 || value > 16383)
|
|
|
|
return bfd_reloc_overflow;
|
|
|
|
value &= 0x3FFF;
|
|
|
|
value = ((value & 0x000000c0) << 24) |
|
|
|
|
((value & 0x00003F00) << 16) |
|
|
|
|
((value & 0x0000000F) << 16) | (value & 0x00000030);
|
|
|
|
value |= left_val;
|
|
|
|
bfd_put_32 (abfd, (bfd_vma) value, (bfd_byte *) data + octets);
|
|
|
|
break;
|
2005-02-23 10:56:44 +01:00
|
|
|
|
2004-03-30 16:04:32 +02:00
|
|
|
case R_S_16C_16: /* word2. */
|
|
|
|
if (value > 65535 || value < 0)
|
|
|
|
return bfd_reloc_overflow;
|
|
|
|
value &= 0xFFFF;
|
|
|
|
sword = value;
|
|
|
|
bfd_put_16 (abfd, (bfd_vma) sword,
|
|
|
|
(unsigned char *) data + octets);
|
|
|
|
break;
|
2005-02-23 10:56:44 +01:00
|
|
|
|
2004-03-30 16:04:32 +02:00
|
|
|
case R_S_16C_20: /* word2(8-11),word3. */
|
|
|
|
/* if (value > 1048575 || value < 0) RELOC_ERROR(1); */
|
|
|
|
value &= 0xFFFFF;
|
|
|
|
sword = value & 0x0000FFFF;
|
|
|
|
value = (value & 0x000F0000) >> 16;
|
|
|
|
value |= left_val;
|
|
|
|
bfd_put_8 (abfd, (bfd_vma) value, (unsigned char *) data + octets);
|
|
|
|
bfd_put_16 (abfd, (bfd_vma) sword,
|
|
|
|
(unsigned char *) data + octets + 1);
|
|
|
|
if (neg2pos)
|
|
|
|
{
|
|
|
|
/* Change load/stor negative displ opcode
|
|
|
|
to load/stor positive displ opcode. */
|
|
|
|
value = bfd_get_8 (abfd, (char *) data + octets - 3);
|
|
|
|
value &= 0xF7;
|
|
|
|
value |= 0x2;
|
|
|
|
bfd_put_8 (abfd, (bfd_vma) value,
|
|
|
|
(unsigned char *) data + octets - 3);
|
|
|
|
}
|
|
|
|
break;
|
2005-02-23 10:56:44 +01:00
|
|
|
|
2004-03-30 16:04:32 +02:00
|
|
|
default:
|
|
|
|
return bfd_reloc_notsupported;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case R_16C_ABS:
|
|
|
|
switch (size)
|
|
|
|
{
|
|
|
|
case R_S_16C_20: /* word1(0-3),word2. */
|
|
|
|
if (value > 1048575 || value < 0)
|
|
|
|
return bfd_reloc_overflow;
|
|
|
|
value &= 0xFFFFF;
|
|
|
|
value = ((value & 0x0000FFFF) << 16) |
|
|
|
|
((value & 0x000F0000) >> 16);
|
|
|
|
value |= left_val;
|
|
|
|
bfd_put_32 (abfd, (bfd_vma) value, (bfd_byte *) data + octets);
|
|
|
|
break;
|
2005-02-23 10:56:44 +01:00
|
|
|
|
2004-03-30 16:04:32 +02:00
|
|
|
case R_S_16C_24: /* word2(0-3,8-11),word3. */
|
|
|
|
/* if (value > 16777215 || value < 0) RELOC_ERROR(1); */
|
|
|
|
value &= 0xFFFFFF;
|
|
|
|
value = ((value & 0x0000FFFF) << 16) |
|
|
|
|
((value & 0x000F0000) >> 8) | ((value & 0x00F00000) >> 20);
|
|
|
|
value |= left_val;
|
|
|
|
bfd_put_32 (abfd, (bfd_vma) value, (bfd_byte *) data + octets);
|
|
|
|
break;
|
2005-02-23 10:56:44 +01:00
|
|
|
|
2004-03-30 16:04:32 +02:00
|
|
|
default:
|
|
|
|
return bfd_reloc_notsupported;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case R_16C_IMMED:
|
|
|
|
switch (size)
|
|
|
|
{
|
|
|
|
case R_S_16C_04: /* word1/2(4-7). */
|
|
|
|
if (value > 15 || value < -1)
|
|
|
|
return bfd_reloc_overflow;
|
|
|
|
value &= 0xF;
|
|
|
|
value <<= 4;
|
|
|
|
value |= left_val;
|
|
|
|
bfd_put_8 (abfd, (bfd_vma) value, (unsigned char *) data + octets);
|
|
|
|
break;
|
2005-02-23 10:56:44 +01:00
|
|
|
|
2004-03-30 16:04:32 +02:00
|
|
|
case R_S_16C_16: /* word2. */
|
|
|
|
if (value > 32767 || value < -32768)
|
|
|
|
return bfd_reloc_overflow;
|
|
|
|
value &= 0xFFFF;
|
|
|
|
sword = value;
|
|
|
|
bfd_put_16 (abfd, (bfd_vma) sword,
|
|
|
|
(unsigned char *) data + octets);
|
|
|
|
break;
|
2005-02-23 10:56:44 +01:00
|
|
|
|
2004-03-30 16:04:32 +02:00
|
|
|
case R_S_16C_20: /* word1(0-3),word2. */
|
|
|
|
if (value > 1048575 || value < 0)
|
|
|
|
return bfd_reloc_overflow;
|
|
|
|
value &= 0xFFFFF;
|
|
|
|
value = ((value & 0x0000FFFF) << 16) |
|
|
|
|
((value & 0x000F0000) >> 16);
|
|
|
|
value |= left_val;
|
|
|
|
bfd_put_32 (abfd, (bfd_vma) value, (bfd_byte *) data + octets);
|
|
|
|
break;
|
2005-02-23 10:56:44 +01:00
|
|
|
|
2004-03-30 16:04:32 +02:00
|
|
|
case R_S_16C_32: /* word2, word3. */
|
|
|
|
value &= 0xFFFFFFFF;
|
|
|
|
value = ((value & 0x0000FFFF) << 16) |
|
|
|
|
((value & 0xFFFF0000) >> 16);
|
|
|
|
bfd_put_32 (abfd, (bfd_vma) value, (bfd_byte *) data + octets);
|
|
|
|
break;
|
2005-02-23 10:56:44 +01:00
|
|
|
|
2004-03-30 16:04:32 +02:00
|
|
|
default:
|
|
|
|
return bfd_reloc_notsupported;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return bfd_reloc_notsupported;
|
|
|
|
}
|
2005-02-23 10:56:44 +01:00
|
|
|
|
|
|
|
return bfd_reloc_ok;
|
2004-03-30 16:04:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Relocate a CR16C ELF section. */
|
|
|
|
|
|
|
|
static bfd_boolean
|
|
|
|
elf32_cr16c_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)
|
|
|
|
{
|
|
|
|
Elf_Internal_Shdr *symtab_hdr;
|
|
|
|
struct elf_link_hash_entry **sym_hashes;
|
|
|
|
Elf_Internal_Rela *rel, *relend;
|
|
|
|
|
|
|
|
symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
|
|
|
|
sym_hashes = elf_sym_hashes (input_bfd);
|
|
|
|
|
|
|
|
rel = relocs;
|
|
|
|
relend = relocs + input_section->reloc_count;
|
|
|
|
for (; rel < relend; rel++)
|
|
|
|
{
|
|
|
|
int r_type;
|
|
|
|
reloc_howto_type *howto;
|
|
|
|
unsigned long r_symndx;
|
|
|
|
Elf_Internal_Sym *sym;
|
|
|
|
asection *sec;
|
|
|
|
struct elf_link_hash_entry *h;
|
|
|
|
bfd_vma relocation;
|
|
|
|
bfd_reloc_status_type r;
|
|
|
|
|
|
|
|
r_symndx = ELF32_R_SYM (rel->r_info);
|
|
|
|
r_type = ELF32_R_TYPE (rel->r_info);
|
|
|
|
howto = elf_howto_table + r_type;
|
|
|
|
|
|
|
|
h = NULL;
|
|
|
|
sym = NULL;
|
|
|
|
sec = NULL;
|
|
|
|
if (r_symndx < symtab_hdr->sh_info)
|
|
|
|
{
|
|
|
|
sym = local_syms + r_symndx;
|
|
|
|
sec = local_sections[r_symndx];
|
|
|
|
relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-11-05 19:29:44 +01:00
|
|
|
bfd_boolean unresolved_reloc, warned, ignored;
|
2004-04-02 17:26:04 +02:00
|
|
|
|
|
|
|
RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel,
|
|
|
|
r_symndx, symtab_hdr, sym_hashes,
|
|
|
|
h, sec, relocation,
|
2013-11-05 19:29:44 +01:00
|
|
|
unresolved_reloc, warned, ignored);
|
2004-03-30 16:04:32 +02:00
|
|
|
}
|
|
|
|
|
PR ld/13991
bfd/
* bfd/elf-bfd.h (_bfd_elf_link_just_syms): Define as
_bfd_generic_link_just_syms.
* bfd/elflink.c (_bfd_elf_link_just_syms): Delete.
* bfd/linker.c (_bfd_generic_link_just_syms): Set sec_info_type.
* bfd/bfd-in.h (discarded_section): Renamed from elf_discarded_section.
* bfd/section.c (SEC_INFO_TYPE_NONE, SEC_INFO_TYPE_STABS,
SEC_INFO_TYPE_MERGE, SEC_INFO_TYPE_EH_FRAME,
SEC_INFO_TYPE_JUST_SYMS): Renamed from corresponding ELF_INFO_TYPE.
* bfd/elf-eh-frame.c, * bfd/elf-m10200.c, * bfd/elf-m10300.c,
* bfd/elf.c, * bfd/elf32-arm.c, * bfd/elf32-avr.c, * bfd/elf32-bfin.c,
* bfd/elf32-cr16.c, * bfd/elf32-cr16c.c, * bfd/elf32-cris.c,
* bfd/elf32-crx.c, * bfd/elf32-d10v.c, * bfd/elf32-epiphany.c,
* bfd/elf32-fr30.c, * bfd/elf32-frv.c, * bfd/elf32-h8300.c,
* bfd/elf32-hppa.c, * bfd/elf32-i370.c, * bfd/elf32-i386.c,
* bfd/elf32-i860.c, * bfd/elf32-ip2k.c, * bfd/elf32-iq2000.c,
* bfd/elf32-lm32.c, * bfd/elf32-m32c.c, * bfd/elf32-m32r.c,
* bfd/elf32-m68hc1x.c, * bfd/elf32-m68k.c, * bfd/elf32-mcore.c,
* bfd/elf32-mep.c, * bfd/elf32-moxie.c, * bfd/elf32-msp430.c,
* bfd/elf32-mt.c, * bfd/elf32-openrisc.c, * bfd/elf32-ppc.c,
* bfd/elf32-rl78.c, * bfd/elf32-rx.c, * bfd/elf32-s390.c,
* bfd/elf32-score.c, * bfd/elf32-score7.c, * bfd/elf32-sh.c,
* bfd/elf32-spu.c, * bfd/elf32-tic6x.c, * bfd/elf32-tilepro.c,
* bfd/elf32-v850.c, * bfd/elf32-vax.c, * bfd/elf32-xc16x.c,
* bfd/elf32-xstormy16.c, * bfd/elf32-xtensa.c, * bfd/elf64-alpha.c,
* bfd/elf64-hppa.c, * bfd/elf64-ia64-vms.c, * bfd/elf64-mmix.c,
* bfd/elf64-ppc.c, * bfd/elf64-s390.c, * bfd/elf64-sh64.c,
* bfd/elf64-x86-64.c, * bfd/elflink.c, * bfd/elfnn-ia64.c,
* bfd/elfxx-mips.c, * bfd/elfxx-sparc.c, * bfd/elfxx-tilegx.c,
* bfd/reloc.c: Update all references.
* bfd/bfd-in2.h: Regenerate.
ld/
* ld/ldlang.c (size_input_section): Use sec_info_type rather than
usrdata->flags.just_syms.
* ld/ldwrite.c (build_link_order): Likewise.
* ld/emultempl/hppaelf.em (build_section_lists): Likewise.
* ld/emultempl/ppc64elf.em (build_toc_list): Likewise.
* ld/emultempl/armelf.em (build_section_lists): Likewise.
(after_allocation): Update for renamed sec_info_type value.
* ld/emultempl/tic6xdsbt.em: Likewise.
2012-04-24 07:12:40 +02:00
|
|
|
if (sec != NULL && discarded_section (sec))
|
2010-10-25 17:54:16 +02:00
|
|
|
RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
|
2012-05-07 05:27:52 +02:00
|
|
|
rel, 1, relend, howto, 0, contents);
|
2007-03-07 09:54:35 +01:00
|
|
|
|
Add output_type to bfd_link_info
The "shared" field in bfd_link_info is set for both DSO and and PIE.
There are separate fields for executable and relocatable outputs. This
patch adds an "output_type" field:
enum output_type
{
type_unknown = 0,
type_executable,
type_dll,
type_relocatable
};
and a "pic" field to bfd_link_info to replace shared, executable and
relocatable fields so that we can use the "output_type" field to check
for output type and the "pic" field check if output is PIC. Macros,
bfd_link_executable, bfd_link_dll, bfd_link_relocatable, bfd_link_pic
and bfd_link_pie, are provided to check for output features.
bfd/
* bfd/aoutx.h: Replace shared, executable, relocatable and pie
fields with bfd_link_executable, bfd_link_dll,
bfd_link_relocatable, bfd_link_pic and bfd_link_pie.
* bfd/bout.c: Likewise.
* bfd/coff-alpha.c: Likewise.
* bfd/coff-arm.c: Likewise.
* bfd/coff-i386.c: Likewise.
* bfd/coff-i960.c: Likewise.
* bfd/coff-m68k.c: Likewise.
* bfd/coff-mcore.c: Likewise.
* bfd/coff-mips.c: Likewise.
* bfd/coff-ppc.c: Likewise.
* bfd/coff-rs6000.c: Likewise.
* bfd/coff-sh.c: Likewise.
* bfd/coff-tic80.c: Likewise.
* bfd/coff-x86_64.c: Likewise.
* bfd/coff64-rs6000.c: Likewise.
* bfd/coffgen.c: Likewise.
* bfd/cofflink.c: Likewise.
* bfd/ecoff.c: Likewise.
* bfd/ecofflink.c: Likewise.
* bfd/elf-bfd.h: Likewise.
* bfd/elf-eh-frame.c: Likewise.
* bfd/elf-ifunc.c: Likewise.
* bfd/elf-m10200.c: Likewise.
* bfd/elf-m10300.c: Likewise.
* bfd/elf-s390-common.c: Likewise.
* bfd/elf-vxworks.c: Likewise.
* bfd/elf.c: Likewise.
* bfd/elf32-arm.c: Likewise.
* bfd/elf32-avr.c: Likewise.
* bfd/elf32-bfin.c: Likewise.
* bfd/elf32-cr16.c: Likewise.
* bfd/elf32-cr16c.c: Likewise.
* bfd/elf32-cris.c: Likewise.
* bfd/elf32-crx.c: Likewise.
* bfd/elf32-d10v.c: Likewise.
* bfd/elf32-dlx.c: Likewise.
* bfd/elf32-epiphany.c: Likewise.
* bfd/elf32-fr30.c: Likewise.
* bfd/elf32-frv.c: Likewise.
* bfd/elf32-ft32.c: Likewise.
* bfd/elf32-h8300.c: Likewise.
* bfd/elf32-hppa.c: Likewise.
* bfd/elf32-i370.c: Likewise.
* bfd/elf32-i386.c: Likewise.
* bfd/elf32-i860.c: Likewise.
* bfd/elf32-ip2k.c: Likewise.
* bfd/elf32-iq2000.c: Likewise.
* bfd/elf32-lm32.c: Likewise.
* bfd/elf32-m32c.c: Likewise.
* bfd/elf32-m32r.c: Likewise.
* bfd/elf32-m68hc11.c: Likewise.
* bfd/elf32-m68hc1x.c: Likewise.
* bfd/elf32-m68k.c: Likewise.
* bfd/elf32-mcore.c: Likewise.
* bfd/elf32-mep.c: Likewise.
* bfd/elf32-metag.c: Likewise.
* bfd/elf32-microblaze.c: Likewise.
* bfd/elf32-moxie.c: Likewise.
* bfd/elf32-msp430.c: Likewise.
* bfd/elf32-mt.c: Likewise.
* bfd/elf32-nds32.c: Likewise.
* bfd/elf32-nios2.c: Likewise.
* bfd/elf32-or1k.c: Likewise.
* bfd/elf32-ppc.c: Likewise.
* bfd/elf32-rl78.c: Likewise.
* bfd/elf32-rx.c: Likewise.
* bfd/elf32-s390.c: Likewise.
* bfd/elf32-score.c: Likewise.
* bfd/elf32-score7.c: Likewise.
* bfd/elf32-sh-symbian.c: Likewise.
* bfd/elf32-sh.c: Likewise.
* bfd/elf32-sh64.c: Likewise.
* bfd/elf32-spu.c: Likewise.
* bfd/elf32-tic6x.c: Likewise.
* bfd/elf32-tilepro.c: Likewise.
* bfd/elf32-v850.c: Likewise.
* bfd/elf32-vax.c: Likewise.
* bfd/elf32-visium.c: Likewise.
* bfd/elf32-xc16x.c: Likewise.
* bfd/elf32-xstormy16.c: Likewise.
* bfd/elf32-xtensa.c: Likewise.
* bfd/elf64-alpha.c: Likewise.
* bfd/elf64-hppa.c: Likewise.
* bfd/elf64-ia64-vms.c: Likewise.
* bfd/elf64-mmix.c: Likewise.
* bfd/elf64-ppc.c: Likewise.
* bfd/elf64-s390.c: Likewise.
* bfd/elf64-sh64.c: Likewise.
* bfd/elf64-x86-64.c: Likewise.
* bfd/elflink.c: Likewise.
* bfd/elfnn-aarch64.c: Likewise.
* bfd/elfnn-ia64.c: Likewise.
* bfd/elfxx-mips.c: Likewise.
* bfd/elfxx-sparc.c: Likewise.
* bfd/elfxx-tilegx.c: Likewise.
* bfd/i386linux.c: Likewise.
* bfd/linker.c: Likewise.
* bfd/m68klinux.c: Likewise.
* bfd/pdp11.c: Likewise.
* bfd/pe-mips.c: Likewise.
* bfd/peXXigen.c: Likewise.
* bfd/reloc.c: Likewise.
* bfd/reloc16.c: Likewise.
* bfd/sparclinux.c: Likewise.
* bfd/sunos.c: Likewise.
* bfd/vms-alpha.c: Likewise.
* bfd/xcofflink.c: Likewise.
include/
* include/bfdlink.h (output_type): New enum.
(bfd_link_executable): New macro.
(bfd_link_dll): Likewise.
(bfd_link_relocatable): Likewise.
(bfd_link_pic): Likewise.
(bfd_link_pie): Likewise.
(bfd_link_info): Remove shared, executable, pie and relocatable.
Add output_type and pic.
ld/
* ld/ldctor.c: Replace shared, executable, relocatable and pie
fields with bfd_link_executable, bfd_link_dll,
bfd_link_relocatable, bfd_link_pic and bfd_link_pie.
* ld/ldemul.c: Likewise.
* ld/ldfile.c: Likewise.
* ld/ldlang.c: Likewise.
* ld/ldmain.c: Likewise.
* ld/ldwrite.c: Likewise.
* ld/lexsup.c: Likewise.
* ld/pe-dll.c: Likewise.
* ld/plugin.c: Likewise.
* ld/emultempl/aarch64elf.em: Likewise.
* ld/emultempl/aix.em: Likewise.
* ld/emultempl/alphaelf.em: Likewise.
* ld/emultempl/armcoff.em: Likewise.
* ld/emultempl/armelf.em: Likewise.
* ld/emultempl/avrelf.em: Likewise.
* ld/emultempl/beos.em: Likewise.
* ld/emultempl/cr16elf.em: Likewise.
* ld/emultempl/elf-generic.em: Likewise.
* ld/emultempl/elf32.em: Likewise.
* ld/emultempl/genelf.em: Likewise.
* ld/emultempl/generic.em: Likewise.
* ld/emultempl/gld960.em: Likewise.
* ld/emultempl/gld960c.em: Likewise.
* ld/emultempl/hppaelf.em: Likewise.
* ld/emultempl/irix.em: Likewise.
* ld/emultempl/linux.em: Likewise.
* ld/emultempl/lnk960.em: Likewise.
* ld/emultempl/m68hc1xelf.em: Likewise.
* ld/emultempl/m68kcoff.em: Likewise.
* ld/emultempl/m68kelf.em: Likewise.
* ld/emultempl/metagelf.em: Likewise.
* ld/emultempl/mipself.em: Likewise.
* ld/emultempl/mmo.em: Likewise.
* ld/emultempl/msp430.em: Likewise.
* ld/emultempl/nds32elf.em: Likewise.
* ld/emultempl/needrelax.em: Likewise.
* ld/emultempl/nios2elf.em: Likewise.
* ld/emultempl/pe.em: Likewise.
* ld/emultempl/pep.em: Likewise.
* ld/emultempl/ppc32elf.em: Likewise.
* ld/emultempl/ppc64elf.em: Likewise.
* ld/emultempl/sh64elf.em: Likewise.
* ld/emultempl/solaris2.em: Likewise.
* ld/emultempl/spuelf.em: Likewise.
* ld/emultempl/sunos.em: Likewise.
* ld/emultempl/tic6xdsbt.em: Likewise.
* ld/emultempl/ticoff.em: Likewise.
* ld/emultempl/v850elf.em: Likewise.
* ld/emultempl/vms.em: Likewise.
* ld/emultempl/vxworks.em: Likewise.
2015-08-18 14:51:03 +02:00
|
|
|
if (bfd_link_relocatable (info))
|
2007-03-07 09:54:35 +01:00
|
|
|
{
|
|
|
|
/* 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. */
|
|
|
|
if (sym != NULL && ELF_ST_TYPE (sym->st_info) == STT_SECTION)
|
|
|
|
rel->r_addend += sec->output_offset;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2004-03-30 16:04:32 +02:00
|
|
|
r = cr16c_elf_final_link_relocate (howto, input_bfd, output_bfd,
|
|
|
|
input_section,
|
|
|
|
contents, rel->r_offset,
|
|
|
|
relocation, rel->r_addend,
|
|
|
|
info, sec, h == NULL);
|
|
|
|
|
|
|
|
if (r != bfd_reloc_ok)
|
|
|
|
{
|
|
|
|
const char *name;
|
|
|
|
const char *msg = (const char *) 0;
|
|
|
|
|
|
|
|
if (h != NULL)
|
|
|
|
name = h->root.root.string;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
name = (bfd_elf_string_from_elf_section
|
|
|
|
(input_bfd, symtab_hdr->sh_link, sym->st_name));
|
|
|
|
if (name == NULL || *name == '\0')
|
|
|
|
name = bfd_section_name (input_bfd, sec);
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (r)
|
|
|
|
{
|
|
|
|
case bfd_reloc_overflow:
|
Return void from linker callbacks
The ldmain.c implementation of these linker callback functions always
return true, so any code handling a false return is dead. What's
more, some of the bfd backends abort if ever a false return is seen,
and there seems to be some confusion in gdb's compile-object-load.c.
The return value was never meant to be "oh yes, a multiple_definition
error occurred", but rather "out of memory or other catastrophic
failure".
This patch removes the status return on the callbacks that always
return true. I kept the return status for "notice" because that one
does happen to need to return "out of memory".
include/
* bfdlink.h (struct bfd_link_callbacks): Update comments.
Return void from multiple_definition, multiple_common,
add_to_set, constructor, warning, undefined_symbol,
reloc_overflow, reloc_dangerous and unattached_reloc.
bfd/
* aoutx.h: Adjust linker callback calls throughout file,
removing dead code.
* bout.c: Likewise.
* coff-alpha.c: Likewise.
* coff-arm.c: Likewise.
* coff-h8300.c: Likewise.
* coff-h8500.c: Likewise.
* coff-i960.c: Likewise.
* coff-mcore.c: Likewise.
* coff-mips.c: Likewise.
* coff-ppc.c: Likewise.
* coff-rs6000.c: Likewise.
* coff-sh.c: Likewise.
* coff-tic80.c: Likewise.
* coff-w65.c: Likewise.
* coff-z80.c: Likewise.
* coff-z8k.c: Likewise.
* coff64-rs6000.c: Likewise.
* cofflink.c: Likewise.
* ecoff.c: Likewise.
* elf-bfd.h: Likewise.
* elf-m10200.c: Likewise.
* elf-m10300.c: Likewise.
* elf32-arc.c: Likewise.
* elf32-arm.c: Likewise.
* elf32-avr.c: Likewise.
* elf32-bfin.c: Likewise.
* elf32-cr16.c: Likewise.
* elf32-cr16c.c: Likewise.
* elf32-cris.c: Likewise.
* elf32-crx.c: Likewise.
* elf32-d10v.c: Likewise.
* elf32-epiphany.c: Likewise.
* elf32-fr30.c: Likewise.
* elf32-frv.c: Likewise.
* elf32-ft32.c: Likewise.
* elf32-h8300.c: Likewise.
* elf32-hppa.c: Likewise.
* elf32-i370.c: Likewise.
* elf32-i386.c: Likewise.
* elf32-i860.c: Likewise.
* elf32-ip2k.c: Likewise.
* elf32-iq2000.c: Likewise.
* elf32-lm32.c: Likewise.
* elf32-m32c.c: Likewise.
* elf32-m32r.c: Likewise.
* elf32-m68hc1x.c: Likewise.
* elf32-m68k.c: Likewise.
* elf32-mep.c: Likewise.
* elf32-metag.c: Likewise.
* elf32-microblaze.c: Likewise.
* elf32-moxie.c: Likewise.
* elf32-msp430.c: Likewise.
* elf32-mt.c: Likewise.
* elf32-nds32.c: Likewise.
* elf32-nios2.c: Likewise.
* elf32-or1k.c: Likewise.
* elf32-ppc.c: Likewise.
* elf32-s390.c: Likewise.
* elf32-score.c: Likewise.
* elf32-score7.c: Likewise.
* elf32-sh.c: Likewise.
* elf32-sh64.c: Likewise.
* elf32-spu.c: Likewise.
* elf32-tic6x.c: Likewise.
* elf32-tilepro.c: Likewise.
* elf32-v850.c: Likewise.
* elf32-vax.c: Likewise.
* elf32-visium.c: Likewise.
* elf32-xstormy16.c: Likewise.
* elf32-xtensa.c: Likewise.
* elf64-alpha.c: Likewise.
* elf64-hppa.c: Likewise.
* elf64-ia64-vms.c: Likewise.
* elf64-mmix.c: Likewise.
* elf64-ppc.c: Likewise.
* elf64-s390.c: Likewise.
* elf64-sh64.c: Likewise.
* elf64-x86-64.c: Likewise.
* elflink.c: Likewise.
* elfnn-aarch64.c: Likewise.
* elfnn-ia64.c: Likewise.
* elfxx-mips.c: Likewise.
* elfxx-sparc.c: Likewise.
* elfxx-tilegx.c: Likewise.
* linker.c: Likewise.
* pdp11.c: Likewise.
* pe-mips.c: Likewise.
* reloc.c: Likewise.
* reloc16.c: Likewise.
* simple.c: Likewise.
* vms-alpha.c: Likewise.
* xcofflink.c: Likewise.
* elf32-rl78.c (get_symbol_value, get_romstart, get_ramstart): Delete
status param. Adjust calls to these and linker callbacks throughout.
* elf32-rx.c: (get_symbol_value, get_gp, get_romstart,
get_ramstart): Delete status param. Adjust calls to these and
linker callbacks throughout.
ld/
* ldmain.c (multiple_definition, multiple_common, add_to_set,
constructor_callback, warning_callback, undefined_symbol,
reloc_overflow, reloc_dangerous, unattached_reloc): Return void.
* emultempl/elf32.em: Adjust callback calls.
gdb/
* compile/compile-object-load.c (link_callbacks_multiple_definition,
link_callbacks_warning, link_callbacks_undefined_symbol,
link_callbacks_undefined_symbol, link_callbacks_reloc_overflow,
link_callbacks_reloc_dangerous,
link_callbacks_unattached_reloc): Return void.
2016-05-27 09:50:55 +02:00
|
|
|
(*info->callbacks->reloc_overflow)
|
|
|
|
(info, (h ? &h->root : NULL), name, howto->name,
|
|
|
|
(bfd_vma) 0, input_bfd, input_section, rel->r_offset);
|
2004-03-30 16:04:32 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case bfd_reloc_undefined:
|
Return void from linker callbacks
The ldmain.c implementation of these linker callback functions always
return true, so any code handling a false return is dead. What's
more, some of the bfd backends abort if ever a false return is seen,
and there seems to be some confusion in gdb's compile-object-load.c.
The return value was never meant to be "oh yes, a multiple_definition
error occurred", but rather "out of memory or other catastrophic
failure".
This patch removes the status return on the callbacks that always
return true. I kept the return status for "notice" because that one
does happen to need to return "out of memory".
include/
* bfdlink.h (struct bfd_link_callbacks): Update comments.
Return void from multiple_definition, multiple_common,
add_to_set, constructor, warning, undefined_symbol,
reloc_overflow, reloc_dangerous and unattached_reloc.
bfd/
* aoutx.h: Adjust linker callback calls throughout file,
removing dead code.
* bout.c: Likewise.
* coff-alpha.c: Likewise.
* coff-arm.c: Likewise.
* coff-h8300.c: Likewise.
* coff-h8500.c: Likewise.
* coff-i960.c: Likewise.
* coff-mcore.c: Likewise.
* coff-mips.c: Likewise.
* coff-ppc.c: Likewise.
* coff-rs6000.c: Likewise.
* coff-sh.c: Likewise.
* coff-tic80.c: Likewise.
* coff-w65.c: Likewise.
* coff-z80.c: Likewise.
* coff-z8k.c: Likewise.
* coff64-rs6000.c: Likewise.
* cofflink.c: Likewise.
* ecoff.c: Likewise.
* elf-bfd.h: Likewise.
* elf-m10200.c: Likewise.
* elf-m10300.c: Likewise.
* elf32-arc.c: Likewise.
* elf32-arm.c: Likewise.
* elf32-avr.c: Likewise.
* elf32-bfin.c: Likewise.
* elf32-cr16.c: Likewise.
* elf32-cr16c.c: Likewise.
* elf32-cris.c: Likewise.
* elf32-crx.c: Likewise.
* elf32-d10v.c: Likewise.
* elf32-epiphany.c: Likewise.
* elf32-fr30.c: Likewise.
* elf32-frv.c: Likewise.
* elf32-ft32.c: Likewise.
* elf32-h8300.c: Likewise.
* elf32-hppa.c: Likewise.
* elf32-i370.c: Likewise.
* elf32-i386.c: Likewise.
* elf32-i860.c: Likewise.
* elf32-ip2k.c: Likewise.
* elf32-iq2000.c: Likewise.
* elf32-lm32.c: Likewise.
* elf32-m32c.c: Likewise.
* elf32-m32r.c: Likewise.
* elf32-m68hc1x.c: Likewise.
* elf32-m68k.c: Likewise.
* elf32-mep.c: Likewise.
* elf32-metag.c: Likewise.
* elf32-microblaze.c: Likewise.
* elf32-moxie.c: Likewise.
* elf32-msp430.c: Likewise.
* elf32-mt.c: Likewise.
* elf32-nds32.c: Likewise.
* elf32-nios2.c: Likewise.
* elf32-or1k.c: Likewise.
* elf32-ppc.c: Likewise.
* elf32-s390.c: Likewise.
* elf32-score.c: Likewise.
* elf32-score7.c: Likewise.
* elf32-sh.c: Likewise.
* elf32-sh64.c: Likewise.
* elf32-spu.c: Likewise.
* elf32-tic6x.c: Likewise.
* elf32-tilepro.c: Likewise.
* elf32-v850.c: Likewise.
* elf32-vax.c: Likewise.
* elf32-visium.c: Likewise.
* elf32-xstormy16.c: Likewise.
* elf32-xtensa.c: Likewise.
* elf64-alpha.c: Likewise.
* elf64-hppa.c: Likewise.
* elf64-ia64-vms.c: Likewise.
* elf64-mmix.c: Likewise.
* elf64-ppc.c: Likewise.
* elf64-s390.c: Likewise.
* elf64-sh64.c: Likewise.
* elf64-x86-64.c: Likewise.
* elflink.c: Likewise.
* elfnn-aarch64.c: Likewise.
* elfnn-ia64.c: Likewise.
* elfxx-mips.c: Likewise.
* elfxx-sparc.c: Likewise.
* elfxx-tilegx.c: Likewise.
* linker.c: Likewise.
* pdp11.c: Likewise.
* pe-mips.c: Likewise.
* reloc.c: Likewise.
* reloc16.c: Likewise.
* simple.c: Likewise.
* vms-alpha.c: Likewise.
* xcofflink.c: Likewise.
* elf32-rl78.c (get_symbol_value, get_romstart, get_ramstart): Delete
status param. Adjust calls to these and linker callbacks throughout.
* elf32-rx.c: (get_symbol_value, get_gp, get_romstart,
get_ramstart): Delete status param. Adjust calls to these and
linker callbacks throughout.
ld/
* ldmain.c (multiple_definition, multiple_common, add_to_set,
constructor_callback, warning_callback, undefined_symbol,
reloc_overflow, reloc_dangerous, unattached_reloc): Return void.
* emultempl/elf32.em: Adjust callback calls.
gdb/
* compile/compile-object-load.c (link_callbacks_multiple_definition,
link_callbacks_warning, link_callbacks_undefined_symbol,
link_callbacks_undefined_symbol, link_callbacks_reloc_overflow,
link_callbacks_reloc_dangerous,
link_callbacks_unattached_reloc): Return void.
2016-05-27 09:50:55 +02:00
|
|
|
(*info->callbacks->undefined_symbol)
|
|
|
|
(info, name, input_bfd, input_section, rel->r_offset, TRUE);
|
2004-03-30 16:04:32 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case bfd_reloc_outofrange:
|
|
|
|
msg = _("internal error: out of range error");
|
|
|
|
goto common_error;
|
|
|
|
|
|
|
|
case bfd_reloc_notsupported:
|
|
|
|
msg = _("internal error: unsupported relocation error");
|
|
|
|
goto common_error;
|
|
|
|
|
|
|
|
case bfd_reloc_dangerous:
|
|
|
|
msg = _("internal error: dangerous error");
|
|
|
|
goto common_error;
|
|
|
|
|
|
|
|
default:
|
|
|
|
msg = _("internal error: unknown error");
|
|
|
|
/* fall through */
|
|
|
|
|
|
|
|
common_error:
|
Return void from linker callbacks
The ldmain.c implementation of these linker callback functions always
return true, so any code handling a false return is dead. What's
more, some of the bfd backends abort if ever a false return is seen,
and there seems to be some confusion in gdb's compile-object-load.c.
The return value was never meant to be "oh yes, a multiple_definition
error occurred", but rather "out of memory or other catastrophic
failure".
This patch removes the status return on the callbacks that always
return true. I kept the return status for "notice" because that one
does happen to need to return "out of memory".
include/
* bfdlink.h (struct bfd_link_callbacks): Update comments.
Return void from multiple_definition, multiple_common,
add_to_set, constructor, warning, undefined_symbol,
reloc_overflow, reloc_dangerous and unattached_reloc.
bfd/
* aoutx.h: Adjust linker callback calls throughout file,
removing dead code.
* bout.c: Likewise.
* coff-alpha.c: Likewise.
* coff-arm.c: Likewise.
* coff-h8300.c: Likewise.
* coff-h8500.c: Likewise.
* coff-i960.c: Likewise.
* coff-mcore.c: Likewise.
* coff-mips.c: Likewise.
* coff-ppc.c: Likewise.
* coff-rs6000.c: Likewise.
* coff-sh.c: Likewise.
* coff-tic80.c: Likewise.
* coff-w65.c: Likewise.
* coff-z80.c: Likewise.
* coff-z8k.c: Likewise.
* coff64-rs6000.c: Likewise.
* cofflink.c: Likewise.
* ecoff.c: Likewise.
* elf-bfd.h: Likewise.
* elf-m10200.c: Likewise.
* elf-m10300.c: Likewise.
* elf32-arc.c: Likewise.
* elf32-arm.c: Likewise.
* elf32-avr.c: Likewise.
* elf32-bfin.c: Likewise.
* elf32-cr16.c: Likewise.
* elf32-cr16c.c: Likewise.
* elf32-cris.c: Likewise.
* elf32-crx.c: Likewise.
* elf32-d10v.c: Likewise.
* elf32-epiphany.c: Likewise.
* elf32-fr30.c: Likewise.
* elf32-frv.c: Likewise.
* elf32-ft32.c: Likewise.
* elf32-h8300.c: Likewise.
* elf32-hppa.c: Likewise.
* elf32-i370.c: Likewise.
* elf32-i386.c: Likewise.
* elf32-i860.c: Likewise.
* elf32-ip2k.c: Likewise.
* elf32-iq2000.c: Likewise.
* elf32-lm32.c: Likewise.
* elf32-m32c.c: Likewise.
* elf32-m32r.c: Likewise.
* elf32-m68hc1x.c: Likewise.
* elf32-m68k.c: Likewise.
* elf32-mep.c: Likewise.
* elf32-metag.c: Likewise.
* elf32-microblaze.c: Likewise.
* elf32-moxie.c: Likewise.
* elf32-msp430.c: Likewise.
* elf32-mt.c: Likewise.
* elf32-nds32.c: Likewise.
* elf32-nios2.c: Likewise.
* elf32-or1k.c: Likewise.
* elf32-ppc.c: Likewise.
* elf32-s390.c: Likewise.
* elf32-score.c: Likewise.
* elf32-score7.c: Likewise.
* elf32-sh.c: Likewise.
* elf32-sh64.c: Likewise.
* elf32-spu.c: Likewise.
* elf32-tic6x.c: Likewise.
* elf32-tilepro.c: Likewise.
* elf32-v850.c: Likewise.
* elf32-vax.c: Likewise.
* elf32-visium.c: Likewise.
* elf32-xstormy16.c: Likewise.
* elf32-xtensa.c: Likewise.
* elf64-alpha.c: Likewise.
* elf64-hppa.c: Likewise.
* elf64-ia64-vms.c: Likewise.
* elf64-mmix.c: Likewise.
* elf64-ppc.c: Likewise.
* elf64-s390.c: Likewise.
* elf64-sh64.c: Likewise.
* elf64-x86-64.c: Likewise.
* elflink.c: Likewise.
* elfnn-aarch64.c: Likewise.
* elfnn-ia64.c: Likewise.
* elfxx-mips.c: Likewise.
* elfxx-sparc.c: Likewise.
* elfxx-tilegx.c: Likewise.
* linker.c: Likewise.
* pdp11.c: Likewise.
* pe-mips.c: Likewise.
* reloc.c: Likewise.
* reloc16.c: Likewise.
* simple.c: Likewise.
* vms-alpha.c: Likewise.
* xcofflink.c: Likewise.
* elf32-rl78.c (get_symbol_value, get_romstart, get_ramstart): Delete
status param. Adjust calls to these and linker callbacks throughout.
* elf32-rx.c: (get_symbol_value, get_gp, get_romstart,
get_ramstart): Delete status param. Adjust calls to these and
linker callbacks throughout.
ld/
* ldmain.c (multiple_definition, multiple_common, add_to_set,
constructor_callback, warning_callback, undefined_symbol,
reloc_overflow, reloc_dangerous, unattached_reloc): Return void.
* emultempl/elf32.em: Adjust callback calls.
gdb/
* compile/compile-object-load.c (link_callbacks_multiple_definition,
link_callbacks_warning, link_callbacks_undefined_symbol,
link_callbacks_undefined_symbol, link_callbacks_reloc_overflow,
link_callbacks_reloc_dangerous,
link_callbacks_unattached_reloc): Return void.
2016-05-27 09:50:55 +02:00
|
|
|
(*info->callbacks->warning) (info, msg, name, input_bfd,
|
|
|
|
input_section, rel->r_offset);
|
2004-03-30 16:04:32 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* CR16C ELF uses three common sections:
|
|
|
|
One is for default common symbols (placed in usual common section).
|
|
|
|
Second is for near common symbols (placed in "ncommon" section).
|
|
|
|
Third is for far common symbols (placed in "fcommon" section).
|
|
|
|
The following implementation is based on elf32-mips architecture */
|
|
|
|
|
|
|
|
static asection cr16c_elf_fcom_section;
|
|
|
|
static asymbol cr16c_elf_fcom_symbol;
|
|
|
|
static asymbol * cr16c_elf_fcom_symbol_ptr;
|
|
|
|
static asection cr16c_elf_ncom_section;
|
|
|
|
static asymbol cr16c_elf_ncom_symbol;
|
|
|
|
static asymbol * cr16c_elf_ncom_symbol_ptr;
|
|
|
|
|
|
|
|
/* Given a BFD section, try to locate the
|
|
|
|
corresponding ELF section index. */
|
|
|
|
|
|
|
|
static bfd_boolean
|
|
|
|
elf32_cr16c_section_from_bfd_section (bfd *abfd ATTRIBUTE_UNUSED,
|
|
|
|
asection *sec,
|
|
|
|
int *retval)
|
|
|
|
{
|
|
|
|
if (strcmp (bfd_get_section_name (abfd, sec), ".fcommon") == 0)
|
|
|
|
*retval = SHN_CR16C_FCOMMON;
|
|
|
|
else if (strcmp (bfd_get_section_name (abfd, sec), ".ncommon") == 0)
|
|
|
|
*retval = SHN_CR16C_NCOMMON;
|
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Handle the special CR16C section numbers that a symbol may use. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
elf32_cr16c_symbol_processing (bfd *abfd ATTRIBUTE_UNUSED,
|
|
|
|
asymbol *asym)
|
|
|
|
{
|
|
|
|
elf_symbol_type *elfsym = (elf_symbol_type *) asym;
|
|
|
|
unsigned int indx;
|
|
|
|
|
|
|
|
indx = elfsym->internal_elf_sym.st_shndx;
|
|
|
|
|
|
|
|
switch (indx)
|
|
|
|
{
|
|
|
|
case SHN_CR16C_FCOMMON:
|
|
|
|
if (cr16c_elf_fcom_section.name == NULL)
|
|
|
|
{
|
|
|
|
/* Initialize the far common section. */
|
|
|
|
cr16c_elf_fcom_section.name = ".fcommon";
|
|
|
|
cr16c_elf_fcom_section.flags = SEC_IS_COMMON | SEC_ALLOC;
|
|
|
|
cr16c_elf_fcom_section.output_section = &cr16c_elf_fcom_section;
|
|
|
|
cr16c_elf_fcom_section.symbol = &cr16c_elf_fcom_symbol;
|
|
|
|
cr16c_elf_fcom_section.symbol_ptr_ptr = &cr16c_elf_fcom_symbol_ptr;
|
|
|
|
cr16c_elf_fcom_symbol.name = ".fcommon";
|
|
|
|
cr16c_elf_fcom_symbol.flags = BSF_SECTION_SYM;
|
|
|
|
cr16c_elf_fcom_symbol.section = &cr16c_elf_fcom_section;
|
|
|
|
cr16c_elf_fcom_symbol_ptr = &cr16c_elf_fcom_symbol;
|
|
|
|
}
|
|
|
|
asym->section = &cr16c_elf_fcom_section;
|
|
|
|
asym->value = elfsym->internal_elf_sym.st_size;
|
|
|
|
break;
|
|
|
|
case SHN_CR16C_NCOMMON:
|
|
|
|
if (cr16c_elf_ncom_section.name == NULL)
|
|
|
|
{
|
|
|
|
/* Initialize the far common section. */
|
|
|
|
cr16c_elf_ncom_section.name = ".ncommon";
|
|
|
|
cr16c_elf_ncom_section.flags = SEC_IS_COMMON | SEC_ALLOC;
|
|
|
|
cr16c_elf_ncom_section.output_section = &cr16c_elf_ncom_section;
|
|
|
|
cr16c_elf_ncom_section.symbol = &cr16c_elf_ncom_symbol;
|
|
|
|
cr16c_elf_ncom_section.symbol_ptr_ptr = &cr16c_elf_ncom_symbol_ptr;
|
|
|
|
cr16c_elf_ncom_symbol.name = ".ncommon";
|
|
|
|
cr16c_elf_ncom_symbol.flags = BSF_SECTION_SYM;
|
|
|
|
cr16c_elf_ncom_symbol.section = &cr16c_elf_ncom_section;
|
|
|
|
cr16c_elf_ncom_symbol_ptr = &cr16c_elf_ncom_symbol;
|
|
|
|
}
|
|
|
|
asym->section = &cr16c_elf_ncom_section;
|
|
|
|
asym->value = elfsym->internal_elf_sym.st_size;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Hook called by the linker routine which adds symbols from an object
|
|
|
|
file. We must handle the special cr16c section numbers here. */
|
|
|
|
|
|
|
|
static bfd_boolean
|
|
|
|
elf32_cr16c_add_symbol_hook (bfd *abfd,
|
|
|
|
struct bfd_link_info *info ATTRIBUTE_UNUSED,
|
2004-04-02 17:26:04 +02:00
|
|
|
Elf_Internal_Sym *sym,
|
2004-03-30 16:04:32 +02:00
|
|
|
const char **namep ATTRIBUTE_UNUSED,
|
|
|
|
flagword *flagsp ATTRIBUTE_UNUSED,
|
|
|
|
asection **secp,
|
|
|
|
bfd_vma *valp)
|
|
|
|
{
|
|
|
|
unsigned int indx = sym->st_shndx;
|
|
|
|
|
|
|
|
switch (indx)
|
|
|
|
{
|
|
|
|
case SHN_CR16C_FCOMMON:
|
|
|
|
*secp = bfd_make_section_old_way (abfd, ".fcommon");
|
|
|
|
(*secp)->flags |= SEC_IS_COMMON;
|
|
|
|
*valp = sym->st_size;
|
|
|
|
break;
|
|
|
|
case SHN_CR16C_NCOMMON:
|
|
|
|
*secp = bfd_make_section_old_way (abfd, ".ncommon");
|
|
|
|
(*secp)->flags |= SEC_IS_COMMON;
|
|
|
|
*valp = sym->st_size;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2009-05-21 16:15:50 +02:00
|
|
|
static int
|
2004-03-30 16:04:32 +02:00
|
|
|
elf32_cr16c_link_output_symbol_hook (struct bfd_link_info *info ATTRIBUTE_UNUSED,
|
|
|
|
const char *name ATTRIBUTE_UNUSED,
|
|
|
|
Elf_Internal_Sym *sym,
|
|
|
|
asection *input_sec,
|
|
|
|
struct elf_link_hash_entry *h ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
/* If we see a common symbol, which implies a relocatable link, then
|
|
|
|
if a symbol was in a special common section in an input file, mark
|
|
|
|
it as a special common in the output file. */
|
|
|
|
|
|
|
|
if (sym->st_shndx == SHN_COMMON)
|
|
|
|
{
|
|
|
|
if (strcmp (input_sec->name, ".fcommon") == 0)
|
|
|
|
sym->st_shndx = SHN_CR16C_FCOMMON;
|
|
|
|
else if (strcmp (input_sec->name, ".ncommon") == 0)
|
|
|
|
sym->st_shndx = SHN_CR16C_NCOMMON;
|
|
|
|
}
|
|
|
|
|
2009-05-21 16:15:50 +02:00
|
|
|
return 1;
|
2004-03-30 16:04:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Definitions for setting CR16C target vector. */
|
bfd target vector rationalisation
This renames the bfd targets to <cpu>_<format>_<other>_<endian>_vec.
So for example, bfd_elf32_ntradlittlemips_vec becomes
mips_elf32_ntrad_le_vec and hp300bsd_vec becomes m68k_aout_hp300bsd_vec.
bfd/
* aix386-core.c, * aout-adobe.c, * aout-arm.c, * aout-ns32k.c,
* aout-sparcle.c, * aout0.c, * aoutx.h, * armnetbsd.c, * bout.c,
* cf-i386lynx.c, * cf-sparclynx.c, * cisco-core.c, * coff-alpha.c,
* coff-apollo.c, * coff-arm.c, * coff-aux.c, * coff-go32.c,
* coff-h8300.c, * coff-h8500.c, * coff-i386.c, * coff-i860.c,
* coff-i960.c, * coff-m68k.c, * coff-m88k.c, * coff-mips.c,
* coff-rs6000.c, * coff-sh.c, * coff-sparc.c, * coff-stgo32.c,
* coff-svm68k.c, * coff-tic80.c, * coff-u68k.c, * coff-w65.c,
* coff-we32k.c, * coff-x86_64.c, * coff-z80.c, * coff-z8k.c,
* coff64-rs6000.c, * config.bfd, * configure.com, * configure.in,
* demo64.c, * elf-m10200.c, * elf-m10300.c, * elf32-am33lin.c,
* elf32-arc.c, * elf32-arm.c, * elf32-avr.c, * elf32-bfin.c,
* elf32-cr16.c, * elf32-cr16c.c, * elf32-cris.c, * elf32-crx.c,
* elf32-d10v.c, * elf32-d30v.c, * elf32-dlx.c, * elf32-epiphany.c,
* elf32-fr30.c, * elf32-frv.c, * elf32-gen.c, * elf32-h8300.c,
* elf32-hppa.c, * elf32-i370.c, * elf32-i386.c, * elf32-i860.c,
* elf32-i960.c, * elf32-ip2k.c, * elf32-iq2000.c, * elf32-lm32.c,
* elf32-m32c.c, * elf32-m32r.c, * elf32-m68hc11.c, * elf32-m68hc12.c,
* elf32-m68k.c, * elf32-m88k.c, * elf32-mcore.c, * elf32-mep.c,
* elf32-metag.c, * elf32-microblaze.c, * elf32-mips.c, * elf32-moxie.c,
* elf32-msp430.c, * elf32-mt.c, * elf32-nds32.c, * elf32-nios2.c,
* elf32-or1k.c, * elf32-pj.c, * elf32-ppc.c, * elf32-rl78.c,
* elf32-rx.c, * elf32-s390.c, * elf32-score.c, * elf32-sh-symbian.c,
* elf32-sh.c, * elf32-sh64.c, * elf32-sparc.c, * elf32-spu.c,
* elf32-tic6x.c, * elf32-tilegx.c, * elf32-tilepro.c, * elf32-v850.c,
* elf32-vax.c, * elf32-xc16x.c, * elf32-xgate.c, * elf32-xstormy16.c,
* elf32-xtensa.c, * elf64-alpha.c, * elf64-gen.c, * elf64-hppa.c,
* elf64-ia64-vms.c, * elf64-mips.c, * elf64-mmix.c, * elf64-ppc.c,
* elf64-s390.c, * elf64-sh64.c, * elf64-sparc.c, * elf64-tilegx.c,
* elf64-x86-64.c, * elfn32-mips.c, * elfnn-aarch64.c, * elfnn-ia64.c,
* epoc-pe-arm.c, * epoc-pei-arm.c, * hp300bsd.c, * hp300hpux.c,
* hppabsd-core.c, * hpux-core.c, * i386aout.c, * i386bsd.c,
* i386dynix.c, * i386freebsd.c, * i386linux.c, * i386lynx.c,
* i386mach3.c, * i386msdos.c, * i386netbsd.c, * i386os9k.c,
* irix-core.c, * m68k4knetbsd.c, * m68klinux.c, * m68knetbsd.c,
* m88kmach3.c, * m88kopenbsd.c, * mach-o-i386.c, * mach-o-x86-64.c,
* makefile.vms, * mipsbsd.c, * mmo.c, * netbsd-core.c, * newsos3.c,
* nlm32-alpha.c, * nlm32-i386.c, * nlm32-ppc.c, * nlm32-sparc.c,
* ns32knetbsd.c, * osf-core.c, * pc532-mach.c, * pe-arm-wince.c,
* pe-arm.c, * pe-i386.c, * pe-mcore.c, * pe-mips.c, * pe-ppc.c,
* pe-sh.c, * pe-x86_64.c, * pei-arm-wince.c, * pei-arm.c,
* pei-i386.c, * pei-ia64.c, * pei-mcore.c, * pei-mips.c, * pei-ppc.c,
* pei-sh.c, * pei-x86_64.c, * ppcboot.c, * ptrace-core.c, * riscix.c,
* sco5-core.c, * som.c, * sparclinux.c, * sparclynx.c,
* sparcnetbsd.c, * sunos.c, * targets.c, * trad-core.c,
* vax1knetbsd.c, * vaxbsd.c, * vaxnetbsd.c, * versados.c,
* vms-alpha.c, * vms-lib.c: Rename bfd targets to
<cpu>_<format>_<other>_<endian>_vec. Adjust associated MY macros
on aout targets.
* configure: Regenerate.
binutils/
* emul_aix.c: Update bfd target vector naming.
* testsuite/binutils-all/objcopy.exp: Likewise.
ld/
* emultempl/metagelf.em: Update bfd target vector naming.
* emultempl/nios2elf.em: Likewise.
* emultempl/spuelf.em: Likewise.
* emultempl/tic6xdsbt.em: Likewise.
2014-05-02 12:39:40 +02:00
|
|
|
#define TARGET_LITTLE_SYM cr16c_elf32_vec
|
2004-03-30 16:04:32 +02:00
|
|
|
#define TARGET_LITTLE_NAME "elf32-cr16c"
|
|
|
|
#define ELF_ARCH bfd_arch_cr16c
|
|
|
|
#define ELF_MACHINE_CODE EM_CR
|
|
|
|
#define ELF_MAXPAGESIZE 0x1
|
|
|
|
#define elf_symbol_leading_char '_'
|
|
|
|
|
|
|
|
#define bfd_elf32_bfd_reloc_type_lookup elf_cr16c_reloc_type_lookup
|
2007-03-26 14:23:03 +02:00
|
|
|
#define bfd_elf32_bfd_reloc_name_lookup elf_cr16c_reloc_name_lookup
|
2004-03-30 16:04:32 +02:00
|
|
|
#define elf_info_to_howto elf_cr16c_info_to_howto
|
|
|
|
#define elf_info_to_howto_rel elf_cr16c_info_to_howto_rel
|
|
|
|
#define elf_backend_relocate_section elf32_cr16c_relocate_section
|
|
|
|
#define elf_backend_symbol_processing elf32_cr16c_symbol_processing
|
|
|
|
#define elf_backend_section_from_bfd_section elf32_cr16c_section_from_bfd_section
|
|
|
|
#define elf_backend_add_symbol_hook elf32_cr16c_add_symbol_hook
|
|
|
|
#define elf_backend_link_output_symbol_hook elf32_cr16c_link_output_symbol_hook
|
|
|
|
|
|
|
|
#define elf_backend_can_gc_sections 1
|
|
|
|
|
|
|
|
#include "elf32-target.h"
|