📄 aout-arm.c
字号:
relocation += reloc_entry->addend; relocation -= input_section->output_section->vma; relocation -= input_section->output_offset; relocation -= addr; if (relocation & 3) return bfd_reloc_overflow; /* Check for overflow */ if (relocation & 0x02000000) { if ((relocation & ~ (bfd_vma) 0x03ffffff) != ~ (bfd_vma) 0x03ffffff) flag = bfd_reloc_overflow; } else if (relocation & ~0x03ffffff) flag = bfd_reloc_overflow; target &= ~0x00ffffff; target |= (relocation >> 2) & 0x00ffffff; bfd_put_32 (abfd, target, (bfd_byte *) data + addr); /* Now the ARM magic... Change the reloc type so that it is marked as done. Strictly this is only necessary if we are doing a partial relocation. */ reloc_entry->howto = &MY(howto_table)[7]; return flag;}reloc_howto_type *MY(bfd_reloc_type_lookup) (abfd,code) bfd *abfd; bfd_reloc_code_real_type code;{#define ASTD(i,j) case i: return &MY(howto_table)[j] if (code == BFD_RELOC_CTOR) switch (bfd_get_arch_info (abfd)->bits_per_address) { case 32: code = BFD_RELOC_32; break; default: return (CONST struct reloc_howto_struct *) 0; } switch (code) { ASTD (BFD_RELOC_16, 1); ASTD (BFD_RELOC_32, 2); ASTD (BFD_RELOC_ARM_PCREL_BRANCH, 3); ASTD (BFD_RELOC_8_PCREL, 4); ASTD (BFD_RELOC_16_PCREL, 5); ASTD (BFD_RELOC_32_PCREL, 6); default: return (CONST struct reloc_howto_struct *) 0; }}#define MY_swap_std_reloc_in MY(swap_std_reloc_in)#define MY_swap_std_reloc_out MY(swap_std_reloc_out)#define MY_get_section_contents _bfd_generic_get_section_contents/* #define MY_bfd_link_hash_table_create _bfd_generic_link_hash_table_create *//* #define MY_bfd_link_add_symbols _bfd_generic_link_add_symbols *//* #define MY_bfd_final_link _bfd_generic_final_link */#include "aoutx.h"static voidMY_swap_std_reloc_in (abfd, bytes, cache_ptr, symbols, symcount) bfd *abfd; struct reloc_std_external *bytes; arelent *cache_ptr; asymbol **symbols; bfd_size_type symcount ATTRIBUTE_UNUSED;{ int r_index; int r_extern; int r_pcrel; struct aoutdata *su = &(abfd->tdata.aout_data->a); cache_ptr->address = bfd_h_get_32 (abfd, bytes->r_address); cache_ptr->howto = MY_reloc_howto (abfd, bytes, r_index, r_extern, r_pcrel); MOVE_ADDRESS (0);}voidMY_swap_std_reloc_out (abfd, g, natptr) bfd *abfd; arelent *g; struct reloc_std_external *natptr;{ int r_index; asymbol *sym = *(g->sym_ptr_ptr); int r_extern; int r_length; int r_pcrel; int r_neg = 0; /* Negative relocs use the BASEREL bit. */ asection *output_section = sym->section->output_section; PUT_WORD(abfd, g->address, natptr->r_address); r_length = g->howto->size ; /* Size as a power of two */ if (r_length < 0) { r_length = -r_length; r_neg = 1; } r_pcrel = (int) g->howto->pc_relative; /* Relative to PC? */ /* For RISC iX, in pc-relative relocs the r_pcrel bit means that the relocation has been done already (Only for the 26-bit one I think)???!!! */ if (g->howto->type == 3) { r_length = 3; r_pcrel = 0; } else if (g->howto->type == 7) { r_length = 3; r_pcrel = 1; }#if 0 /* For a standard reloc, the addend is in the object file. */ r_addend = g->addend + (*(g->sym_ptr_ptr))->section->output_section->vma;#endif /* name was clobbered by aout_write_syms to be symbol index */ /* If this relocation is relative to a symbol then set the r_index to the symbols index, and the r_extern bit. Absolute symbols can come in in two ways, either as an offset from the abs section, or as a symbol which has an abs value. check for that here */ if (bfd_is_com_section (output_section) || output_section == &bfd_abs_section || output_section == &bfd_und_section) { if (bfd_abs_section.symbol == sym) { /* Whoops, looked like an abs symbol, but is really an offset from the abs section */ r_index = 0; r_extern = 0; } else { /* Fill in symbol */ r_extern = 1; r_index = (*(g->sym_ptr_ptr))->KEEPIT; } } else { /* Just an ordinary section */ r_extern = 0; r_index = output_section->target_index; } /* now the fun stuff */ if (bfd_header_big_endian (abfd)) { natptr->r_index[0] = r_index >> 16; natptr->r_index[1] = r_index >> 8; natptr->r_index[2] = r_index; natptr->r_type[0] = ( (r_extern ? RELOC_STD_BITS_EXTERN_BIG: 0) | (r_pcrel ? RELOC_STD_BITS_PCREL_BIG: 0) | (r_neg ? RELOC_ARM_BITS_NEG_BIG: 0) | (r_length << RELOC_STD_BITS_LENGTH_SH_BIG)); } else { natptr->r_index[2] = r_index >> 16; natptr->r_index[1] = r_index >> 8; natptr->r_index[0] = r_index; natptr->r_type[0] = ( (r_extern ? RELOC_STD_BITS_EXTERN_LITTLE: 0) | (r_pcrel ? RELOC_STD_BITS_PCREL_LITTLE: 0) | (r_neg ? RELOC_ARM_BITS_NEG_LITTLE: 0) | (r_length << RELOC_STD_BITS_LENGTH_SH_LITTLE)); }}#define MY_BFD_TARGET#include "aout-target.h"extern const bfd_target aout_arm_big_vec;const bfd_target aout_arm_little_vec ={ "a.out-arm-little", /* name */ bfd_target_aout_flavour, BFD_ENDIAN_LITTLE, /* target byte order (little) */ BFD_ENDIAN_LITTLE, /* target headers byte order (little) */ (HAS_RELOC | EXEC_P | /* object flags */ HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED), (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE | SEC_DATA), MY_symbol_leading_char, AR_PAD_CHAR, /* ar_pad_char */ 15, /* ar_max_namelen */ bfd_getl64, bfd_getl_signed_64, bfd_putl64, bfd_getl32, bfd_getl_signed_32, bfd_putl32, bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* data */ bfd_getl64, bfd_getl_signed_64, bfd_putl64, bfd_getl32, bfd_getl_signed_32, bfd_putl32, bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* hdrs */ {_bfd_dummy_target, MY_object_p, /* bfd_check_format */ bfd_generic_archive_p, MY_core_file_p}, {bfd_false, MY_mkobject, /* bfd_set_format */ _bfd_generic_mkarchive, bfd_false}, {bfd_false, MY_write_object_contents, /* bfd_write_contents */ _bfd_write_archive_contents, bfd_false}, BFD_JUMP_TABLE_GENERIC (MY), BFD_JUMP_TABLE_COPY (MY), BFD_JUMP_TABLE_CORE (MY), BFD_JUMP_TABLE_ARCHIVE (MY), BFD_JUMP_TABLE_SYMBOLS (MY), BFD_JUMP_TABLE_RELOCS (MY), BFD_JUMP_TABLE_WRITE (MY), BFD_JUMP_TABLE_LINK (MY), BFD_JUMP_TABLE_DYNAMIC (MY), & aout_arm_big_vec, (PTR) MY_backend_data,};const bfd_target aout_arm_big_vec ={ "a.out-arm-big", /* name */ bfd_target_aout_flavour, BFD_ENDIAN_BIG, /* target byte order (big) */ BFD_ENDIAN_BIG, /* target headers byte order (big) */ (HAS_RELOC | EXEC_P | /* object flags */ HAS_LINENO | HAS_DEBUG | HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED), (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC | SEC_CODE | SEC_DATA), MY_symbol_leading_char, AR_PAD_CHAR, /* ar_pad_char */ 15, /* ar_max_namelen */ bfd_getb64, bfd_getb_signed_64, bfd_putb64, bfd_getb32, bfd_getb_signed_32, bfd_putb32, bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */ bfd_getb64, bfd_getb_signed_64, bfd_putb64, bfd_getb32, bfd_getb_signed_32, bfd_putb32, bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */ {_bfd_dummy_target, MY_object_p, /* bfd_check_format */ bfd_generic_archive_p, MY_core_file_p}, {bfd_false, MY_mkobject, /* bfd_set_format */ _bfd_generic_mkarchive, bfd_false}, {bfd_false, MY_write_object_contents, /* bfd_write_contents */ _bfd_write_archive_contents, bfd_false}, BFD_JUMP_TABLE_GENERIC (MY), BFD_JUMP_TABLE_COPY (MY), BFD_JUMP_TABLE_CORE (MY), BFD_JUMP_TABLE_ARCHIVE (MY), BFD_JUMP_TABLE_SYMBOLS (MY), BFD_JUMP_TABLE_RELOCS (MY), BFD_JUMP_TABLE_WRITE (MY), BFD_JUMP_TABLE_LINK (MY), BFD_JUMP_TABLE_DYNAMIC (MY), & aout_arm_little_vec, (PTR) MY_backend_data,};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -