[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: PA: fix ELF ABI
From: |
Matthew Wilcox |
Subject: |
Re: PA: fix ELF ABI |
Date: |
Fri, 20 Apr 2001 14:44:43 -0600 |
My apologies; I missed a hunk from the previous patch I sent. Please
disregard the previous message and apply this patch instead.
2001-04-20 Jes Sorensen <address@hidden>
* elf/elf.h (ELFOSABI_LINUX): Define as 3.
* sysdeps/hppa/dl-machine.h: Provide private macros for
VALID_ELF_HEADER() and friends accepting both ELFOSABI_SYSV (0)
and ELFOSABI_LINUX.
* sysdeps/hppa/dl-machine.h (RTLD_START): _dl_init now returns a
function pointer, hence load the jump address and gp from the
function pointer before jumping.
diff -urNx CVS glibc-2.2.1/elf/elf.h glibc/elf/elf.h
--- glibc-2.2.1/elf/elf.h Thu Nov 16 12:58:55 2000
+++ glibc/elf/elf.h Wed Dec 13 10:56:11 2000
@@ -139,6 +139,7 @@
#define EI_OSABI 7 /* OS ABI identification */
#define ELFOSABI_SYSV 0 /* UNIX System V ABI */
#define ELFOSABI_HPUX 1 /* HP-UX */
+#define ELFOSABI_LINUX 3 /* Linux */
#define ELFOSABI_ARM 97 /* ARM */
#define ELFOSABI_STANDALONE 255 /* Standalone (embedded) application */
diff -urNx CVS glibc-2.2.1/sysdeps/hppa/dl-machine.h
glibc/sysdeps/hppa/dl-machine.h
--- glibc-2.2.1/sysdeps/hppa/dl-machine.h Thu Nov 16 13:00:28 2000
+++ glibc/sysdeps/hppa/dl-machine.h Thu Mar 22 21:49:15 2001
@@ -28,6 +28,13 @@
#include <link.h>
#include <assert.h>
+# define VALID_ELF_OSABI(osabi) ((osabi == ELFOSABI_SYSV) ||
(osabi == ELFOSABI_LINUX))
+# define VALID_ELF_ABIVERSION(ver) (ver == 0)
+# define VALID_ELF_HEADER(hdr,exp,size) \
+ memcmp (hdr,exp,size-2) == 0 \
+ && VALID_ELF_OSABI (hdr[EI_OSABI]) \
+ && VALID_ELF_ABIVERSION (hdr[EI_ABIVERSION])
+
/* These must match the definition of the stub in bfd/elf32-hppa.c. */
#define SIZEOF_PLT_STUB (4*4)
#define GOT_FROM_PLT_STUB (4*4)
@@ -248,7 +255,17 @@
The C function `_dl_start' is the real entry point;
its return value is the user program's entry point. */
-#define RTLD_START asm ("\
+#define RTLD_START \
+/* Set up dp for any non-PIC lib constructors that may be called. */ \
+static struct link_map * set_dp (struct link_map *map) \
+{ \
+ register Elf32_Addr dp asm ("%r27"); \
+ dp = D_PTR (map, l_info[DT_PLTGOT]); \
+ asm volatile ("" : : "r" (dp)); \
+ return map; \
+} \
+ \
+asm ("\
.text
.globl _start
.type _start,@function
@@ -324,7 +341,6 @@
bl _dl_start,%rp
ldo -4(%r24),%r26
- /* FALLTHRU */
.globl _dl_start_user
.type _dl_start_user,@function
_dl_start_user:
@@ -352,10 +368,14 @@
stw %r24,-44(%sp)
.Lnofix:
- /* Call _dl_init(_dl_loaded, argc, argv, envp). */
addil LT'_dl_loaded,%r19
ldw RT'_dl_loaded(%r1),%r26
+ bl set_dp, %r2
ldw 0(%r26),%r26
+
+ /* Call _dl_init(_dl_loaded, argc, argv, envp). */
+ copy %r28,%r26
+
/* envp = argv + argc + 1 */
sh2add %r25,%r24,%r23
bl _dl_init,%r2
@@ -373,11 +393,18 @@
.word 0xdeadbeef
.previous
+ /* %r3 contains a function pointer, we need to mask out the lower
+ * bits and load the gp and jump address. */
+ depi 0,31,2,%r3
+ ldw 0(%r3),%r2
addil LT'__dl_fini_plabel,%r19
ldw RT'__dl_fini_plabel(%r1),%r23
stw %r19,4(%r23)
- bv %r0(%r3)
- depi 2,31,2,%r23 /* delay slot */");
+ ldw 4(%r3),%r19 /* load the object's gp */
+ bv %r0(%r2)
+ depi 2,31,2,%r23 /* delay slot */
+");
+
/* This code gets called via the .plt stub, and is used in
dl-runtime.c to call the `fixup' function and then redirect to the
- PA: fix ELF ABI, Matthew Wilcox, 2001/04/20
- Re: PA: fix ELF ABI,
Matthew Wilcox <=