bfd/
authorH.J. Lu <hjl.tools@gmail.com>
Mon, 13 Oct 2003 15:55:51 +0000 (15:55 +0000)
committerH.J. Lu <hjl.tools@gmail.com>
Mon, 13 Oct 2003 15:55:51 +0000 (15:55 +0000)
2003-10-10  H.J. Lu  <hongjiu.lu@intel.com>

* bfd-in.h (bfd_elf32_ia64_after_parse): New prototype.
(bfd_elf64_ia64_after_parse): Likewise.
* bfd-in2.h: Regenerated.

* elfxx-ia64.c (oor_ip): New.
(oor_branch_size): Likewise.
(bfd_elfNN_ia64_after_parse): Likewise.
(elfNN_ia64_relax_section): Use oor_ip if oor_branch_size
equals sizeof (oor_ip).

ld/

2003-10-10  H.J. Lu  <hongjiu.lu@intel.com>

* Makefile.am (eelf64_ia64.c): Also depend on
$(srcdir)/emultempl/ia64elf.em.
* Makefile.in: Regenerated.

* emulparams/elf64_ia64.sh (EXTRA_EM_FILE): Set to ia64elf.

* emultempl/ia64elf.em: New.

bfd/ChangeLog
bfd/bfd-in.h
bfd/bfd-in2.h
bfd/elfxx-ia64.c
ld/ChangeLog
ld/Makefile.am
ld/Makefile.in
ld/emulparams/elf64_ia64.sh
ld/emultempl/ia64elf.em [new file with mode: 0644]

index aadca635d2960765a043c5d3506018c091a787a2..08f2411de5d05f56f0d13f82ebeb63ed70a130d2 100644 (file)
@@ -1,3 +1,15 @@
+2003-10-13  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * bfd-in.h (bfd_elf32_ia64_after_parse): New prototype.
+       (bfd_elf64_ia64_after_parse): Likewise.
+       * bfd-in2.h: Regenerated.
+
+       * elfxx-ia64.c (oor_ip): New.
+       (oor_branch_size): Likewise.
+       (bfd_elfNN_ia64_after_parse): Likewise.
+       (elfNN_ia64_relax_section): Use oor_ip if oor_branch_size
+       equals sizeof (oor_ip).
+
 2003-10-12  Kaz Kojima  <kkojima@rr.iij4u.or.jp>
 
        * elf64-sh64.c (sh_elf64_relocate_section): Tidy up for the
index 49ebee7237ac0b39d3c320a12ac5e695324bd645..cfc99b82a51570d1e18004fe5c2c970f4f0bc948 100644 (file)
@@ -824,3 +824,10 @@ extern int bfd_ticoff_get_section_load_page
 extern bfd_vma bfd_h8300_pad_address
   (bfd *, bfd_vma);
 
+/* IA64 Itanium code generation.  Called from linker.  */
+extern void bfd_elf32_ia64_after_parse
+  (int);
+
+extern void bfd_elf64_ia64_after_parse
+  (int);
+
index 034330fd92fe4eb28bc94ed1b5bb8e7d19ff613c..a70b0d32b8fd367668bc688024955b4543eaa544 100644 (file)
@@ -831,6 +831,13 @@ extern int bfd_ticoff_get_section_load_page
 extern bfd_vma bfd_h8300_pad_address
   (bfd *, bfd_vma);
 
+/* IA64 Itanium code generation.  Called from linker.  */
+extern void bfd_elf32_ia64_after_parse
+  (int);
+
+extern void bfd_elf64_ia64_after_parse
+  (int);
+
 /* Extracted from init.c.  */
 void bfd_init (void);
 
index 15f7c0a126ad1157ec5d37c77e383604735efe1e..ed626bfae3960316c7a73e48ca89570348cf1445 100644 (file)
@@ -656,6 +656,28 @@ static const bfd_byte oor_brl[16] =
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00,  /*               brl.sptk.few tgt;; */
   0x00, 0x00, 0x00, 0xc0
 };
+
+static const bfd_byte oor_ip[48] =
+{
+  0x04, 0x00, 0x00, 0x00, 0x01, 0x00,  /*  [MLX]        nop.m 0            */
+  0x00, 0x00, 0x00, 0x00, 0x00, 0xe0,  /*               movl r15=0         */
+  0x01, 0x00, 0x00, 0x60,
+  0x03, 0x00, 0x00, 0x00, 0x01, 0x00,  /*  [MII]        nop.m 0            */
+  0x00, 0x01, 0x00, 0x60, 0x00, 0x00,  /*               mov r16=ip;;       */
+  0xf2, 0x80, 0x00, 0x80,              /*               add r16=r15,r16;;  */
+  0x11, 0x00, 0x00, 0x00, 0x01, 0x00,  /*  [MIB]        nop.m 0            */
+  0x60, 0x80, 0x04, 0x80, 0x03, 0x00,  /*               mov b6=r16         */
+  0x60, 0x00, 0x80, 0x00               /*               br b6;;            */
+};
+
+static size_t oor_branch_size = sizeof (oor_brl);
+
+void
+bfd_elfNN_ia64_after_parse (int itanium)
+{
+  oor_branch_size = itanium ? sizeof (oor_ip) : sizeof (oor_brl);
+}
+
 \f
 /* These functions do relaxation for IA-64 ELF.  */
 
