This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: Generate code for Itanium


We find a need to generate code for Itanium. According to the ia64
spec, all platforms should support brl. But some kernels do not
provide brl emulation. This patch is to work around this issue.
I'd like to keep it as a undocumented feature since not many people
are using Itanium.


H.J.
---
bfd/

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

	* elfxx-ia64.c (oor_ip): New.
	(elfNN_ia64_relax_section): Use oor_ip if link_info->itanium is
	true.

include/

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

	* bfdlink.h (bfd_link_info): Add itanium.

ld/

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

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

--- binutils/bfd/elfxx-ia64.c.itanium	2003-09-30 15:21:05.000000000 -0700
+++ binutils/bfd/elfxx-ia64.c	2003-10-08 12:37:57.000000000 -0700
@@ -656,6 +656,19 @@ 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;;            */
+};
 
 /* These functions do relaxation for IA-64 ELF.  */
 
@@ -892,7 +905,10 @@ elfNN_ia64_relax_section (abfd, sec, lin
 		size = sizeof (plt_full_entry);
 	      else
 		{
-		  size = sizeof (oor_brl);
+		  if (link_info->itanium)
+		    size = sizeof (oor_ip);
+		  else
+		    size = sizeof (oor_brl);
 		}
 
 	      /* Resize the current section to make room for the new branch. */
@@ -914,10 +930,22 @@ elfNN_ia64_relax_section (abfd, sec, lin
 		}
 	      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 (link_info->itanium)
+		    {
+		      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.  */
--- binutils/include/bfdlink.h.itanium	2003-10-08 12:42:51.000000000 -0700
+++ binutils/include/bfdlink.h	2003-10-08 11:32:02.000000000 -0700
@@ -300,6 +300,9 @@ struct bfd_link_info
      flags.  */
   unsigned int noexecstack: 1;
 
+  /* TRUE if generating binary for Intel Itanium processor.  */
+  unsigned int itanium: 1;
+
   /* What to do with unresolved symbols in an object file.
      When producing static binaries the default is GENERATE_ERROR.
      When producing dynamic binaries the default is IGNORE.  The
--- binutils/ld/Makefile.am.itanium	2003-08-15 23:22:43.000000000 -0700
+++ binutils/ld/Makefile.am	2003-10-08 12:39:40.000000000 -0700
@@ -789,12 +789,14 @@ eelf64_aix.c: $(srcdir)/emulparams/elf64
   $(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 \
--- binutils/ld/Makefile.in.itanium	2003-08-15 23:22:43.000000000 -0700
+++ binutils/ld/Makefile.in	2003-10-08 12:39:59.000000000 -0700
@@ -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 i
 
 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
   $(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 \
--- binutils/ld/emulparams/elf64_ia64.sh.itanium	2003-07-07 07:12:01.000000000 -0700
+++ binutils/ld/emulparams/elf64_ia64.sh	2003-10-08 12:37:57.000000000 -0700
@@ -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=
--- binutils/ld/emultempl/ia64elf.em.itanium	2003-10-08 12:37:57.000000000 -0700
+++ binutils/ld/emultempl/ia64elf.em	2003-10-08 12:37:57.000000000 -0700
@@ -0,0 +1,47 @@
+# 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.
+#
+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:
+      link_info.itanium = TRUE;
+      break;
+'
+
+. ${srcdir}/emultempl/needrelax.em
--- binutils/ld/ldmain.c.itanium	2003-09-30 12:38:02.000000000 -0700
+++ binutils/ld/ldmain.c	2003-10-08 12:37:57.000000000 -0700
@@ -323,6 +323,7 @@ main (int argc, char **argv)
   link_info.flags = 0;
   link_info.flags_1 = 0;
   link_info.relax_finalizing = FALSE;
+  link_info.itanium = FALSE;
 
   ldfile_add_arch ("");
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]