This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


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

Re: Fix LD_BIND_NOT and LD_PROFILE on ia64


On Sun, Jan 23, 2005 at 11:36:42PM +0100, Andreas Schwab wrote:
> Ulrich Drepper <drepper@redhat.com> writes:
> 
> > That branch is completely irrelevant when it comes to patches.  You are
> > not getting anything ever on that branch unless it has been proved in the
> > trunk.
> 
> The trunk is useless until the audit stuff has been implemented.  I have
> only a patch for an incomplete implementation, maybe someone with more
> knowledge about the IA64 ABI can complete it.
> 
> Andreas.
> 

This is my incomplete patch. I need to spend some time on audit code.


H.J.
-----
2005-01-24  H.J. Lu  <hongjiu.lu@intel.com>

	* elf/tst-auditmod1.c: Add ia64 entries.

	* sysdeps/generic/ldsodefs.h (La_ia64_regs): New.
	(La_ia64_retval): New.
	(audit_ifaces): Add ia64 entries.

	* sysdeps/ia64/bits/link.h: New file.

	* sysdeps/ia64/dl-machine.h (elf_machine_runtime_setup): Test
	for dl_profile non-null.
	(ARCH_LA_PLTENTER): New.
	(ARCH_LA_PLTEXIT): New.

	* sysdeps/ia64/dl-trampoline.S (_dl_runtime_resolve): Only
	allocate 2 output registers. Call _dl_fixup instead of fixup.
	(_dl_runtime_profile): Try to support audit.

--- libc/elf/tst-auditmod1.c.tramp	2005-01-24 15:30:36.000000000 -0800
+++ libc/elf/tst-auditmod1.c	2005-01-24 15:41:02.000000000 -0800
@@ -144,6 +144,12 @@ la_symbind64 (Elf64_Sym *sym, unsigned i
 # define La_regs La_alpha_regs
 # define La_retval La_alpha_retval
 # define int_retval lrv_r0
+#elif defined __ia64__
+# define pltenter la_ia64_gnu_pltenter
+# define pltexit la_ia64_gnu_pltexit
+# define La_regs La_ia64_regs
+# define La_retval La_ia64_retval
+# define int_retval lrv_r8
 #else
 # error "architecture specific code needed"
 #endif
--- libc/sysdeps/generic/ldsodefs.h.tramp	2005-01-24 15:30:39.000000000 -0800
+++ libc/sysdeps/generic/ldsodefs.h	2005-01-24 15:43:13.000000000 -0800
@@ -189,6 +189,8 @@ struct La_m68k_regs;
 struct La_m68k_retval;
 struct La_alpha_regs;
 struct La_alpha_retval;
+struct La_ia64_regs;
+struct La_ia64_retval;
 
 struct audit_ifaces
 {
@@ -233,6 +235,10 @@ struct audit_ifaces
 				      uintptr_t *, struct La_alpha_regs *,
 				      unsigned int *, const char *name,
 				      long int *framesizep);
+    Elf64_Addr (*ia64_gnu_pltenter) (Elf64_Sym *, unsigned int, uintptr_t *,
+				     uintptr_t *, struct La_ia64_regs *,
+				     unsigned int *, const char *name,
+				     long int *framesizep);
   };
   union
   {
@@ -262,6 +268,10 @@ struct audit_ifaces
 				       uintptr_t *,
 				       const struct La_alpha_regs *,
 				       struct La_alpha_retval *, const char *);
+    unsigned int (*ia64_gnu_pltexit) (Elf64_Sym *, unsigned int, uintptr_t *,
+				      uintptr_t *,
+				      const struct La_ia64_regs *,
+				      struct La_ia64_retval *, const char *);
   };
   unsigned int (*objclose) (uintptr_t *);
 