@@ -891,9 +913,7 @@ elfNN_ia64_relax_section (abfd, sec, link_info, again)
              if (tsec == ia64_info->plt_sec)
                size = sizeof (plt_full_entry);
              else
-               {
-                 size = sizeof (oor_brl);
-               }
+               size = oor_branch_size;
 
              /* Resize the current section to make room for the new branch. */
              trampoff = (sec->_cooked_size + 15) & (bfd_vma) -16;
@@ -914,10 +934,22 @@ elfNN_ia64_relax_section (abfd, sec, link_info, again)
                }
              else
                {
-                 memcpy (contents + trampoff, oor_brl, size);
-                 irel->r_info = ELFNN_R_INFO (ELFNN_R_SYM (irel->r_info),
-                                              R_IA64_PCREL60B);
-                 irel->r_offset = trampoff + 2;
+                 if (size == sizeof (oor_ip))
+                   {
+                     memcpy (contents + trampoff, oor_ip, size);
+                     irel->r_info = ELFNN_R_INFO (ELFNN_R_SYM (irel->r_info),
+                                                  R_IA64_PCREL64I);
+                     irel->r_addend -= 16;
+                     irel->r_offset = trampoff + 2;
+                   }
+                 else
+                   {
+                     memcpy (contents + trampoff, oor_brl, size);
+                     irel->r_info = ELFNN_R_INFO (ELFNN_R_SYM (irel->r_info),
+                                                  R_IA64_PCREL60B);
+                     irel->r_offset = trampoff + 2;
+                   }
+
                }
 
              /* Record the fixup so we don't do it again this section.  */
index 1c48c10a0f90bc6bddcbbe81f87e4b04383c74fb..0f91e79ed765b5eb12b0850e000d93eeb29d71a4 100644 (file)
@@ -1,3 +1,13 @@
+2003-10-10  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * Makefile.am (eelf64_ia64.c): Also depend on
+       $(srcdir)/emultempl/ia64elf.em.
+       * Makefile.in: Regenerated.
+
+       * emulparams/elf64_ia64.sh (EXTRA_EM_FILE): Set to ia64elf.
+
+       * emultempl/ia64elf.em: New.
+
 2003-10-12  Kaz Kojima  <kkojima@rr.iij4u.or.jp>
 
        * emulparams/shelf32_nbsd.sh (OTHER_SECTIONS): Redefine.
index 00c4998904abe8649dc2d28b710a6910e5861c77..fea073b11d474f2a056035d6ff1a64a6af7d76c7 100644 (file)
@@ -789,12 +789,14 @@ eelf64_aix.c: $(srcdir)/emulparams/elf64_aix.sh \
   $(srcdir)/emultempl/elf32.em $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
        ${GENSCRIPTS} elf64_aix "$(tdir_elf64_aix)"
 eelf64_ia64.c: $(srcdir)/emulparams/elf64_ia64.sh \
-  $(srcdir)/emultempl/elf32.em $(srcdir)/emultempl/needrelax.em \
+  $(srcdir)/emultempl/elf32.em $(srcdir)/emultempl/ia64elf.em \
+  $(srcdir)/emultempl/needrelax.em \
   $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
        ${GENSCRIPTS} elf64_ia64 "$(tdir_elf64_ia64)"
 eelf64_ia64_fbsd.c: $(srcdir)/emulparams/elf64_ia64_fbsd.sh \
   $(srcdir)/emulparams/elf64_ia64.sh \
-  $(srcdir)/emultempl/elf32.em $(srcdir)/emultempl/needrelax.em \
+  $(srcdir)/emultempl/elf32.em $(srcdir)/emultempl/ia64elf.em \
+  $(srcdir)/emultempl/needrelax.em \
   $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
        ${GENSCRIPTS} elf64_ia64_fbsd "$(tdir_elf64_ia64_fbsd)"
 eelf64_s390.c: $(srcdir)/emulparams/elf64_s390.sh \
index 85c13ddfee950200451d52ef7a7d6c937b90b054..1006b3f903b1c85f4e90fbf5a05215006f673d97 100644 (file)
@@ -1,4 +1,4 @@
-# Makefile.in generated automatically by automake 1.4-p5 from Makefile.am
+# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am
 
 # Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
@@ -888,7 +888,7 @@ uninstall-man:
 all-recursive install-data-recursive install-exec-recursive \
 installdirs-recursive install-recursive uninstall-recursive install-info-recursive \
 check-recursive installcheck-recursive info-recursive dvi-recursive:
-       @set fnord $(MAKEFLAGS); amf=$$2; \
+       @set fnord $$MAKEFLAGS; amf=$$2; \
        dot_seen=no; \
        target=`echo $@ | sed s/-recursive//`; \
        list='$(SUBDIRS)'; for subdir in $$list; do \
