This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: Old PLT in elf64-alpha via ld --traditional-format?
- To: <binutils at sources dot redhat dot com>
- Subject: Re: Old PLT in elf64-alpha via ld --traditional-format?
- From: Todd Vierling <tv at wasabisystems dot com>
- Date: Fri, 9 Feb 2001 12:29:12 -0500 (Eastern Standard Time)
On Fri, 9 Feb 2001, Todd Vierling wrote:
: NetBSD uses the old-style three-word PLT entries in its shared objects and
: dynamically linked programs, resulting in a hack to elf64-alpha.c for
: NetBSD/alpha. We will be moving to the new PLT format in later NetBSD
: releases, but in order to keep compatibility in the toolchain (and make
: newer binutils still work on older released NetBSD systems), I wanted to
: come up with a dynamic way to produce the old style PLT at link time.
:
: At the moment, nothing in the elf64-alpha BFD target makes use of
: BFD_TRADITIONAL_FORMAT, meaning that "ld --traditional-format" does nothing
: special on the alpha. Would there be serious objection to making this
: produce binaries from ld which use the old PLT format?
FYI, here's a diff of how I made this work. This is not currently being
contributed as a patch; just as a request for comments (before making it
standard for NetBSD/alpha and contributing the patch). Along with this
change to bfd/elf64-alpha.c, I made an appropriate LINK_SPEC modification to
the NetBSD/alpha gcc configuration.
=====
--- bfd/elf64-alpha.c 2001/01/30 18:33:12
+++ bfd/elf64-alpha.c 2001/02/09 17:23:46
@@ -1669,6 +1669,11 @@
#define PLT_ENTRY_WORD2 0
#define PLT_ENTRY_WORD3 0
+/* ld --traditional-format uses this older format instead. */
+#define OLD_PLT_ENTRY_WORD1 0x279f0000 /* ldah $28, 0($31) */
+#define OLD_PLT_ENTRY_WORD2 0x239c0000 /* lda $28, 0($28) */
+#define OLD_PLT_ENTRY_WORD3 0xc3e00000 /* br $31, plt0 */
+
#define MAX_GOT_ENTRIES (64*1024 / 8)
#define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.so"
@@ -3772,10 +3777,26 @@
/* Fill in the entry in the procedure linkage table. */
{
unsigned insn1, insn2, insn3;
+
+ if ((output_bfd->flags & BFD_TRADITIONAL_FORMAT) != 0)
+ {
+ long hi, lo;
- insn1 = PLT_ENTRY_WORD1 | ((-(h->plt.offset + 4) >> 2) & 0x1fffff);
- insn2 = PLT_ENTRY_WORD2;
- insn3 = PLT_ENTRY_WORD3;
+ /* 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 = OLD_PLT_ENTRY_WORD1 | (hi & 0xffff);
+ insn2 = OLD_PLT_ENTRY_WORD2 | (lo & 0xffff);
+ insn3 = OLD_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;
+ }
bfd_put_32 (output_bfd, insn1, splt->contents + h->plt.offset);
bfd_put_32 (output_bfd, insn2, splt->contents + h->plt.offset + 4);
--
-- Todd Vierling <tv@wasabisystems.com> * Wasabi NetBSD: Run with it.
-- NetBSD 1.5 now available on CD-ROM -- http://www.wasabisystems.com/