This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
PATCH: ARM dl-trampoline.S
- From: Mark Mitchell <mark at codesourcery dot com>
- To: libc-alpha at sources dot redhat dot com
- Date: Wed, 19 Jan 2005 08:31:31 -0800
- Subject: PATCH: ARM dl-trampoline.S
- Reply-to: mark at codesourcery dot com
This patch updates the ARM port for the recent dl-trampoline.S and
link.h changes. OK to apply?
--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
2005-01-19 Mark Mitchell <mark@codesourcery.com>
* elf/tst-auditmod1.c: Add ARM support.
* sysdeps/arm/dl-machine.h (ELF_MACHINE_RUNTIME_TRAMPOLINE):
Remove.
(RESOLVE): Do not use it; use ...
(RESOLVE_MAP): ... instead.
(ARCH_LA_PLTENTER): Define.
(ARCH_LA_PLTEXIT): Likewise.
(elf_machine_rel): Use RESOLVE_MAP, not RESOLVE.
(elf_machine_rela): Likewise.
* sysdeps/arm/dl-trampoline.S: New file.
* sysdeps/arm/bits/link.h: Likewise.
* sysdeps/generic/ldsodefs.h (struct La_arm_regs): Declare.
(struct audit_ifaces): Add ARM functions.
Index: elf/tst-auditmod1.c
===================================================================
RCS file: /cvs/glibc/libc/elf/tst-auditmod1.c,v
retrieving revision 1.7
diff -c -5 -p -r1.7 tst-auditmod1.c
*** elf/tst-auditmod1.c 16 Jan 2005 06:24:59 -0000 1.7
--- elf/tst-auditmod1.c 19 Jan 2005 16:20:37 -0000
*************** la_symbind64 (Elf64_Sym *sym, unsigned i
*** 100,110 ****
symname, (long int) sym->st_value, ndx, *flags);
return sym->st_value;
}
! #ifdef __i386__
# define pltenter la_i86_gnu_pltenter
# define pltexit la_i86_gnu_pltexit
# define La_regs La_i86_regs
# define La_retval La_i86_retval
# define int_retval lrv_eax
--- 100,116 ----
symname, (long int) sym->st_value, ndx, *flags);
return sym->st_value;
}
! #ifdef __arm__
! # define pltenter la_arm_gnu_plteneter
! # define pltext la_arm_gnu_pltexit
! # define La_regs La_arm_regs
! # define La_retval La_arm_retval
! # define int_retval lvr_r0
! #elif defined __i386__
# define pltenter la_i86_gnu_pltenter
# define pltexit la_i86_gnu_pltexit
# define La_regs La_i86_regs
# define La_retval La_i86_retval
# define int_retval lrv_eax
Index: sysdeps/arm/dl-machine.h
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/arm/dl-machine.h,v
retrieving revision 1.49
diff -c -5 -p -r1.49 dl-machine.h
*** sysdeps/arm/dl-machine.h 4 Dec 2004 21:20:17 -0000 1.49
--- sysdeps/arm/dl-machine.h 19 Jan 2005 16:20:38 -0000
*************** elf_machine_runtime_setup (struct link_m
*** 127,249 ****
#define BX(x) "bx\t" #x
#else
#define BX(x) "mov\tpc, " #x
#endif
- #ifndef PROF
- # define ELF_MACHINE_RUNTIME_TRAMPOLINE asm ("\
- .text\n\
- .globl _dl_runtime_resolve\n\
- .type _dl_runtime_resolve, #function\n\
- .align 2\n\
- _dl_runtime_resolve:\n\
- @ we get called with\n\
- @ stack[0] contains the return address from this call\n\
- @ ip contains &GOT[n+3] (pointer to function)\n\
- @ lr points to &GOT[2]\n\
- \n\
- @ stack arguments\n\
- stmdb sp!,{r0-r3}\n\
- \n\
- @ get pointer to linker struct\n\
- ldr r0, [lr, #-4]\n\
- \n\
- @ prepare to call fixup()\n\
- @ change &GOT[n+3] into 8*n NOTE: reloc are 8 bytes each\n\
- sub r1, ip, lr\n\
- sub r1, r1, #4\n\
- add r1, r1, r1\n\
- \n\
- @ call fixup routine\n\
- bl fixup\n\
- \n\
- @ save the return\n\
- mov ip, r0\n\
- \n\
- @ get arguments and return address back\n\
- ldmia sp!, {r0-r3,lr}\n\
- \n\
- @ jump to the newly found address\n\
- " BX(ip) "\n\
- \n\
- .size _dl_runtime_resolve, .-_dl_runtime_resolve\n\
- \n\
- .globl _dl_runtime_profile\n\
- .type _dl_runtime_profile, #function\n\
- .align 2\n\
- _dl_runtime_profile:\n\
- @ stack arguments\n\
- stmdb sp!, {r0-r3}\n\
- \n\
- @ get pointer to linker struct\n\
- ldr r0, [lr, #-4]\n\
- \n\
- @ prepare to call fixup()\n\
- @ change &GOT[n+3] into 8*n NOTE: reloc are 8 bytes each\n\
- sub r1, ip, lr\n\
- sub r1, r1, #4\n\
- add r1, r1, r1\n\
- \n\
- @ call profiling fixup routine\n\
- bl profile_fixup\n\
- \n\
- @ save the return\n\
- mov ip, r0\n\
- \n\
- @ get arguments and return address back\n\
- ldmia sp!, {r0-r3,lr}\n\
- \n\
- @ jump to the newly found address\n\
- " BX(ip) "\n\
- \n\
- .size _dl_runtime_resolve, .-_dl_runtime_resolve\n\
- .previous\n\
- ");
- #else // PROF
- # define ELF_MACHINE_RUNTIME_TRAMPOLINE asm ("\
- .text\n\
- .globl _dl_runtime_resolve\n\
- .globl _dl_runtime_profile\n\
- .type _dl_runtime_resolve, #function\n\
- .type _dl_runtime_profile, #function\n\
- .align 2\n\
- _dl_runtime_resolve:\n\
- _dl_runtime_profile:\n\
- @ we get called with\n\
- @ stack[0] contains the return address from this call\n\
- @ ip contains &GOT[n+3] (pointer to function)\n\
- @ lr points to &GOT[2]\n\
- \n\
- @ stack arguments\n\
- stmdb sp!, {r0-r3}\n\
- \n\
- @ get pointer to linker struct\n\
- ldr r0, [lr, #-4]\n\
- \n\
- @ prepare to call fixup()\n\
- @ change &GOT[n+3] into 8*n NOTE: reloc are 8 bytes each\n\
- sub r1, ip, lr\n\
- sub r1, r1, #4\n\
- add r1, r1, r1\n\
- \n\
- @ call profiling fixup routine\n\
- bl fixup\n\
- \n\
- @ save the return\n\
- mov ip, r0\n\
- \n\
- @ get arguments and return address back\n\
- ldmia sp!, {r0-r3,lr}\n\
- \n\
- @ jump to the newly found address\n\
- " BX(ip) "\n\
- \n\
- .size _dl_runtime_profile, .-_dl_runtime_profile\n\
- .previous\n\
- ");
- #endif //PROF
-
/* Mask identifying addresses reserved for the user program,
where the dynamic linker should not map anything. */
#define ELF_MACHINE_USER_ADDRESS_MASK 0xf8000000UL
/* Initial entry point code for the dynamic linker.
--- 127,136 ----
*************** elf_machine_plt_value (struct link_map *
*** 346,358 ****
Elf32_Addr value)
{
return value;
}
#endif /* !dl_machine_h */
! #ifdef RESOLVE
/* ARM never uses Elf32_Rela relocations for the dynamic linker.
Prelinked libraries may use Elf32_Rela though. */
# ifdef RTLD_BOOTSTRAP
# define ELF_MACHINE_NO_RELA 1
--- 233,249 ----
Elf32_Addr value)
{
return value;
}
+ /* Names of the architecture-specific auditing callback functions. */
+ #define ARCH_LA_PLTENTER arm_gnu_pltenter
+ #define ARCH_LA_PLTEXIT arm_gnu_pltexit
+
#endif /* !dl_machine_h */
! #ifdef RESOLVE_MAP
/* ARM never uses Elf32_Rela relocations for the dynamic linker.
Prelinked libraries may use Elf32_Rela though. */
# ifdef RTLD_BOOTSTRAP
# define ELF_MACHINE_NO_RELA 1
*************** elf_machine_rel (struct link_map *map, c
*** 423,433 ****
# endif
else
#endif
{
const Elf32_Sym *const refsym = sym;
! Elf32_Addr value = RESOLVE (&sym, version, r_type);
if (sym)
value += sym->st_value;
switch (r_type)
{
--- 314,324 ----
# endif
else
#endif
{
const Elf32_Sym *const refsym = sym;
! Elf32_Addr value = RESOLVE_MAP (&sym, version, r_type);
if (sym)
value += sym->st_value;
switch (r_type)
{
*************** elf_machine_rela (struct link_map *map,
*** 532,542 ****
else
{
# ifndef RESOLVE_CONFLICT_FIND_MAP
const Elf32_Sym *const refsym = sym;
# endif
! Elf32_Addr value = RESOLVE (&sym, version, r_type);
if (sym)
value += sym->st_value;
switch (r_type)
{
--- 423,433 ----
else
{
# ifndef RESOLVE_CONFLICT_FIND_MAP
const Elf32_Sym *const refsym = sym;
# endif
! Elf32_Addr value = RESOLVE_MAP (&sym, version, r_type);
if (sym)
value += sym->st_value;
switch (r_type)
{
*************** elf_machine_lazy_rel (struct link_map *m
*** 631,636 ****
}
else
_dl_reloc_bad_type (map, r_type, 1);
}
! #endif /* RESOLVE */
--- 522,527 ----
}
else
_dl_reloc_bad_type (map, r_type, 1);
}
! #endif /* RESOLVE_MAP */
Index: sysdeps/arm/dl-trampoline.S
===================================================================
RCS file: sysdeps/arm/dl-trampoline.S
diff -N sysdeps/arm/dl-trampoline.S
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- sysdeps/arm/dl-trampoline.S 19 Jan 2005 16:20:38 -0000
***************
*** 0 ****
--- 1,135 ----
+ /* PLT trampolines. ARM version.
+ 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. */
+
+ #include <sysdep.h>
+
+ #if defined(__USE_BX__)
+ #define BX(x) bx x
+ #else
+ #define BX(x) mov pc, x
+ #endif
+
+ #ifndef PROF
+ .text
+ .globl _dl_runtime_resolve
+ .type _dl_runtime_resolve, #function
+ .align 2
+ _dl_runtime_resolve:
+ @ we get called with
+ @ stack[0] contains the return address from this call
+ @ ip contains &GOT[n+3] (pointer to function)
+ @ lr points to &GOT[2]
+
+ @ stack arguments
+ stmdb sp!,{r0-r3}
+
+ @ get pointer to linker struct
+ ldr r0, [lr, #-4]
+
+ @ prepare to call _dl_fixup()
+ @ change &GOT[n+3] into 8*n NOTE: reloc are 8 bytes each
+ sub r1, ip, lr
+ sub r1, r1, #4
+ add r1, r1, r1
+
+ @ call fixup routine
+ bl _dl_fixup
+
+ @ save the return
+ mov ip, r0
+
+ @ get arguments and return address back
+ ldmia sp!, {r0-r3,lr}
+
+ @ jump to the newly found address
+ BX(ip)
+
+ .size _dl_runtime_resolve, .-_dl_runtime_resolve
+
+ .globl _dl_runtime_profile
+ .type _dl_runtime_profile, #function
+ .align 2
+ _dl_runtime_profile:
+ @ stack arguments
+ stmdb sp!, {r0-r3}
+
+ @ get pointer to linker struct
+ ldr r0, [lr, #-4]
+
+ @ prepare to call _dl_profile_fixup()
+ @ change &GOT[n+3] into 8*n NOTE: reloc are 8 bytes each
+ sub r1, ip, lr
+ sub r1, r1, #4
+ add r1, r1, r1
+
+ @ call profiling fixup routine
+ bl _dl_profile_fixup
+
+ @ save the return
+ mov ip, r0
+
+ @ get arguments and return address back
+ ldmia sp!, {r0-r3,lr}
+
+ @ jump to the newly found address
+ BX(ip)
+
+ .size _dl_runtime_resolve, .-_dl_runtime_resolve
+ .previous
+ #else
+ .text
+ .globl _dl_runtime_resolve
+ .globl _dl_runtime_profile
+ .type _dl_runtime_resolve, #function
+ .type _dl_runtime_profile, #function
+ .align 2
+ _dl_runtime_resolve:
+ _dl_runtime_profile:
+ @ we get called with
+ @ stack[0] contains the return address from this call
+ @ ip contains &GOT[n+3] (pointer to function)
+ @ lr points to &GOT[2]
+
+ @ stack arguments
+ stmdb sp!, {r0-r3}
+
+ @ get pointer to linker struct
+ ldr r0, [lr, #-4]
+
+ @ prepare to call _dl_fixup()
+ @ change &GOT[n+3] into 8*n NOTE: reloc are 8 bytes each
+ sub r1, ip, lr
+ sub r1, r1, #4
+ add r1, r1, r1
+
+ @ call profiling fixup routine
+ bl _dl_fixup
+
+ @ save the return
+ mov ip, r0
+
+ @ get arguments and return address back
+ ldmia sp!, {r0-r3,lr}
+
+ @ jump to the newly found address
+ BX(ip)
+
+ .size _dl_runtime_profile, .-_dl_runtime_profile
+ .previous
+ #endif
Index: sysdeps/arm/bits/link.h
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/arm/bits/link.h,v
retrieving revision 1.2
diff -c -5 -p -r1.2 link.h
*** sysdeps/arm/bits/link.h 6 Jan 2005 22:40:20 -0000 1.2
--- sysdeps/arm/bits/link.h 19 Jan 2005 16:20:38 -0000
***************
*** 0 ****
--- 1,57 ----
+ /* 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 ARM. */
+ typedef struct La_arm_regs
+ {
+ uint32_t lvr_r0;
+ uint32_t lvr_r1;
+ uint32_t lvr_r2;
+ uint32_t lvr_r3;
+ } La_arm_regs;
+
+ /* Return values for calls from PLT on ARM. */
+ typedef struct La_arm_retval
+ {
+ uint32_t lvr_r0;
+ uint32_t lvr_r1;
+ } La_arm_retval;
+
+
+ __BEGIN_DECLS
+
+ extern Elf32_Addr la_arm_gnu_pltenter (Elf32_Sym *__sym, unsigned int __ndx,
+ uintptr_t *__refcook,
+ uintptr_t *__defcook,
+ La_arm_regs *__regs,
+ unsigned int *__flags,
+ const char *__symname,
+ long int *__framesizep);
+ extern unsigned int la_arm_gnu_pltexit (Elf32_Sym *__sym, unsigned int __ndx,
+ uintptr_t *__refcook,
+ uintptr_t *__defcook,
+ const La_arm_regs *__inregs,
+ La_arm_retval *__outregs,
+ const char *symname);
+
+ __END_DECLS
Index: sysdeps/generic/ldsodefs.h
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/generic/ldsodefs.h,v
retrieving revision 1.112
diff -c -5 -p -r1.112 ldsodefs.h
*** sysdeps/generic/ldsodefs.h 16 Jan 2005 02:07:29 -0000 1.112
--- sysdeps/generic/ldsodefs.h 19 Jan 2005 16:20:38 -0000
*************** enum allowmask
*** 173,182 ****
--- 173,183 ----
allow_ldso = 8
};
/* Type for list of auditing interfaces. */
+ struct La_arm_regs;
struct La_i86_regs;
struct La_i86_retval;
struct La_x86_64_regs;
struct La_x86_64_retval;
struct La_ppc32_regs;
*************** struct audit_ifaces
*** 202,211 ****
--- 203,216 ----
uintptr_t (*symbind64) (Elf64_Sym *, unsigned int, uintptr_t *,
uintptr_t *, unsigned int *, const char *);
};
union
{
+ Elf32_Addr (*arm_gnu_pltenter) (Elf32_Sym *, unsigned int, uintptr_t *,
+ uintptr_t *, struct La_arm_regs *,
+ unsigned int *, const char *name,
+ long int *framesizep);
Elf32_Addr (*i86_gnu_pltenter) (Elf32_Sym *, unsigned int, uintptr_t *,
uintptr_t *, struct La_i86_regs *,
unsigned int *, const char *name,
long int *framesizep);
Elf64_Addr (*x86_64_gnu_pltenter) (Elf64_Sym *, unsigned int, uintptr_t *,
*************** struct audit_ifaces
*** 229,238 ****
--- 234,246 ----
unsigned int *, const char *name,
long int *framesizep);
};
union
{
+ unsigned int (*arm_gnu_pltexit) (Elf32_Sym *, unsigned int, uintptr_t *,
+ uintptr_t *, const struct La_arm_regs *,
+ struct La_i86_retval *, const char *);
unsigned int (*i86_gnu_pltexit) (Elf32_Sym *, unsigned int, uintptr_t *,
uintptr_t *, const struct La_i86_regs *,
struct La_i86_retval *, const char *);
unsigned int (*x86_64_gnu_pltexit) (Elf64_Sym *, unsigned int, uintptr_t *,
uintptr_t *,