Index: elf32-m68k.c =================================================================== RCS file: /cvs/src/src/bfd/elf32-m68k.c,v retrieving revision 1.73 diff -u -p -r1.73 elf32-m68k.c --- elf32-m68k.c 20 Feb 2005 14:59:06 -0000 1.73 +++ elf32-m68k.c 16 Mar 2005 06:39:49 -0000 @@ -191,6 +191,37 @@ reloc_type_lookup (abfd, code) /* The size in bytes of an entry in the procedure linkage table. */ +#define CFV4E_PLT_ENTRY_SIZE 24 + +#define CFV4E_FLAG(abfd) (elf_elfheader (abfd)->e_flags & EF_CFV4E) + +static const bfd_byte elf_cfv4e_plt0_entry[CFV4E_PLT_ENTRY_SIZE] = +{ + 0x20, 0x3c, + 0, 0, 0, 0, /* replaced with offset to .got + 4. */ + 0x2f, 0x3b, 0x08, 0xfa, /* move.l (%pc,addr),-(%sp) */ + 0x20, 0x3c, + 0, 0, 0, 0, /* replaced with offset to .got + 8. */ + 0x20, 0x7b, 0x08, 0x00, /* move.l (%pc,%d0:l), %a0 */ + 0x4e, 0xd0, /* jmp (%a0) */ + 0x4e, 0x71 /* nop */ +}; + +/* Subsequent entries in a procedure linkage table look like this. */ + +static const bfd_byte elf_cfv4e_plt_entry[CFV4E_PLT_ENTRY_SIZE] = +{ + 0x20, 0x3c, + 0, 0, 0, 0, /* replaced with offset to symbol's .got entry. */ + 0x20, 0x7b, 0x08, 0x00, /* move.l (%pc,%d0:l), %a0 */ + 0x4e, 0xd0, /* jmp (%a0) */ + 0x2f, 0x3c, /* move.l #offset,-(%sp) */ + 0, 0, 0, 0, /* replaced with offset into relocation table. */ + 0x60, 0xff, /* bra.l .plt */ + 0, 0, 0, 0 /* replaced with offset to start of .plt. */ +}; + + #define PLT_ENTRY_SIZE 20 /* The first entry in a procedure linkage table looks like this. See @@ -977,6 +1008,8 @@ elf_m68k_adjust_dynamic_symbol (info, h) { if (CPU32_FLAG (dynobj)) s->size += PLT_CPU32_ENTRY_SIZE; + else if( CFV4E_FLAG(dynobj) ) + s->_raw_size += CFV4E_PLT_ENTRY_SIZE; else s->size += PLT_ENTRY_SIZE; } @@ -998,6 +1031,8 @@ elf_m68k_adjust_dynamic_symbol (info, h) /* Make room for this entry. */ if (CPU32_FLAG (dynobj)) s->size += PLT_CPU32_ENTRY_SIZE; + else if( CFV4E_FLAG(dynobj) ) + s->_raw_size += CFV4E_PLT_ENTRY_SIZE; else s->size += PLT_ENTRY_SIZE; @@ -1789,6 +1824,8 @@ elf_m68k_finish_dynamic_symbol (output_b first entry in the procedure linkage table is reserved. */ if ( CPU32_FLAG (output_bfd)) plt_index = h->plt.offset / PLT_CPU32_ENTRY_SIZE - 1; + else if ( CFV4E_FLAG(output_bfd)) + plt_index = h->plt.offset / CFV4E_PLT_ENTRY_SIZE - 1; else plt_index = h->plt.offset / PLT_ENTRY_SIZE - 1; @@ -1806,6 +1843,15 @@ elf_m68k_finish_dynamic_symbol (output_b plt_off2 = 12; plt_off3 = 18; } + else if (CFV4E_FLAG (output_bfd)) + { + memcpy (splt->contents + h->plt.offset, elf_cfv4e_plt_entry, + CFV4E_PLT_ENTRY_SIZE); + plt_off1 = 2; + plt_off2 = 14; + plt_off3 = 20; + + } else { /* Fill in the entry in the procedure linkage table. */ @@ -1816,26 +1862,48 @@ elf_m68k_finish_dynamic_symbol (output_b plt_off3 = 16; } - /* The offset is relative to the first extension word. */ - bfd_put_32 (output_bfd, + if ( !CFV4E_FLAG (output_bfd)) + { + /* The offset is relative to the first extension word. */ + bfd_put_32 (output_bfd, (sgot->output_section->vma + sgot->output_offset + got_offset - (splt->output_section->vma + h->plt.offset + 2)), splt->contents + h->plt.offset + plt_off1); - + } + else + { + bfd_put_32 (output_bfd, + (sgot->output_section->vma + + sgot->output_offset + + got_offset + - (splt->output_section->vma + + h->plt.offset + 2) - 6), + splt->contents + h->plt.offset + plt_off1); + + } bfd_put_32 (output_bfd, plt_index * sizeof (Elf32_External_Rela), splt->contents + h->plt.offset + plt_off2); bfd_put_32 (output_bfd, - (h->plt.offset + plt_off3), splt->contents + h->plt.offset + plt_off3); - - /* Fill in the entry in the global offset table. */ - bfd_put_32 (output_bfd, + if ( !CFV4E_FLAG (output_bfd)) + { + /* Fill in the entry in the global offset table. */ + bfd_put_32 (output_bfd, + (splt->output_section->vma + + splt->output_offset + + h->plt.offset + + 8), + sgot->contents + got_offset); + } + else + bfd_put_32 (output_bfd, (splt->output_section->vma + splt->output_offset + h->plt.offset - + 8), + + 12), sgot->contents + got_offset); /* Fill in the entry in the .rela.plt section. */ @@ -2013,7 +2081,24 @@ elf_m68k_finish_dynamic_sections (output /* Fill in the first entry in the procedure linkage table. */ if (splt->size > 0) { - if (!CPU32_FLAG (output_bfd)) + + if ( CFV4E_FLAG (output_bfd)) + { + memcpy (splt->contents, elf_cfv4e_plt0_entry, CFV4E_PLT_ENTRY_SIZE); + bfd_put_32 (output_bfd, + (sgot->output_section->vma + + sgot->output_offset + 4 + - (splt->output_section->vma + 2)), + splt->contents + 2); + bfd_put_32 (output_bfd, + (sgot->output_section->vma + + sgot->output_offset + 8 + - (splt->output_section->vma + 10) - 8 ), + splt->contents + 12); + elf_section_data (splt->output_section)->this_hdr.sh_entsize + = CFV4E_PLT_ENTRY_SIZE; + } + else if (!CPU32_FLAG (output_bfd)) { memcpy (splt->contents, elf_m68k_plt0_entry, PLT_ENTRY_SIZE); bfd_put_32 (output_bfd,