$NetBSD: patch-aa,v 1.1 1999/01/04 22:37:31 tv Exp $ --- ./bfd/elf64-alpha.c.orig Fri May 1 11:48:09 1998 +++ ./bfd/elf64-alpha.c Tue Dec 29 15:31:36 1998 @@ -1012,9 +1012,16 @@ #define PLT_HEADER_WORD4 0x6b7b0000 /* jmp $27,($27) */ #define PLT_ENTRY_SIZE 12 +#ifdef __NetBSD__ +/* XXX. XXX. For NetBSD 1.3 compatibility - should be fixed better */ +#define PLT_ENTRY_WORD1 0x279f0000 /* ldah $28, 0($31) */ +#define PLT_ENTRY_WORD2 0x239c0000 /* lda $28, 0($28) */ +#define PLT_ENTRY_WORD3 0xc3e00000 /* br $31, plt0 */ +#else #define PLT_ENTRY_WORD1 0xc3800000 /* br $28, plt0 */ #define PLT_ENTRY_WORD2 0 #define PLT_ENTRY_WORD3 0 +#endif #define MAX_GOT_ENTRIES (64*1024 / 8) @@ -3118,9 +3125,23 @@ { unsigned insn1, insn2, insn3; +#ifdef __NetBSD__ +/* XXX. XXX. For NetBSD 1.3 compatibility - should be fixed better */ + long hi, lo; + + /* decompose the reloc offset for the plt for ldah+lda */ + hi = plt_index * sizeof(Elf64_External_Rela); + lo = ((hi & 0xffff) ^ 0x8000) - 0x8000; + hi = (hi - lo) >> 16; + + insn1 = PLT_ENTRY_WORD1 | (hi & 0xffff); + insn2 = PLT_ENTRY_WORD2 | (lo & 0xffff); + insn3 = PLT_ENTRY_WORD3 | ((-(h->plt_offset + 12) >> 2) & 0x1fffff); +#else insn1 = PLT_ENTRY_WORD1 | ((-(h->plt_offset + 4) >> 2) & 0x1fffff); insn2 = PLT_ENTRY_WORD2; insn3 = PLT_ENTRY_WORD3; +#endif bfd_put_32 (output_bfd, insn1, splt->contents + h->plt_offset); bfd_put_32 (output_bfd, insn2, splt->contents + h->plt_offset + 4);