diff options
author | Christian Groessler <chris@groessler.org> | 2003-08-27 13:28:42 +0000 |
---|---|---|
committer | Christian Groessler <chris@groessler.org> | 2003-08-27 13:28:42 +0000 |
commit | d539b3aa78c59cc1cf7adace42150a5dec88932e (patch) | |
tree | 1e5d32b71a50c8d3458f73e0fe47df230d153000 /bfd/elf32-i860.c | |
parent | 73052b5e963199196fe53f05e0a3732e92a7de68 (diff) | |
download | gdb-d539b3aa78c59cc1cf7adace42150a5dec88932e.zip gdb-d539b3aa78c59cc1cf7adace42150a5dec88932e.tar.gz gdb-d539b3aa78c59cc1cf7adace42150a5dec88932e.tar.bz2 |
2003-08-27 Christian Groessler <chris@groessler.org>
* elf32-i860.c (i860_howto_pc26_reloc, i860_howto_pc16_reloc,
i860_howto_splitn_reloc, i860_howto_highadj_reloc): New
functions.
(elf32_i860_howto_table): Insert the new functions as
'special_function's in the proper reloc type entries.
Diffstat (limited to 'bfd/elf32-i860.c')
-rw-r--r-- | bfd/elf32-i860.c | 204 |
1 files changed, 198 insertions, 6 deletions
diff --git a/bfd/elf32-i860.c b/bfd/elf32-i860.c index 0e013ef..b523fb3 100644 --- a/bfd/elf32-i860.c +++ b/bfd/elf32-i860.c @@ -26,6 +26,198 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "elf-bfd.h" #include "elf/i860.h" +/* special_function for R_860_PC26 relocation. + Derived from bfd_elf_generic_reloc (elf.c) with modifications. */ +static bfd_reloc_status_type +i860_howto_pc26_reloc (bfd *abfd ATTRIBUTE_UNUSED, + arelent *reloc_entry, + asymbol *symbol, + void *data ATTRIBUTE_UNUSED, + asection *input_section, + bfd *output_bfd, + char **error_message ATTRIBUTE_UNUSED) +{ + if (output_bfd != NULL + && (symbol->flags & BSF_SECTION_SYM) == 0 + && (! reloc_entry->howto->partial_inplace + || reloc_entry->addend == 0)) + { + reloc_entry->address += input_section->output_offset; + return bfd_reloc_ok; + } + + reloc_entry->addend -= 4; + return bfd_reloc_continue; +} + +/* special_function for R_860_PC16 relocation. */ +static bfd_reloc_status_type +i860_howto_pc16_reloc (bfd *abfd, + arelent *reloc_entry, + asymbol *symbol, + void *data, + asection *input_section, + bfd *output_bfd, + char **error_message ATTRIBUTE_UNUSED) +{ + bfd_vma insn; + bfd_vma relocation; + bfd_byte *addr; + + if (output_bfd != NULL + && (symbol->flags & BSF_SECTION_SYM) == 0 + && (! reloc_entry->howto->partial_inplace + || reloc_entry->addend == 0)) + { + reloc_entry->address += input_section->output_offset; + return bfd_reloc_ok; + } + + /* Used elf32-mips.c as an example. */ + if (bfd_is_und_section (symbol->section) + && output_bfd == (bfd *) NULL) + return bfd_reloc_undefined; + + if (bfd_is_com_section (symbol->section)) + relocation = 0; + else + relocation = symbol->value; + + relocation += symbol->section->output_section->vma; + relocation += symbol->section->output_offset; + relocation += reloc_entry->addend; + + if (reloc_entry->address > input_section->_cooked_size) + return bfd_reloc_outofrange; + + /* Adjust for PC-relative relocation. */ + relocation -= (input_section->output_section->vma + + input_section->output_offset + + reloc_entry->address + + 4); + + /* Check for target out of range. */ + if ((bfd_signed_vma)relocation > (0x7fff << 2) + || (bfd_signed_vma)relocation < (-0x8000 << 2)) + return bfd_reloc_outofrange; + + addr = (bfd_byte *) data + reloc_entry->address; + insn = bfd_get_32 (abfd, addr); + + relocation >>= reloc_entry->howto->rightshift; + relocation = (((relocation & 0xf800) << 5) | (relocation & 0x7ff)) + & reloc_entry->howto->dst_mask; + insn = (insn & ~reloc_entry->howto->dst_mask) | relocation; + + bfd_put_32 (abfd, (bfd_vma) insn, addr); + + return bfd_reloc_ok; +} + +/* special_function for R_860_HIGHADJ relocation. */ +static bfd_reloc_status_type +i860_howto_highadj_reloc (bfd *abfd, + arelent *reloc_entry, + asymbol *symbol, + void *data, + asection *input_section, + bfd *output_bfd, + char **error_message ATTRIBUTE_UNUSED) +{ + bfd_vma insn; + bfd_vma relocation; + bfd_byte *addr; + + if (output_bfd != NULL + && (symbol->flags & BSF_SECTION_SYM) == 0 + && (! reloc_entry->howto->partial_inplace + || reloc_entry->addend == 0)) + { + reloc_entry->address += input_section->output_offset; + return bfd_reloc_ok; + } + + /* Used elf32-mips.c as an example. */ + if (bfd_is_und_section (symbol->section) + && output_bfd == (bfd *) NULL) + return bfd_reloc_undefined; + + if (bfd_is_com_section (symbol->section)) + relocation = 0; + else + relocation = symbol->value; + + relocation += symbol->section->output_section->vma; + relocation += symbol->section->output_offset; + relocation += reloc_entry->addend; + relocation += 0x8000; + + if (reloc_entry->address > input_section->_cooked_size) + return bfd_reloc_outofrange; + + addr = (bfd_byte *) data + reloc_entry->address; + insn = bfd_get_32 (abfd, addr); + + relocation = ((relocation >> 16) & 0xffff); + + insn = (insn & 0xffff0000) | relocation; + + bfd_put_32 (abfd, (bfd_vma) insn, addr); + + return bfd_reloc_ok; +} + +/* special_function for R_860_SPLITn relocations. */ +static bfd_reloc_status_type +i860_howto_splitn_reloc (bfd *abfd, + arelent *reloc_entry, + asymbol *symbol, + void *data, + asection *input_section, + bfd *output_bfd, + char **error_message ATTRIBUTE_UNUSED) +{ + bfd_vma insn; + bfd_vma relocation; + bfd_byte *addr; + + if (output_bfd != NULL + && (symbol->flags & BSF_SECTION_SYM) == 0 + && (! reloc_entry->howto->partial_inplace + || reloc_entry->addend == 0)) + { + reloc_entry->address += input_section->output_offset; + return bfd_reloc_ok; + } + + /* Used elf32-mips.c as an example. */ + if (bfd_is_und_section (symbol->section) + && output_bfd == (bfd *) NULL) + return bfd_reloc_undefined; + + if (bfd_is_com_section (symbol->section)) + relocation = 0; + else + relocation = symbol->value; + + relocation += symbol->section->output_section->vma; + relocation += symbol->section->output_offset; + relocation += reloc_entry->addend; + + if (reloc_entry->address > input_section->_cooked_size) + return bfd_reloc_outofrange; + + addr = (bfd_byte *) data + reloc_entry->address; + insn = bfd_get_32 (abfd, addr); + + relocation = (((relocation & 0xf800) << 5) | (relocation & 0x7ff)) + & reloc_entry->howto->dst_mask; + insn = (insn & ~reloc_entry->howto->dst_mask) | relocation; + + bfd_put_32 (abfd, (bfd_vma) insn, addr); + + return bfd_reloc_ok; +} /* This howto table is preliminary. */ static reloc_howto_type elf32_i860_howto_table [] = @@ -124,7 +316,7 @@ static reloc_howto_type elf32_i860_howto_table [] = TRUE, /* pc_relative */ 0, /* bitpos */ complain_overflow_bitfield, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + i860_howto_pc26_reloc, /* special_function */ "R_860_PC26", /* name */ FALSE, /* partial_inplace */ 0x3ffffff, /* src_mask */ @@ -153,7 +345,7 @@ static reloc_howto_type elf32_i860_howto_table [] = TRUE, /* pc_relative */ 0, /* bitpos */ complain_overflow_bitfield, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + i860_howto_pc16_reloc, /* special_function */ "R_860_PC16", /* name */ FALSE, /* partial_inplace */ 0x1f07ff, /* src_mask */ @@ -181,7 +373,7 @@ static reloc_howto_type elf32_i860_howto_table [] = FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + i860_howto_splitn_reloc, /* special_function */ "R_860_SPLIT0", /* name */ FALSE, /* partial_inplace */ 0x1f07ff, /* src_mask */ @@ -209,7 +401,7 @@ static reloc_howto_type elf32_i860_howto_table [] = FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + i860_howto_splitn_reloc, /* special_function */ "R_860_SPLIT1", /* name */ FALSE, /* partial_inplace */ 0x1f07fe, /* src_mask */ @@ -237,7 +429,7 @@ static reloc_howto_type elf32_i860_howto_table [] = FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + i860_howto_splitn_reloc, /* special_function */ "R_860_SPLIT2", /* name */ FALSE, /* partial_inplace */ 0x1f07fc, /* src_mask */ @@ -419,7 +611,7 @@ static reloc_howto_type elf32_i860_howto_table [] = FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + i860_howto_highadj_reloc, /* special_function */ "R_860_HIGHADJ", /* name */ FALSE, /* partial_inplace */ 0xffff, /* src_mask */ |