--- libc/sysdeps/ia64/bits/link.h.tramp	2005-01-07 14:13:48.000000000 -0800
+++ libc/sysdeps/ia64/bits/link.h	2005-01-24 15:40:07.000000000 -0800
@@ -0,0 +1,60 @@
+/* Copyright (C) 2005 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef	_LINK_H
+# error "Never include <bits/link.h> directly; use <link.h> instead."
+#endif
+
+
+/* Registers for entry into PLT on ia64.  */
+typedef struct La_ia64_regs
+{
+  uint64_t lr_gr [8];
+  long double lr_fr [8];
+  uint64_t lr_sp;
+  uint64_t lr_gp;
+} La_ia64_regs;
+
+/* Return values for calls from PLT on ia64.  */
+typedef struct La_ia64_retval
+{
+  uint64_t lrv_r8;
+  uint64_t lrv_r9;
+  uint64_t lrv_r10;
+  uint64_t lrv_r11;
+  long double lr_fr [8];
+} La_ia64_retval;
+
+
+__BEGIN_DECLS
+
+extern Elf64_Addr la_ia64_gnu_pltenter (Elf64_Sym *__sym, unsigned int __ndx,
+				       uintptr_t *__refcook,
+				       uintptr_t *__defcook,
+				       La_ia64_regs *__regs,
+				       unsigned int *__flags,
+				       const char *__symname,
+				       long int *__framesizep);
+extern unsigned int la_ia64_gnu_pltexit (Elf64_Sym *__sym, unsigned int __ndx,
+					uintptr_t *__refcook,
+					uintptr_t *__defcook,
+					const La_ia64_regs *__inregs,
+					La_ia64_retval *__outregs,
+					const char *symname);
+
+__END_DECLS
--- libc/sysdeps/ia64/dl-machine.h.tramp	2005-01-24 15:30:39.000000000 -0800
+++ libc/sysdeps/ia64/dl-machine.h	2005-01-24 16:03:55.000000000 -0800
@@ -123,7 +123,8 @@ elf_machine_runtime_setup (struct link_m
 	doit = (Elf64_Addr) ((struct fdesc *) &_dl_runtime_resolve)->ip;
       else
 	{
-	  if (_dl_name_match_p (GLRO(dl_profile), l))
+	  if (GLRO(dl_profile) != NULL
+	      && _dl_name_match_p (GLRO(dl_profile), l))
 	    {
 	      /* This is the object we are looking for.  Say that we really
 		 want profiling and the timers are started.  */
@@ -139,6 +140,9 @@ elf_machine_runtime_setup (struct link_m
   return lazy;
 }
 
+/* Names of the architecture-specific auditing callback functions.  */
+#define ARCH_LA_PLTENTER ia64_gnu_pltenter
+#define ARCH_LA_PLTEXIT ia64_gnu_pltexit
 
 /* Undo the adds out0 = 16, sp below to get at the value we want in
    __libc_stack_end.  */
--- libc/sysdeps/ia64/dl-trampoline.S.tramp	2005-01-22 21:11:50.000000000 -0800
+++ libc/sysdeps/ia64/dl-trampoline.S	2005-01-24 16:16:27.795490484 -0800
@@ -32,7 +32,7 @@ ENTRY(_dl_runtime_resolve)
 	{ .mmi
 	  .prologue
 	  .save ar.pfs, r40
-	  alloc loc0 = ar.pfs, 8, 6, 3, 0
+	  alloc loc0 = ar.pfs, 8, 6, 2, 0
 	  adds r2 = -144, r12
 	  adds r3 = -128, r12
 	}
@@ -42,13 +42,8 @@ ENTRY(_dl_runtime_resolve)
 	  .save rp, r41
 	  mov loc1 = b0
 	  .body
-	  mov out2 = b0		/* needed by fixup_profile */
-	  ;;
-	}
-	{ .mfb
 	  mov loc2 = r8		/* preserve struct value register */
-	  nop.f 0
-	  nop.b 0
+	  ;;
 	}
 	{ .mii
 	  mov loc3 = r9		/* preserve language specific register */
@@ -76,7 +71,7 @@ ENTRY(_dl_runtime_resolve)
 	{ .mmb
 	  stf.spill [r2] = f14
 	  stf.spill [r3] = f15
-	  br.call.sptk.many b0 = fixup
+	  br.call.sptk.many b0 = _dl_fixup#
 	}
 	{ .mii
 	  ld8 r9 = [ret0], 8
@@ -128,35 +123,55 @@ ENTRY(_dl_runtime_resolve)
 	  br.sptk.many b6
 	  ;;
 	}
-END (_dl_runtime_resolve)
+END(_dl_runtime_resolve)
 
 
 ENTRY(_dl_runtime_profile)
 	{ .mmi
 	  .prologue
 	  .save ar.pfs, r40
-	  alloc loc0 = ar.pfs, 8, 6, 3, 0
-	  adds r2 = -144, r12
-	  adds r3 = -128, r12
+	  alloc loc0 = ar.pfs, 8, 7, 5, 0
+	  adds r2 = -224, r12
+	  adds r3 = -216, r12
 	}
 	{ .mii
-	  .fframe 160
-	  adds r12 = -160, r12
+	  .fframe 248
+	  adds r12 = -248, r12
 	  .save rp, r41
 	  mov loc1 = b0
 	  .body
-	  mov out2 = b0		/* needed by fixup_profile */
+	  mov out2 = b0		/* needed by _dl_fixup_profile */
 	  ;;
 	}
-	{ .mfb
+	{ .mmi
+	  st8.spill [r2] = in0, 16	/* store arg 0 */
+	  st8.spill [r3] = in1, 16	/* store arg 1 */
 	  mov loc2 = r8		/* preserve struct value register */
-	  nop.f 0
-	  nop.b 0
+	  ;;
 	}
-	{ .mii
+	{ .mmi
+	  st8.spill [r2] = in2, 16	/* store arg 2 */
+	  st8.spill [r3] = in3, 16	/* store arg 3 */
 	  mov loc3 = r9		/* preserve language specific register */
+	  ;;
+	}
+	{ .mmi
+	  st8.spill [r2] = in4, 16	/* store arg 4 */
+	  st8.spill [r3] = in5, 16	/* store arg 5 */
 	  mov loc4 = r10	/* preserve language specific register */
+	  ;;
+	}
+	{ .mmi
+	  st8 [r2] = in6, 16	/* store arg 6 */
+	  st8 [r3] = in7, 16	/* store arg 7 */
 	  mov loc5 = r11	/* preserve language specific register */
+	  ;;
+	}
+	{ .mii
+	  adds out3 = 16, r12	/* needed by _dl_fixup_profile */
+	  adds out4 = 224, r12	/* needed by _dl_fixup_profile */
+	  adds r3 = 8, r3
+	  ;;
 	}
 	{ .mmi
 	  stf.spill [r2] = f8, 32
@@ -176,10 +191,16 @@ ENTRY(_dl_runtime_profile)
 	  shladd out1 = r15, 3, out1
 	  ;;
 	}
+	{ .mmi
+	  stf.spill [r2] = f14, 32
+	  stf.spill [r3] = f15, 24
+	  adds loc6 = 248, r12
+	  ;;
+	}
 	{ .mmb
-	  stf.spill [r2] = f14
-	  stf.spill [r3] = f15
-	  br.call.sptk.many b0 = profile_fixup
+	  st8 [r2] = gp		/* store gp */
+	  st8 [r3] = loc6	/* store sp */
+	  br.call.sptk.many b0 = _dl_profile_fixup#
 	}
 	{ .mii
 	  ld8 r9 = [ret0], 8
@@ -209,7 +230,7 @@ ENTRY(_dl_runtime_profile)
 	  ldf.fill f14 = [r2], 32
 	  ldf.fill f15 = [r3], 32
 	  .restore sp		/* pop the unwind frame state */
-	  adds r12 = 160, r12
+	  adds r12 = 248, r12
 	  ;;
 	}
 	{ .mii
@@ -231,4 +252,4 @@ ENTRY(_dl_runtime_profile)
 	  br.sptk.many b6
 	  ;;
 	}
-END (_dl_runtime_profile)
+END(_dl_runtime_profile)


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