@@ -908,7 +908,7 @@ check-recursive installcheck-recursive info-recursive dvi-recursive:
 
 mostlyclean-recursive clean-recursive distclean-recursive \
 maintainer-clean-recursive:
-       @set fnord $(MAKEFLAGS); amf=$$2; \
+       @set fnord $$MAKEFLAGS; amf=$$2; \
        dot_seen=no; \
        rev=''; list='$(SUBDIRS)'; for subdir in $$list; do \
          rev="$$subdir $$rev"; \
@@ -1093,7 +1093,7 @@ distclean-generic:
        -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
 
 maintainer-clean-generic:
-       -test -z "ldlexldeffilephdeffilepcldgramhldgramc$(MAINTAINERCLEANFILES)" || rm -f ldlexl deffileph deffilepc ldgramh ldgramc $(MAINTAINERCLEANFILES)
+       -test -z "ldlexcdeffilephdeffilepcldgramhldgramc$(MAINTAINERCLEANFILES)" || rm -f ldlexc deffileph deffilepc ldgramh ldgramc $(MAINTAINERCLEANFILES)
 mostlyclean-am:  mostlyclean-hdr mostlyclean-noinstPROGRAMS \
                mostlyclean-compile mostlyclean-libtool \
                mostlyclean-aminfo mostlyclean-tags mostlyclean-generic \
@@ -1515,12 +1515,14 @@ eelf64_aix.c: $(srcdir)/emulparams/elf64_aix.sh \
   $(srcdir)/emultempl/elf32.em $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
        ${GENSCRIPTS} elf64_aix "$(tdir_elf64_aix)"
 eelf64_ia64.c: $(srcdir)/emulparams/elf64_ia64.sh \
-  $(srcdir)/emultempl/elf32.em $(srcdir)/emultempl/needrelax.em \
+  $(srcdir)/emultempl/elf32.em $(srcdir)/emultempl/ia64elf.em \
+  $(srcdir)/emultempl/needrelax.em \
   $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
        ${GENSCRIPTS} elf64_ia64 "$(tdir_elf64_ia64)"
 eelf64_ia64_fbsd.c: $(srcdir)/emulparams/elf64_ia64_fbsd.sh \
   $(srcdir)/emulparams/elf64_ia64.sh \
-  $(srcdir)/emultempl/elf32.em $(srcdir)/emultempl/needrelax.em \
+  $(srcdir)/emultempl/elf32.em $(srcdir)/emultempl/ia64elf.em \
+  $(srcdir)/emultempl/needrelax.em \
   $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS}
        ${GENSCRIPTS} elf64_ia64_fbsd "$(tdir_elf64_ia64_fbsd)"
 eelf64_s390.c: $(srcdir)/emulparams/elf64_s390.sh \
index d9c7f6aba168fb56ce34428a2f206c2002168d92..858cd10cbbda9cdafe0410142fd091bd63d4f272 100644 (file)
@@ -2,7 +2,7 @@
 SCRIPT_NAME=elf
 ELFSIZE=64
 TEMPLATE_NAME=elf32
-EXTRA_EM_FILE=needrelax
+EXTRA_EM_FILE=ia64elf
 OUTPUT_FORMAT="elf64-ia64-little"
 ARCH=ia64
 MACHINE=
diff --git a/ld/emultempl/ia64elf.em b/ld/emultempl/ia64elf.em
new file mode 100644 (file)
index 0000000..5517725
--- /dev/null
@@ -0,0 +1,61 @@
+# This shell script emits a C file. -*- C -*-
+#   Copyright 2003 Free Software Foundation, Inc.
+#
+# This file is part of GLD, the Gnu Linker.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+
+# This file is sourced from elf32.em, and defines extra ia64-elf
+# specific routines.
+#
+# Define some shell vars to insert bits of code into the standard elf
+# parse_args and list_options functions.
+#
+cat >>e${EMULATION_NAME}.c <<EOF
+
+/* None zero if generating binary for Intel Itanium processor.  */
+static int itanium = 0;
+
+static void
+gld${EMULATION_NAME}_after_parse (void)
+{
+  bfd_${EMULATION_NAME}_after_parse (itanium);
+}
+
+EOF
+
+PARSE_AND_LIST_PROLOGUE='
+#define OPTION_ITANIUM                 300
+'
+
+PARSE_AND_LIST_LONGOPTS='
+    { "itanium", no_argument, NULL, OPTION_ITANIUM},
+'
+
+PARSE_AND_LIST_OPTIONS='
+  fprintf (file, _("\
+  --itanium             Generate code for Intel Itanium processor\n"
+                  ));
+'
+
+PARSE_AND_LIST_ARGS_CASES='
+    case OPTION_ITANIUM:
+      itanium = 1;
+      break;
+'
+
+LDEMUL_AFTER_PARSE=gld${EMULATION_NAME}_after_parse
+. ${srcdir}/emultempl/needrelax.em