This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH] Add sotruss-lib.h override mechanism for ports
- From: Chris Metcalf <cmetcalf at tilera dot com>
- To: libc-alpha at sourceware dot org
- Date: Tue, 15 May 2012 15:27:41 -0400
- Subject: [PATCH] Add sotruss-lib.h override mechanism for ports
---
This allows ports to add a "sotruss-lib.h" override like the current
"tst-audit.h" override. The HAVE_ARCH_PLTENTER and HAVE_ARCH_PLTEXIT
defines don't appear to do anything at the moment, so I removed them.
I chose to implement a "negative sense" with a define that says "no
override is available" in sysdeps/generic/sotruss-lib.h. That way ports
overrides can just provide the function definitions, and the absence
of the "no override is available" define signals that a function was
provided and no #warning should be issued.
The enter and exit functions are provided in separate #if/#elif/#elif/...
cascades in the current code. I think a useful cleanup would be to merge
them together, particularly since this proposed "ports" model only allows
you to provide both or neither, but I didn't want to confuse the structure
of this patch. If people think it's appropriate, I can refactor the file
so that it provides both enter and exit macros in a single #if clause,
or even just move all the bodies to separate "sotruss-lib.h" files in
each sysdep directory.
ChangeLog | 6 ++++++
elf/sotruss-lib.c | 9 +++++----
sysdeps/generic/sotruss-lib.h | 32 ++++++++++++++++++++++++++++++++
3 files changed, 43 insertions(+), 4 deletions(-)
create mode 100644 sysdeps/generic/sotruss-lib.h
diff --git a/ChangeLog b/ChangeLog
index 8a138ef..6013486 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -0,0 +1,6 @@
+2012-05-15 Chris Metcalf <cmetcalf@tilera.com>
+
+ * sysdeps/generic/sotruss-lib.h: New file.
+ * elf/sotruss-lib.h: Allow using <sotruss-lib.h> to provide
+ architecture-specific pltenter/pltexit definitions.
+
diff --git a/elf/sotruss-lib.c b/elf/sotruss-lib.c
index c2ab733..9c7b205 100644
--- a/elf/sotruss-lib.c
+++ b/elf/sotruss-lib.c
@@ -322,8 +322,6 @@ la_sparc64_gnu_pltenter (Elf64_Sym *sym __attribute__ ((unused)),
return sym->st_value;
}
-#elif !defined HAVE_ARCH_PLTENTER
-# warning "pltenter for architecture not supported"
#endif
@@ -381,6 +379,9 @@ la_sparc64_gnu_pltexit (Elf64_Sym *sym, unsigned int ndx, uintptr_t *refcook,
return 0;
}
-#elif !defined HAVE_ARCH_PLTEXIT
-# warning "pltexit for architecture not supported"
+#else
+# include <sotruss-lib.h>
+# ifdef SOTRUSS_LIB_GENERIC
+# warning "sotruss-lib pltenter/pltexit for architecture not supported"
+# endif
#endif
diff --git a/sysdeps/generic/sotruss-lib.h b/sysdeps/generic/sotruss-lib.h
new file mode 100644
index 0000000..1dfa921
--- /dev/null
+++ b/sysdeps/generic/sotruss-lib.h
@@ -0,0 +1,32 @@
+/* Some machines have these functions defined in elf/sotruss-lib.c directly.
+ New machines can supply a sotruss-lib.h to define these functions.
+
+ElfNN_Addr
+la_CPU_gnu_pltenter (ElfNN_Sym *sym __attribute__ ((unused)),
+ unsigned int ndx __attribute__ ((unused)),
+ uintptr_t *refcook, uintptr_t *defcook,
+ La_CPU_regs *regs, unsigned int *flags,
+ const char *symname, long int *framesizep)
+{
+ print_enter (refcook, defcook, symname,
+ regs->lr_ARGREG0, regs->lr_ARGREG1, regs->lr_ARGREG2, *flags);
+
+ *framesizep = 0;
+
+ return sym->st_value;
+}
+
+unsigned int
+la_CPU_gnu_pltexit (ElfNN_Sym *sym, unsigned int ndx, uintptr_t *refcook,
+ uintptr_t *defcook, const struct La_CPU_regs *inregs,
+ struct La_CPU_retval *outregs, const char *symname)
+{
+ print_exit (refcook, defcook, symname, outregs->lrv_RETVALREG);
+
+ return 0;
+}
+
+*/
+
+/* This define indicates that no overriding sotruss-lib.h was found. */
+#define SOTRUSS_LIB_GENERIC
--
1.6.5.2