mirror of
https://github.com/darlinghq/darling-gdb.git
synced 2024-11-28 14:30:48 +00:00
157090f728
* aout-arm.c (MY_bfd_reloc_name_lookup): Define. (MY (bfd_reloc_name_lookup)): New function. * aout-ns32k.c (MY (bfd_reloc_name_lookup)): New function. * aout-target.h (NAME (aout, reloc_name_lookup)): Declare. (MY_bfd_reloc_name_lookup): Define. * aout-tic30.c (tic30_aout_reloc_name_lookup): New function. (MY_bfd_reloc_name_lookup): Define. * aoutx.h (NAME (aout, reloc_type_lookup)): Don't declare. (NAME (aout, reloc_name_lookup)): New function. * bout.c (b_out_bfd_reloc_name_lookup): New function. * coff-alpha.c (alpha_bfd_reloc_name_lookup): New function. (_bfd_ecoff_bfd_reloc_name_lookup): Define. * coff-arm.c (coff_arm_reloc_name_lookup): New function. (coff_bfd_reloc_name_lookup): Define. * coff-i386.c (coff_bfd_reloc_name_lookup): Define. (coff_i386_reloc_name_lookup): New function. * coff-i860.c (coff_i860_reloc_name_lookup): New function. (coff_bfd_reloc_name_lookup): Define. * coff-i960.c (coff_i960_reloc_name_lookup): New function. (coff_bfd_reloc_name_lookup): Define. * coff-m68k.c (m68k_reloc_name_lookup): New function. (coff_bfd_reloc_name_lookup): Define. * coff-maxq.c (maxq_reloc_name_lookup): New function. (coff_bfd_reloc_name_lookup): Define. * coff-mcore.c (mcore_coff_reloc_name_lookup): New function. (coff_bfd_reloc_name_lookup): Define. * coff-mips.c (mips_bfd_reloc_name_lookup): New function. (_bfd_ecoff_bfd_reloc_name_lookup): Define. * coff-ppc.c (ppc_coff_reloc_name_lookup): New function. (coff_bfd_reloc_name_lookup): Define. * coff-rs6000.c (coff_bfd_reloc_name_lookup): Define. (_bfd_xcoff_reloc_name_lookup): New function. (rs6000coff_vec, pmac_xcoff_vec): Init new field. * coff-sh.c (coff_bfd_reloc_name_lookup): Define. (sh_coff_reloc_name_lookup): New function. * coff-sparc.c (coff_sparc_reloc_name_lookup): New function. (coff_bfd_reloc_name_lookup): Define. * coff-tic30.c (coff_bfd_reloc_name_lookup): Define. (tic30_coff_reloc_name_lookup): New function. * coff-tic4x.c (coff_bfd_reloc_name_lookup): Define. (tic4x_coff_reloc_name_lookup): New function. * coff-tic54x.c (coff_bfd_reloc_name_lookup): Define. (tic54x_coff_reloc_name_lookup): New function. * coff-x86_64.c (coff_bfd_reloc_name_lookup): Define. (coff_amd64_reloc_name_lookup): New function. * coff-z80.c (coff_z80_reloc_name_lookup): New function. (coff_bfd_reloc_name_lookup): Define. * coff-z8k.c (coff_z8k_reloc_name_lookup): New function. (coff_bfd_reloc_name_lookup): Define. * coff64-rs6000.c (coff_bfd_reloc_name_lookup): Define. (xcoff64_reloc_name_lookup): New function. (rs6000coff64_vec, aix5coff64_vec): Init new field. * coffcode.h (coff_bfd_reloc_name_lookup): Define. * elf-hppa.h (elf_hppa_reloc_name_lookup): New function. * elf-m10200.c (bfd_elf32_bfd_reloc_name_lookup): New function. * elf-m10300.c (bfd_elf32_bfd_reloc_name_lookup): New function. * elf32-arc.c (bfd_elf32_bfd_reloc_name_lookup): New function. * elf32-arm.c (elf32_arm_reloc_name_lookup): New function. (bfd_elf32_bfd_reloc_name_lookup): Define. * elf32-avr.c (bfd_elf32_bfd_reloc_name_lookup): New function. * elf32-bfin.c (bfin_bfd_reloc_name_lookup): New function. (bfd_elf32_bfd_reloc_name_lookup): Define. * elf32-cr16c.c (elf_cr16c_reloc_name_lookup): New function. (bfd_elf32_bfd_reloc_name_lookup): Define. * elf32-cris.c (cris_reloc_name_lookup): New function. (bfd_elf32_bfd_reloc_name_lookup): Define. * elf32-crx.c (elf_crx_reloc_name_lookup): New function. (bfd_elf32_bfd_reloc_name_lookup): Define. * elf32-d10v.c (bfd_elf32_bfd_reloc_name_lookup): New function. * elf32-d30v.c (bfd_elf32_bfd_reloc_name_lookup): New function. * elf32-dlx.c (elf32_dlx_reloc_name_lookup): New function. (bfd_elf32_bfd_reloc_name_lookup): Define. * elf32-fr30.c (fr30_reloc_name_lookup): New function. (bfd_elf32_bfd_reloc_name_lookup): Define. * elf32-frv.c (frv_reloc_name_lookup): New function. (bfd_elf32_bfd_reloc_name_lookup): Define. * elf32-gen.c (bfd_elf32_bfd_reloc_name_lookup): Define. * elf32-h8300.c (elf32_h8_reloc_name_lookup): New function. (bfd_elf32_bfd_reloc_name_lookup): Define. * elf32-hppa.c (bfd_elf32_bfd_reloc_name_lookup): Define. * elf32-i370.c (i370_elf_reloc_name_lookup): New function. (bfd_elf32_bfd_reloc_name_lookup): Define. * elf32-i386.c (elf_i386_reloc_name_lookup): New function. (bfd_elf32_bfd_reloc_name_lookup): Define. * elf32-i860.c (elf32_i860_reloc_name_lookup): New function. (bfd_elf32_bfd_reloc_name_lookup): Define. * elf32-i960.c (elf32_i960_reloc_name_lookup): New function. (bfd_elf32_bfd_reloc_name_lookup): Define. * elf32-ip2k.c (ip2k_reloc_name_lookup): New function. (bfd_elf32_bfd_reloc_name_lookup): Define. * elf32-iq2000.c (iq2000_reloc_name_lookup): New function. (bfd_elf32_bfd_reloc_name_lookup): Define. * elf32-m32c.c (m32c_reloc_name_lookup): New function. (bfd_elf32_bfd_reloc_name_lookup): Define. * elf32-m32r.c (bfd_elf32_bfd_reloc_name_lookup): New function. * elf32-m68hc11.c (bfd_elf32_bfd_reloc_name_lookup): New function. * elf32-m68hc12.c (bfd_elf32_bfd_reloc_name_lookup): New function. * elf32-m68k.c (reloc_name_lookup): New function. (bfd_elf32_bfd_reloc_name_lookup): Define. * elf32-m88k.c (bfd_elf32_bfd_reloc_name_lookup): Define. * elf32-mcore.c (mcore_elf_reloc_name_lookup): New function. (bfd_elf32_bfd_reloc_name_lookup): Define. * elf32-mep.c (mep_reloc_name_lookup): New function. (bfd_elf32_bfd_reloc_name_lookup): Define. * elf32-mips.c (bfd_elf32_bfd_reloc_name_lookup): New function. (mips_vxworks_bfd_reloc_name_lookup): Likewise. (bfd_elf32_bfd_reloc_name_lookup): Define. * elf32-msp430.c (bfd_elf32_bfd_reloc_name_lookup): New function. * elf32-mt.c (mt_reloc_name_lookup): New function. (bfd_elf32_bfd_reloc_name_lookup): Define. * elf32-openrisc.c (openrisc_reloc_name_lookup): New function. (bfd_elf32_bfd_reloc_name_lookup): Define. * elf32-or32.c (bfd_elf32_bfd_reloc_name_lookup): New function. * elf32-pj.c (pj_elf_reloc_name_lookup): New function. (bfd_elf32_bfd_reloc_name_lookup): Define. * elf32-ppc.c (ppc_elf_reloc_name_lookup): New function. (bfd_elf32_bfd_reloc_name_lookup): Define. * elf32-s390.c (elf_s390_reloc_name_lookup): New function. (bfd_elf32_bfd_reloc_name_lookup): Define. * elf32-score.c (elf32_score_reloc_name_lookup): New function. (bfd_elf32_bfd_reloc_name_lookup): Define. * elf32-sh.c (sh_elf_reloc_name_lookup): New function. (bfd_elf32_bfd_reloc_name_lookup): Define. * elf32-sparc.c (bfd_elf32_bfd_reloc_name_lookup): Define. * elf32-spu.c (spu_elf_reloc_name_lookup): New function. (bfd_elf32_bfd_reloc_name_lookup): Define. * elf32-v850.c (v850_elf_reloc_name_lookup): New function. (bfd_elf32_bfd_reloc_name_lookup): Define. * elf32-vax.c (reloc_name_lookup): New function. (bfd_elf32_bfd_reloc_name_lookup): Define. * elf32-xc16x.c (xc16x_reloc_name_lookup): New function. (bfd_elf32_bfd_reloc_name_lookup): Define. * elf32-xstormy16.c (xstormy16_reloc_name_lookup): New function. (bfd_elf32_bfd_reloc_name_lookup): Define. * elf32-xtensa.c (elf_xtensa_reloc_name_lookup): New function. (bfd_elf32_bfd_reloc_name_lookup): Define. * elf64-alpha.c (elf64_alpha_bfd_reloc_name_lookup): New function. (bfd_elf64_bfd_reloc_name_lookup): Define. * elf64-gen.c (bfd_elf64_bfd_reloc_name_lookup): Define. * elf64-hppa.c (bfd_elf64_bfd_reloc_name_lookup): Define. * elf64-mips.c (bfd_elf64_bfd_reloc_name_lookup): New function. * elf64-mmix.c (bfd_elf64_bfd_reloc_name_lookup): New function. * elf64-ppc.c (ppc64_elf_reloc_name_lookup): New function. (bfd_elf64_bfd_reloc_name_lookup): Define. * elf64-s390.c (elf_s390_reloc_name_lookup): New function. (bfd_elf64_bfd_reloc_name_lookup): Define. * elf64-sh64.c (sh_elf64_reloc_name_lookup): New function. (bfd_elf64_bfd_reloc_name_lookup): Define. * elf64-sparc.c (bfd_elf64_bfd_reloc_name_lookup): Define. * elf64-x86-64.c (elf64_x86_64_reloc_name_lookup): New function. (bfd_elf64_bfd_reloc_name_lookup): Define. * elfn32-mips.c (bfd_elf32_bfd_reloc_name_lookup): New function. * elfxx-ia64.c (elfNN_ia64_reloc_name_lookup): New function. (bfd_elfNN_bfd_reloc_name_lookup): Define. * elfxx-sparc.c (_bfd_sparc_elf_reloc_name_lookup): New function. * elfxx-sparc.h (_bfd_sparc_elf_reloc_name_lookup): Declare. * i386msdos.c (msdos_bfd_reloc_name_lookup): Define. * i386os9k.c (aout_32_bfd_reloc_name_lookup): Define. * ieee.c (ieee_bfd_reloc_name_lookup): Define. * libaout.h (NAME (aout, reloc_name_lookup)): Declare. * libbfd-in.h (_bfd_norelocs_bfd_reloc_name_lookup): Declare. * mipsbsd.c (MY_bfd_reloc_name_lookup): Define. (MY(reloc_type_lookup)): Rename from MY(reloc_howto_type_lookup). (MY(reloc_name_lookup)): New function. * nlm-target.h (nlm_bfd_reloc_name_lookup): Define. * oasys.c (oasys_bfd_reloc_name_lookup): Define. * pdp11.c (NAME (aout, reloc_name_lookup)): New function. * pe-mips.c (coff_mips_reloc_name_lookup): New function. (coff_bfd_reloc_name_lookup): Define. * reloc.c (bfd_reloc_name_lookup): New function. * riscix.c (riscix_reloc_name_lookup): New function. (MY_bfd_reloc_name_lookup): Define. * som.c (som_bfd_reloc_name_lookup): New function. * targets.c (struct bfd_target): Add reloc_name_lookup. (BFD_JUMP_TABLE_RELOCS): Add NAME##_bfd_reloc_name_lookup. * versados.c (versados_bfd_reloc_name_lookup): Define. * vms.c (vms_bfd_reloc_name_lookup): New function. * bfd-in2.h: Regenerate. * libbfd.h: Regenerate.
444 lines
12 KiB
C
444 lines
12 KiB
C
/* BFD back-end for MAXQ COFF binaries.
|
|
Copyright 2004, 2007 Free Software Foundation, Inc.
|
|
|
|
Contributed by Vineet Sharma (vineets@noida.hcltech.com) Inderpreet S.
|
|
(inderpreetb@noida.hcltech.com)
|
|
|
|
HCL Technologies Ltd.
|
|
|
|
This file is part of BFD, the Binary File Descriptor library.
|
|
|
|
This program is free software; you can redistribute it and/or modify it
|
|
under the terms of the GNU General Public License as published by the Free
|
|
Software Foundation; either version 2 of the License, or (at your option)
|
|
any later version.
|
|
|
|
This program is distributed in the hope that it will be useful, but
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
for more details.
|
|
|
|
You should have received a copy of the GNU General Public License along
|
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
|
51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
|
|
|
|
#include "bfd.h"
|
|
#include "sysdep.h"
|
|
#include "libbfd.h"
|
|
#include "coff/maxq.h"
|
|
#include "coff/internal.h"
|
|
#include "libcoff.h"
|
|
#include "libiberty.h"
|
|
|
|
#ifndef MAXQ20
|
|
#define MAXQ20 1
|
|
#endif
|
|
|
|
#define RTYPE2HOWTO(cache_ptr, dst) \
|
|
((cache_ptr)->howto = \
|
|
((dst)->r_type < 48 \
|
|
? howto_table + (((dst)->r_type==47) ? 6: ((dst)->r_type)) \
|
|
: NULL))
|
|
|
|
#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2)
|
|
|
|
/* Code to swap in the reloc offset. */
|
|
#define SWAP_IN_RELOC_OFFSET H_GET_16
|
|
#define SWAP_OUT_RELOC_OFFSET H_PUT_16
|
|
|
|
#define SHORT_JUMP BFD_RELOC_16_PCREL_S2
|
|
#define LONG_JUMP BFD_RELOC_14
|
|
#define ABSOLUTE_ADDR_FOR_DATA BFD_RELOC_24
|
|
|
|
/* checks the range of short jump -127 to 128 */
|
|
#define IS_SJUMP_RANGE(x) ((x > -128) && (x < 129))
|
|
#define HIGH_WORD_MASK 0xff00
|
|
#define LOW_WORD_MASK 0x00ff
|
|
|
|
static long
|
|
get_symbol_value (asymbol *symbol)
|
|
{
|
|
long relocation = 0;
|
|
|
|
if (bfd_is_com_section (symbol->section))
|
|
relocation = 0;
|
|
else
|
|
relocation = symbol->value +
|
|
symbol->section->output_section->vma + symbol->section->output_offset;
|
|
|
|
return relocation;
|
|
}
|
|
|
|
/* This function performs all the maxq relocations.
|
|
FIXME: The handling of the addend in the 'BFD_*'
|
|
relocations types. */
|
|
|
|
static bfd_reloc_status_type
|
|
coff_maxq20_reloc (bfd * abfd,
|
|
arelent * reloc_entry,
|
|
asymbol * symbol_in,
|
|
void * data,
|
|
asection * input_section ATTRIBUTE_UNUSED,
|
|
bfd * output_bfd ATTRIBUTE_UNUSED,
|
|
char ** error_message ATTRIBUTE_UNUSED)
|
|
{
|
|
unsigned char *addr = NULL;
|
|
unsigned long x = 0;
|
|
long call_addr = 0;
|
|
short addend = 0;
|
|
long diff = 0;
|
|
|
|
/* If this is an undefined symbol, return error. */
|
|
if (symbol_in->section == &bfd_und_section
|
|
&& (symbol_in->flags & BSF_WEAK) == 0)
|
|
return bfd_reloc_continue;
|
|
|
|
if (data && reloc_entry)
|
|
{
|
|
addr = (unsigned char *) data + reloc_entry->address;
|
|
call_addr = call_addr - call_addr;
|
|
call_addr = get_symbol_value (symbol_in);
|
|
|
|
/* Over here the value val stores the 8 bit/16 bit value. We will put a
|
|
check if we are moving a 16 bit immediate value into an 8 bit
|
|
register. In that case we will generate a Upper bytes into PFX[0]
|
|
and move the lower 8 bits as SRC. */
|
|
|
|
switch (reloc_entry->howto->type)
|
|
{
|
|
/* BFD_RELOC_16_PCREL_S2 47 Handles all the relative jumps and
|
|
calls Note: Every relative jump or call is in words. */
|
|
case SHORT_JUMP:
|
|
/* Handle any addend. */
|
|
addend = reloc_entry->addend;
|
|
|
|
if (addend > call_addr || addend > 0)
|
|
call_addr = symbol_in->section->output_section->vma + addend;
|
|
else if (addend < call_addr && addend > 0)
|
|
call_addr = call_addr + addend;
|
|
else if (addend < 0)
|
|
call_addr = call_addr + addend;
|
|
|
|
diff = ((call_addr << 1) - (reloc_entry->address << 1));
|
|
|
|
if (!IS_SJUMP_RANGE (diff))
|
|
{
|
|
bfd_perror (_("Can't Make it a Short Jump"));
|
|
return bfd_reloc_outofrange;
|
|
}
|
|
|
|
x = bfd_get_16 (abfd, addr);
|
|
|
|
x = x & LOW_WORD_MASK;
|
|
x = x | (diff << 8);
|
|
bfd_put_16 (abfd, (bfd_vma) x, addr);
|
|
|
|
return bfd_reloc_ok;
|
|
|
|
case ABSOLUTE_ADDR_FOR_DATA:
|
|
case LONG_JUMP:
|
|
/* BFD_RELOC_14 Handles intersegment or long jumps which might be
|
|
from code to code or code to data segment jumps. Note: When this
|
|
fucntion is called by gas the section flags somehow do not
|
|
contain the info about the section type(CODE or DATA). Thus the
|
|
user needs to evoke the linker after assembling the files
|
|
because the Code-Code relocs are word aligned but code-data are
|
|
byte aligned. */
|
|
addend = (reloc_entry->addend - reloc_entry->addend);
|
|
|
|
/* Handle any addend. */
|
|
addend = reloc_entry->addend;
|
|
|
|
/* For relocation involving multiple file added becomes zero thus
|
|
this fails - check for zero added. In another case when we try
|
|
to add a stub to a file the addend shows the offset from the
|
|
start od this file. */
|
|
addend = 0;
|
|
|
|
if (!bfd_is_com_section (symbol_in->section) &&
|
|
((symbol_in->flags & BSF_OLD_COMMON) == 0))
|
|
{
|
|
if (reloc_entry->addend > symbol_in->value)
|
|
addend = reloc_entry->addend - symbol_in->value;
|
|
|
|
if ((reloc_entry->addend < symbol_in->value)
|
|
&& (reloc_entry->addend != 0))
|
|
addend = reloc_entry->addend - symbol_in->value;
|
|
|
|
if (reloc_entry->addend == symbol_in->value)
|
|
addend = 0;
|
|
}
|
|
|
|
if (bfd_is_com_section (symbol_in->section) ||
|
|
((symbol_in->flags & BSF_OLD_COMMON) != 0))
|
|
addend = reloc_entry->addend;
|
|
|
|
if (addend < 0
|
|
&& (call_addr < (long) (addend * (-1))))
|
|
addend = 0;
|
|
|
|
call_addr += addend;
|
|
|
|
/* FIXME: This check does not work well with the assembler,
|
|
linker needs to be run always. */
|
|
if ((symbol_in->section->flags & SEC_CODE) == SEC_CODE)
|
|
{
|
|
/* Convert it into words. */
|
|
call_addr = call_addr >> 1;
|
|
|
|
if (call_addr > 0xFFFF) /* Intersegment Jump. */
|
|
{
|
|
bfd_perror (_("Exceeds Long Jump Range"));
|
|
return bfd_reloc_outofrange;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
/* case ABSOLUTE_ADDR_FOR_DATA : Resolves any code-data
|
|
segemnt relocs. These are NOT word aligned. */
|
|
|
|
if (call_addr > 0xFFFF) /* Intersegment Jump. */
|
|
{
|
|
bfd_perror (_("Absolute address Exceeds 16 bit Range"));
|
|
return bfd_reloc_outofrange;
|
|
}
|
|
}
|
|
|
|
x = bfd_get_32 (abfd, addr);
|
|
|
|
x = (x & 0xFF00FF00);
|
|
x = (x | ((call_addr & HIGH_WORD_MASK) >> 8));
|
|
x = (x | (call_addr & LOW_WORD_MASK) << 16);
|
|
|
|
bfd_put_32 (abfd, (bfd_vma) x, addr);
|
|
return bfd_reloc_ok;
|
|
|
|
case BFD_RELOC_8:
|
|
addend = (reloc_entry->addend - reloc_entry->addend);
|
|
|
|
if (!bfd_is_com_section (symbol_in->section) &&
|
|
((symbol_in->flags & BSF_OLD_COMMON) == 0))
|
|
{
|
|
if (reloc_entry->addend > symbol_in->value)
|
|
addend = reloc_entry->addend - symbol_in->value;
|
|
if (reloc_entry->addend < symbol_in->value)
|
|
addend = reloc_entry->addend - symbol_in->value;
|
|
if (reloc_entry->addend == symbol_in->value)
|
|
addend = 0;
|
|
}
|
|
|
|
if (bfd_is_com_section (symbol_in->section) ||
|
|
((symbol_in->flags & BSF_OLD_COMMON) != 0))
|
|
addend = reloc_entry->addend;
|
|
|
|
if (addend < 0
|
|
&& (call_addr < (long) (addend * (-1))))
|
|
addend = 0;
|
|
|
|
if (call_addr + addend > 0xFF)
|
|
{
|
|
bfd_perror (_("Absolute address Exceeds 8 bit Range"));
|
|
return bfd_reloc_outofrange;
|
|
}
|
|
|
|
x = bfd_get_8 (abfd, addr);
|
|
x = x & 0x00;
|
|
x = x | (call_addr + addend);
|
|
|
|
bfd_put_8 (abfd, (bfd_vma) x, addr);
|
|
return bfd_reloc_ok;
|
|
|
|
case BFD_RELOC_16:
|
|
addend = (reloc_entry->addend - reloc_entry->addend);
|
|
if (!bfd_is_com_section (symbol_in->section) &&
|
|
((symbol_in->flags & BSF_OLD_COMMON) == 0))
|
|
{
|
|
if (reloc_entry->addend > symbol_in->value)
|
|
addend = reloc_entry->addend - symbol_in->value;
|
|
|
|
if (reloc_entry->addend < symbol_in->value)
|
|
addend = reloc_entry->addend - symbol_in->value;
|
|
|
|
if (reloc_entry->addend == symbol_in->value)
|
|
addend = 0;
|
|
}
|
|
|
|
if (bfd_is_com_section (symbol_in->section) ||
|
|
((symbol_in->flags & BSF_OLD_COMMON) != 0))
|
|
addend = reloc_entry->addend;
|
|
|
|
if (addend < 0
|
|
&& (call_addr < (long) (addend * (-1))))
|
|
addend = 0;
|
|
|
|
if ((call_addr + addend) > 0xFFFF)
|
|
{
|
|
bfd_perror (_("Absolute address Exceeds 16 bit Range"));
|
|
return bfd_reloc_outofrange;
|
|
}
|
|
else
|
|
{
|
|
unsigned short val = (call_addr + addend);
|
|
|
|
x = bfd_get_16 (abfd, addr);
|
|
|
|
/* LE */
|
|
x = (x & 0x0000); /* Flush garbage value. */
|
|
x = val;
|
|
if ((symbol_in->section->flags & SEC_CODE) == SEC_CODE)
|
|
x = x >> 1; /* Convert it into words. */
|
|
}
|
|
|
|
bfd_put_16 (abfd, (bfd_vma) x, addr);
|
|
return bfd_reloc_ok;
|
|
|
|
case BFD_RELOC_32:
|
|
addend = (reloc_entry->addend - reloc_entry->addend);
|
|
|
|
if (!bfd_is_com_section (symbol_in->section) &&
|
|
((symbol_in->flags & BSF_OLD_COMMON) == 0))
|
|
{
|
|
if (reloc_entry->addend > symbol_in->value)
|
|
addend = reloc_entry->addend - symbol_in->value;
|
|
if (reloc_entry->addend < symbol_in->value)
|
|
addend = reloc_entry->addend - symbol_in->value;
|
|
if (reloc_entry->addend == symbol_in->value)
|
|
addend = 0;
|
|
}
|
|
|
|
if (bfd_is_com_section (symbol_in->section) ||
|
|
((symbol_in->flags & BSF_OLD_COMMON) != 0))
|
|
addend = reloc_entry->addend;
|
|
|
|
if (addend < 0
|
|
&& (call_addr < (long) (addend * (-1))))
|
|
addend = 0;
|
|
|
|
if ((call_addr + addend) < 0)
|
|
{
|
|
bfd_perror ("Absolute address Exceeds 32 bit Range");
|
|
return bfd_reloc_outofrange;
|
|
}
|
|
|
|
x = bfd_get_32 (abfd, addr);
|
|
x = (x & 0x0000); /* Flush garbage value. */
|
|
x = call_addr + addend;
|
|
if ((symbol_in->section->flags & SEC_CODE) == SEC_CODE)
|
|
x = x >> 1; /* Convert it into words. */
|
|
|
|
bfd_put_32 (abfd, (bfd_vma) x, addr);
|
|
return bfd_reloc_ok;
|
|
|
|
default:
|
|
bfd_perror (_("Unrecognized Reloc Type"));
|
|
return bfd_reloc_notsupported;
|
|
}
|
|
}
|
|
|
|
return bfd_reloc_notsupported;
|
|
}
|
|
|
|
static reloc_howto_type howto_table[] =
|
|
{
|
|
EMPTY_HOWTO (0),
|
|
EMPTY_HOWTO (1),
|
|
{
|
|
BFD_RELOC_32, 0, 1, 8, FALSE, 0, complain_overflow_bitfield,
|
|
coff_maxq20_reloc, "32Bit", TRUE, 0x000000ff, 0x000000ff, TRUE
|
|
},
|
|
{
|
|
SHORT_JUMP, 0, 1, 8, FALSE, 0, complain_overflow_bitfield,
|
|
coff_maxq20_reloc, "SHORT_JMP", TRUE, 0x000000ff, 0x000000ff, TRUE
|
|
},
|
|
{
|
|
ABSOLUTE_ADDR_FOR_DATA, 0, 2, 32, FALSE, 0, complain_overflow_bitfield,
|
|
coff_maxq20_reloc, "INTERSEGMENT_RELOC", TRUE, 0x00000000, 0x00000000,
|
|
FALSE
|
|
},
|
|
{
|
|
BFD_RELOC_16, 0, 1, 8, FALSE, 0, complain_overflow_bitfield,
|
|
coff_maxq20_reloc, "16Bit", TRUE, 0x000000ff, 0x000000ff, TRUE
|
|
},
|
|
{
|
|
LONG_JUMP, 0, 2, 32, FALSE, 0, complain_overflow_bitfield,
|
|
coff_maxq20_reloc, "LONG_JUMP", TRUE, 0x00000000, 0x00000000, FALSE
|
|
},
|
|
{
|
|
BFD_RELOC_8, 0, 1, 8, FALSE, 0, complain_overflow_bitfield,
|
|
coff_maxq20_reloc, "8bit", TRUE, 0x000000ff, 0x000000ff, TRUE
|
|
},
|
|
EMPTY_HOWTO (8),
|
|
EMPTY_HOWTO (9),
|
|
EMPTY_HOWTO (10),
|
|
};
|
|
|
|
static reloc_howto_type *
|
|
maxq_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
|
|
bfd_reloc_code_real_type code)
|
|
{
|
|
switch (code)
|
|
{
|
|
/* SHORT JUMP */
|
|
case BFD_RELOC_16_PCREL_S2:
|
|
return howto_table + 3;
|
|
|
|
/* INTERSEGMENT JUMP */
|
|
case BFD_RELOC_24:
|
|
return howto_table + 4;
|
|
|
|
/* BYTE RELOC */
|
|
case BFD_RELOC_8:
|
|
return howto_table + 7;
|
|
|
|
/* WORD RELOC */
|
|
case BFD_RELOC_16:
|
|
return howto_table + 5;
|
|
|
|
/* LONG RELOC */
|
|
case BFD_RELOC_32:
|
|
return howto_table + 2;
|
|
|
|
/* LONG JUMP */
|
|
case BFD_RELOC_14:
|
|
return howto_table + 6;
|
|
|
|
default:
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
static reloc_howto_type *
|
|
maxq_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, const char *r_name)
|
|
{
|
|
unsigned int i;
|
|
|
|
for (i = 0; i < sizeof (howto_table) / sizeof (howto_table[0]); i++)
|
|
if (howto_table[i].name != NULL
|
|
&& strcasecmp (howto_table[i].name, r_name) == 0)
|
|
return &howto_table[i];
|
|
|
|
return NULL;
|
|
}
|
|
|
|
#define coff_bfd_reloc_type_lookup maxq_reloc_type_lookup
|
|
#define coff_bfd_reloc_name_lookup maxq_reloc_name_lookup
|
|
|
|
/* Perform any necessary magic to the addend in a reloc entry. */
|
|
#define CALC_ADDEND(abfd, symbol, ext_reloc, cache_ptr) \
|
|
cache_ptr->addend = ext_reloc.r_offset;
|
|
|
|
#include "coffcode.h"
|
|
|
|
#ifndef TARGET_UNDERSCORE
|
|
#define TARGET_UNDERSCORE 1
|
|
#endif
|
|
|
|
#ifndef EXTRA_S_FLAGS
|
|
#define EXTRA_S_FLAGS 0
|
|
#endif
|
|
|
|
/* Forward declaration for use initialising alternative_target field. */
|
|
CREATE_LITTLE_COFF_TARGET_VEC (maxqcoff_vec, "coff-maxq", 0, EXTRA_S_FLAGS,
|
|
TARGET_UNDERSCORE, NULL, COFF_SWAP_TABLE);
|
|
|