about summary refs log tree commit diff
path: root/sysdeps/arm
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/arm')
-rw-r--r--sysdeps/arm/__longjmp.S7
-rw-r--r--sysdeps/arm/bits/fenv.h90
-rw-r--r--sysdeps/arm/bsd-_setjmp.S4
-rw-r--r--sysdeps/arm/bsd-setjmp.S4
-rw-r--r--sysdeps/arm/dl-machine.h478
-rw-r--r--sysdeps/arm/elf/setjmp.S76
-rw-r--r--sysdeps/arm/elf/start.S109
-rw-r--r--sysdeps/arm/fpu/__longjmp.S36
-rw-r--r--sysdeps/arm/fpu/setjmp.S35
-rw-r--r--sysdeps/arm/init-first.c71
-rw-r--r--sysdeps/arm/memset.S68
-rw-r--r--sysdeps/arm/setjmp.S9
-rw-r--r--sysdeps/arm/sysdep.h13
13 files changed, 978 insertions, 22 deletions
diff --git a/sysdeps/arm/__longjmp.S b/sysdeps/arm/__longjmp.S
index a2042f5543..239b0cfc85 100644
--- a/sysdeps/arm/__longjmp.S
+++ b/sysdeps/arm/__longjmp.S
@@ -1,5 +1,5 @@
 /* longjmp for ARM.
-   Copyright (C) 1997 Free Software Foundation, Inc.
+   Copyright (C) 1997, 1998 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
@@ -29,10 +29,5 @@ ENTRY (__longjmp)
 	movs	r0, r1		/* get the return value in place */
 	moveq	r1, #1		/* can't let setjmp() return zero! */
 
-#if __ARM_USES_FP
-	add	r2, r2, #48
-	lfmfd	f4, 4, [r2]
-#endif
-
 	LOADREGS(ia, r2, {v1-v6, sl, fp, sp, pc})
 END (__longjmp)
diff --git a/sysdeps/arm/bits/fenv.h b/sysdeps/arm/bits/fenv.h
new file mode 100644
index 0000000000..3e4cdd3f3b
--- /dev/null
+++ b/sysdeps/arm/bits/fenv.h
@@ -0,0 +1,90 @@
+/* Copyright (C) 1997, 1998 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 Library General Public License as
+   published by the Free Software Foundation; either version 2 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#ifndef _FENV_H
+# error "Never use <bits/fenv.h> directly; include <fenv.h> instead."
+#endif
+
+
+/* Define bits representing the exception.  We use the bit positions
+   of the appropriate bits in the FPU control word.  */
+enum
+  {
+    FE_INVALID = 0x01,
+#define FE_INVALID	FE_INVALID
+    __FE_DENORM = 0x02,
+    FE_DIVBYZERO = 0x04,
+#define FE_DIVBYZERO	FE_DIVBYZERO
+    FE_OVERFLOW = 0x08,
+#define FE_OVERFLOW	FE_OVERFLOW
+    FE_UNDERFLOW = 0x10,
+#define FE_UNDERFLOW	FE_UNDERFLOW
+    FE_INEXACT = 0x20
+#define FE_INEXACT	FE_INEXACT
+  };
+
+#define FE_ALL_EXCEPT \
+	(FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | FE_OVERFLOW | FE_INVALID)
+
+/* The ARM FPU supports all of the four defined rounding modes.  We
+   use again the bit positions in the FPU control word as the values
+   for the appropriate macros.  */
+enum
+  {
+    FE_TONEAREST = 0,
+#define FE_TONEAREST	FE_TONEAREST
+    FE_DOWNWARD = 0x400,
+#define FE_DOWNWARD	FE_DOWNWARD
+    FE_UPWARD = 0x800,
+#define FE_UPWARD	FE_UPWARD
+    FE_TOWARDSZERO = 0xc00
+#define FE_TOWARDSZERO	FE_TOWARDSZERO
+  };
+
+
+/* Type representing exception flags.  */
+typedef unsigned short int fexcept_t;
+
+
+/* Type representing floating-point environment.  This function corresponds
+   to the layout of the block written by the `fstenv'.  */
+typedef struct
+  {
+    unsigned short int control_word;
+    unsigned short int __unused1;
+    unsigned short int status_word;
+    unsigned short int __unused2;
+    unsigned short int tags;
+    unsigned short int __unused3;
+    unsigned int eip;
+    unsigned short int cs_selector;
+    unsigned int opcode:11;
+    unsigned int __unused4:5;
+    unsigned int data_offset;
+    unsigned short int data_selector;
+    unsigned short int __unused5;
+  }
+fenv_t;
+
+/* If the default argument is used we use this value.  */
+#define FE_DFL_ENV	((fenv_t *) -1)
+
+#ifdef __USE_GNU
+/* Floating-point environment where none of the exception is masked.  */
+# define FE_NOMASK_ENV	((fenv_t *) -2)
+#endif
diff --git a/sysdeps/arm/bsd-_setjmp.S b/sysdeps/arm/bsd-_setjmp.S
index 5643c50918..6ae6da6457 100644
--- a/sysdeps/arm/bsd-_setjmp.S
+++ b/sysdeps/arm/bsd-_setjmp.S
@@ -1,5 +1,5 @@
 /* BSD `_setjmp' entry point to `sigsetjmp (..., 0)'.  ARM version.
-   Copyright (C) 1997 Free Software Foundation, Inc.
+   Copyright (C) 1997, 1998 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
@@ -25,5 +25,5 @@
 
 ENTRY (_setjmp)
 	mov	r1, #0
-	b	__sigsetjmp
+	b	C_SYMBOL_NAME(__sigsetjmp)
 END (_setjmp)
diff --git a/sysdeps/arm/bsd-setjmp.S b/sysdeps/arm/bsd-setjmp.S
index ac7dd96821..52622e2155 100644
--- a/sysdeps/arm/bsd-setjmp.S
+++ b/sysdeps/arm/bsd-setjmp.S
@@ -1,5 +1,5 @@
 /* BSD `setjmp' entry point to `sigsetjmp (..., 1)'.  ARM version.
-   Copyright (C) 1997 Free Software Foundation, Inc.
+   Copyright (C) 1997, 1998 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
@@ -25,5 +25,5 @@
 
 ENTRY (setjmp)
 	mov	r1, #1
-	b	__sigsetjmp
+	b	C_SYMBOL_NAME(__sigsetjmp)
 END (setjmp)
diff --git a/sysdeps/arm/dl-machine.h b/sysdeps/arm/dl-machine.h
new file mode 100644
index 0000000000..66b69d02db
--- /dev/null
+++ b/sysdeps/arm/dl-machine.h
@@ -0,0 +1,478 @@
+/* Machine-dependent ELF dynamic relocation inline functions.  ARM version.
+   Copyright (C) 1995, 1996, 1997, 1998 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 Library General Public License as
+   published by the Free Software Foundation; either version 2 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#ifndef dl_machine_h
+#define dl_machine_h
+
+#define ELF_MACHINE_NAME "ARM"
+
+#include <sys/param.h>
+
+#include <assert.h>
+
+/* Return nonzero iff E_MACHINE is compatible with the running host.  */
+static inline int __attribute__ ((unused))
+elf_machine_matches_host (Elf32_Half e_machine)
+{
+  switch (e_machine)
+    {
+    case EM_ARM:
+      return 1;
+    default:
+      return 0;
+    }
+}
+
+
+/* Return the link-time address of _DYNAMIC.  Conveniently, this is the
+   first element of the GOT.  This must be inlined in a function which
+   uses global data.  */
+static inline Elf32_Addr __attribute__ ((unused))
+elf_machine_dynamic (void)
+{
+  register Elf32_Addr *got asm ("r10");
+  return *got;
+}
+
+
+/* Return the run-time load address of the shared object.  */
+// patb
+static inline Elf32_Addr __attribute__ ((unused))
+elf_machine_load_address (void)
+{
+  Elf32_Addr addr;
+  asm (" ldr ip,.L1
+  	ldr r3,.L3
+	add r3, r3, sl
+  	ldr ip,[sl, ip]
+  	sub ip, r3, ip
+  	b .L2
+  	.L1: .word _dl_start(GOT)
+	.L3: .word _dl_start(GOTOFF)
+  	.L2: mov %0, ip"
+       : "=r" (addr) : : "ip", "r3");
+  return addr;
+}
+
+
+/* Set up the loaded object described by L so its unrelocated PLT
+   entries will jump to the on-demand fixup code in dl-runtime.c.  */
+
+static inline int __attribute__ ((unused))
+elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
+{
+  Elf32_Addr *got;
+  extern void _dl_runtime_resolve (Elf32_Word);
+  extern void _dl_runtime_profile (Elf32_Word);
+
+  if (l->l_info[DT_JMPREL] && lazy)
+    {
+      /* patb: this is different than i386 */
+      /* The GOT entries for functions in the PLT have not yet been filled
+	 in.  Their initial contents will arrange when called to push an
+	 index into the .got section, load ip with &_GLOBAL_OFFSET_TABLE_[3],
+	 and then jump to _GLOBAL_OFFSET_TABLE[2].  */
+      got = (Elf32_Addr *) (l->l_addr + l->l_info[DT_PLTGOT]->d_un.d_ptr);
+      got[1] = (Elf32_Addr) l;	/* Identify this shared object.  */
+
+      /* The got[2] entry contains the address of a function which gets
+	 called to get the address of a so far unresolved function and
+	 jump to it.  The profiling extension of the dynamic linker allows
+	 to intercept the calls to collect information.  In this case we
+	 don't store the address in the GOT so that all future calls also
+	 end in this function.  */
+      if (profile)
+	{
+	  got[2] = (Elf32_Addr) &_dl_runtime_profile;
+	  /* Say that we really want profiling and the timers are started.  */
+	  _dl_profile_map = l;
+	}
+      else
+	/* This function will get called to fix up the GOT entry indicated by
+	   the offset on the stack, and then jump to the resolved address.  */
+	got[2] = (Elf32_Addr) &_dl_runtime_resolve;
+    }
+  return lazy;
+}
+
+/* This code is used in dl-runtime.c to call the `fixup' function
+   and then redirect to the address it returns.  */
+   // macro for handling PIC situation....
+#ifdef PIC
+#define CALL_ROUTINE(x) " ldr sl,0f
+	add 	sl, pc, sl
+1:	ldr	r2, 2f
+	mov	lr, pc
+	add	pc, sl, r2
+	b	3f
+0:	.word	_GLOBAL_OFFSET_TABLE_ - 1b - 4
+2:	.word " #x "(GOTOFF)
+3:	"
+#else
+#define CALL_ROUTINE(x) " bl " #x
+#endif
+
+#ifndef PROF
+# define ELF_MACHINE_RUNTIME_TRAMPOLINE asm ("\
+	.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]
+
+	@ save almost everything; lr is already on the stack
+	stmdb	sp!,{r0-r3,sl,fp}
+
+	@ prepare to call 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
+
+	@ get pointer to linker struct
+	ldr	r0, [lr, #-4]
+
+	" CALL_ROUTINE(fixup) "
+
+	@ save the return
+	mov	ip, r0
+
+	@ restore the stack
+	ldmia	sp!,{r0-r3,sl,fp,lr}
+
+	@ jump to the newly found address
+	mov	pc, ip
+
+	.size _dl_runtime_resolve, .-_dl_runtime_resolve
+
+	.globl _dl_runtime_profile
+	.type _dl_runtime_profile, #function
+	.align 2
+_dl_runtime_profile:
+	@ we get caled with
+	@ 	stack[0] contains the return address from this call
+	@	ip contains &GOT[n+3] (pointer to function)
+	@	lr points to &GOT[2]
+
+	@ save almost everything; return add is already on the stack
+	stmdb	sp!,{r0-r3,fp}
+
+	@ prepare to call 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
+
+	@ get pointer to linker struct
+	ldr	r0, [lr, #-4]
+
+	" CALL_ROUTINE(profile_fixup) "
+
+	@ save the return
+	mov	ip, r0
+
+	@ restore the stack
+	ldmia	sp!,{r0-r3,fp,lr}
+
+	@ jump to the newly found address
+	mov	pc, ip
+
+	.size _dl_runtime_profile, .-_dl_runtime_profile
+	.previous
+");
+#else // PROF
+# define ELF_MACHINE_RUNTIME_TRAMPOLINE asm ("\
+	.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:
+	stmdb	sp!,{r0-r3,fp}
+	ldr	r1,[sp,#0x34]
+	sub	r1, ip, lr
+	sub	r1, r1, #4
+	add	r1, r1, r1
+	ldr	r0, [lr, #-4]
+	" CALL_ROUTINE(fixup) "
+	mov	ip, r0
+	ldmia	sp!,{r0-r3,fp,lr}
+	mov	pc, ip
+
+	.size _dl_runtime_profile, .-_dl_runtime_profile
+	.previous
+");
+#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.
+   The C function `_dl_start' is the real entry point;
+   its return value is the user program's entry point.  */
+
+#define RTLD_START asm ("\
+.text
+.globl _start
+.globl _dl_start_user
+_start:
+	@ at start time, all the args are on the stack
+	mov	r0, sp
+	bl	_dl_start
+	@ returns user entry point in r0
+_dl_start_user:
+	mov	r6, r0
+	@ we are PIC code, so get global offset table
+	ldr	sl, .L_GET_GOT
+	add	sl, pc, sl
+.L_GOT_GOT:
+	@ See if we were run as a command with the executable file
+	@ name as an extra leading argument.
+	ldr	r1, .L_SKIP_ARGS
+	ldr	r1, [sl, r1]
+	@ get the original arg count
+	ldr	r0, [sp]
+	@ subtract _dl_skip_args from it
+	sub	r0, r0, r1
+	@ adjust the stack pointer to skip them
+	add	sp, sp, r1, lsl #2
+	@ store the new argc in the new stack location
+	str	r0, [sp]
+
+	@ now we enter a _dl_init_next loop
+	ldr	r2, .L_DEF_SCOPE
+	ldr	r2, [sl, r2]
+	ldr	r4, [r2, #8]
+	@ call _dl_init_next to get the address of an initalizer
+0:	mov	r0, r4
+	bl	_dl_init_next(PLT)
+	cmp	r0, #0
+	beq	1f
+	@ call the shared-object initializer
+	@ during this call, the stack may get moved around
+	mov	lr, pc
+	mov	pc, r0
+	@ go back and look for another initializer
+	b	0b
+1:	@ clear the startup flag
+	ldr	r2, .L_STARTUP_FLAG
+	ldr	r1, [sl, r2]
+	@ we know r0==0 at this point
+	str	r0, [r1]
+	@ load the finalizer function
+	ldr	r0, .L_FINI_PROC
+	ldr	r0, [sl, r0]
+	@ jump to the user_s entry point
+	mov	pc, r6
+.L_GET_GOT:
+	.word	_GLOBAL_OFFSET_TABLE_ - .L_GOT_GOT - 4	\n\
+.L_SKIP_ARGS:					\n\
+	.word	_dl_skip_args(GOTOFF)		\n\
+.L_DEF_SCOPE:					\n\
+	.word	_dl_default_scope(GOT)		\n\
+.L_STARTUP_FLAG:
+	.word	_dl_starting_up(GOT)
+.L_FINI_PROC:
+	.word	_dl_fini(GOT)
+.previous\n\
+");
+
+/* Nonzero iff TYPE should not be allowed to resolve to one of
+   the main executable's symbols, as for a COPY reloc.  */
+#define elf_machine_lookup_noexec_p(type) ((type) == R_ARM_COPY)
+
+/* Nonzero iff TYPE describes relocation of a PLT entry, so
+   PLT entries should not be allowed to define the value.  */
+#define elf_machine_lookup_noplt_p(type) ((type) == R_ARM_JMP_SLOT)
+
+/* A reloc type used for ld.so cmdline arg lookups to reject PLT entries.  */
+#define ELF_MACHINE_JMP_SLOT	R_ARM_JMP_SLOT
+
+/* The i386 never uses Elf32_Rela relocations.  */
+#define ELF_MACHINE_NO_RELA 1
+
+/* We define an initialization functions.  This is called very early in
+   _dl_sysdep_start.  */
+#define DL_PLATFORM_INIT dl_platform_init ()
+
+extern const char *_dl_platform;
+
+static inline void __attribute__ ((unused))
+dl_platform_init (void)
+{
+  if (_dl_platform == NULL)
+    /* We default to ARM
+    This is where processors could be distinguished arm2, arm6, sa110, etc */
+    _dl_platform = "ARM";
+}
+
+static inline void
+elf_machine_fixup_plt (struct link_map *map, const Elf32_Rel *reloc,
+		       Elf32_Addr *reloc_addr, Elf32_Addr value)
+{
+  *reloc_addr = value;
+}
+
+/* Return the final value of a plt relocation.  */
+static inline Elf32_Addr
+elf_machine_plt_value (struct link_map *map, const Elf32_Rel *reloc,
+		       Elf32_Addr value)
+{
+  return value;
+}
+
+#endif /* !dl_machine_h */
+
+#ifdef RESOLVE
+
+extern char **_dl_argv;
+
+/* Perform the relocation specified by RELOC and SYM (which is fully resolved).
+   MAP is the object containing the reloc.  */
+
+static inline void
+elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc,
+		 const Elf32_Sym *sym, const struct r_found_version *version,
+		 Elf32_Addr *const reloc_addr)
+{
+  if (ELF32_R_TYPE (reloc->r_info) == R_ARM_RELATIVE)
+    {
+#ifndef RTLD_BOOTSTRAP
+      if (map != &_dl_rtld_map) /* Already done in rtld itself.  */
+#endif
+	*reloc_addr += map->l_addr;
+    }
+  else if (ELF32_R_TYPE (reloc->r_info) != R_ARM_NONE)
+    {
+      const Elf32_Sym *const refsym = sym;
+      Elf32_Addr value = RESOLVE (&sym, version, ELF32_R_TYPE (reloc->r_info));
+      if (sym)
+	value += sym->st_value;
+
+      switch (ELF32_R_TYPE (reloc->r_info))
+	{
+	case R_ARM_COPY:
+	  if (sym == NULL)
+	    /* This can happen in trace mode if an object could not be
+	       found.  */
+	    break;
+	  if (sym->st_size > refsym->st_size
+	      || (_dl_verbose && sym->st_size < refsym->st_size))
+	    {
+	      const char *strtab;
+
+	      strtab = ((const char *) map->l_addr
+			+ map->l_info[DT_STRTAB]->d_un.d_ptr);
+	      _dl_sysdep_error (_dl_argv[0] ?: "<program name unknown>",
+				": Symbol `", strtab + refsym->st_name,
+				"' has different size in shared object, "
+				"consider re-linking\n", NULL);
+	    }
+	  memcpy (reloc_addr, (void *) value, MIN (sym->st_size,
+						   refsym->st_size));
+	  break;
+	case R_ARM_GLOB_DAT:
+	case R_ARM_JMP_SLOT:
+
+#if 0
+#define _HEX(i) for (j=28; j>=0; j-=4) b[7-j/4]="0123456789abcdef"[((int)i>>j)&15];
+{
+char b[10];
+int j;
+_HEX(map->l_addr);
+__asm__ (" mov r0, #2; mov r1, %0; mov r2, #9; swi 0x00900004; "
+	: : "r"(b) : "r0", "r1", "r2" );
+_HEX(sym->st_size);
+__asm__ (" mov r0, #2; mov r1, %0; mov r2, #9; swi 0x00900004; "
+	: : "r"(b) : "r0", "r1", "r2" );
+_HEX(&sym->st_value);
+__asm__ (" mov r0, #2; mov r1, %0; mov r2, #9; swi 0x00900004; "
+	: : "r"(b) : "r0", "r1", "r2" );
+_HEX(sym->st_value);
+__asm__ (" mov r0, #2; mov r1, %0; mov r2, #9; swi 0x00900004; "
+	: : "r"(b) : "r0", "r1", "r2" );
+_HEX(sym);
+__asm__ (" mov r0, #2; mov r1, %0; mov r2, #9; swi 0x00900004; "
+	: : "r"(b) : "r0", "r1", "r2" );
+_HEX(reloc_addr);
+__asm__ (" mov r0, #2; mov r1, %0; mov r2, #9; swi 0x00900004; "
+	: : "r"(b) : "r0", "r1", "r2" );
+b[0]=' '; b[1]='\n';
+__asm__ (" mov r0, #2; mov r1, %0; mov r2, #2; swi 0x00900004; "
+	: : "r"(b) : "r0", "r1", "r2" );
+}
+#endif
+	  *reloc_addr = value;
+	  break;
+	case R_ARM_32:
+	  {
+#ifndef RTLD_BOOTSTRAP
+	   /* This is defined in rtld.c, but nowhere in the static
+	      libc.a; make the reference weak so static programs can
+	      still link.  This declaration cannot be done when
+	      compiling rtld.c (i.e.  #ifdef RTLD_BOOTSTRAP) because
+	      rtld.c contains the common defn for _dl_rtld_map, which
+	      is incompatible with a weak decl in the same file.  */
+	    weak_extern (_dl_rtld_map);
+	    if (map == &_dl_rtld_map)
+	      /* Undo the relocation done here during bootstrapping.
+		 Now we will relocate it anew, possibly using a
+		 binding found in the user program or a loaded library
+		 rather than the dynamic linker's built-in definitions
+		 used while loading those libraries.  */
+	      value -= map->l_addr + refsym->st_value;
+#endif
+	    *reloc_addr += value;
+	    break;
+	  }
+	case R_ARM_PC26:
+	  *reloc_addr += (value - (Elf32_Addr) reloc_addr);
+	  break;
+	default:
+	  assert (! "unexpected dynamic reloc type");
+	  break;
+	}
+    }
+}
+
+static inline void
+elf_machine_lazy_rel (struct link_map *map, const Elf32_Rel *reloc)
+{
+  Elf32_Addr *const reloc_addr = (void *) (map->l_addr + reloc->r_offset);
+  switch (ELF32_R_TYPE (reloc->r_info))
+    {
+    case R_ARM_JMP_SLOT:
+      *reloc_addr += map->l_addr;
+      break;
+    default:
+      assert (! "unexpected PLT reloc type");
+      break;
+    }
+}
+
+#endif /* RESOLVE */
diff --git a/sysdeps/arm/elf/setjmp.S b/sysdeps/arm/elf/setjmp.S
new file mode 100644
index 0000000000..51572ca515
--- /dev/null
+++ b/sysdeps/arm/elf/setjmp.S
@@ -0,0 +1,76 @@
+/* setjmp for arm, ELF version.
+   Copyright (C) 1995, 1996, 1997, 1998 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 Library General Public License as
+   published by the Free Software Foundation; either version 2 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <sysdep.h>
+#define _ASM
+#define _SETJMP_H
+#include <bits/setjmp.h>
+
+	/* We include the BSD entry points here as well but we make
+	   them weak.  */
+ENTRY (setjmp)
+	.weak C_SYMBOL_NAME (setjmp)
+	@ call comes here with
+	@ lr = return pc
+	@ r0 = &jump_buf
+
+	@ add a second argument into the fray
+	mov r1, #1
+	@ call the common code
+	b __sigsetjmp(PLT)
+END (setjmp)
+
+	/* Binary compatibility entry point.  */
+ENTRY (_setjmp)
+	.weak C_SYMBOL_NAME (_setjmp)
+ENTRY (__setjmp)
+	@ call comes here with
+	@ lr = return pc
+	@ r0 = &jump_buf
+
+	@ add a second argument into the fray
+	mov r1, #1
+	@ fall through to the common code....
+
+ENTRY (__sigsetjmp)
+	@ save the registers into the jmp_buf....
+	stmia r0, {r1-r6, sl, fp, sp, lr}
+
+	/* Make a tail call to __sigjmp_save; it takes the same args.  */
+#ifdef	PIC
+	/* We cannot use the PLT, because it requires that sl==r10 be set, but
+           we can't save and restore our caller's value.  Instead, we do an
+           indirect jump through the GOT, using for the temporary register
+           ip, which is call-clobbered.  */
+	ldr ip, 1f
+	add ip, ip, pc
+2:	@ get the address of __sigjmp_save
+	ldr r1, 3f
+	ldr ip, [ip, r1]
+	@ restore r1
+	ldr r1, [r0]
+	@ jump to *__sigjmp_save
+	mov pc, ip
+1:	.word _GLOBAL_OFFSET_TABLE_ - 2b - 4
+3:	.word __sigjmp_save(GOT)
+
+#else
+	b __sigjmp_save
+#endif
+END (__sigsetjmp)
diff --git a/sysdeps/arm/elf/start.S b/sysdeps/arm/elf/start.S
new file mode 100644
index 0000000000..e0964a1e38
--- /dev/null
+++ b/sysdeps/arm/elf/start.S
@@ -0,0 +1,109 @@
+/* Startup code for ARM & ELF
+   Copyright (C) 1995, 1996, 1997, 1998 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 Library General Public License as
+   published by the Free Software Foundation; either version 2 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+/* This is the canonical entry point, usually the first thing in the text
+   segment.
+
+	Note that the code in the .init section has already been run.
+	This includes _init and _libc_init
+
+
+	At this entry point, most registers' values are unspecified, except for:
+
+   r0		Contains a function pointer to be registered with `atexit'.
+   		This is how the dynamic linker arranges to have DT_FINI
+		functions called for shared libraries that have been loaded
+		before this code runs.
+
+   sp		The stack contains the arguments and environment:
+   		0(%esp)			argc
+		4(%esp)			argv[0]
+		...
+		(4*argc)(%esp)		NULL
+		(4*(argc+1))(%esp)	envp[0]
+		...
+					NULL
+*/
+
+	.text
+	.globl _start
+_start:
+	/* Clear the frame pointer.  The Intel ABI suggests this be done,
+		to mark the outermost frame obviously. This seems like a
+		sensible thing to do  */
+	mov fp, #0
+
+	/* r0 contains the address of the shared library termination
+	   function, which we will register with `atexit' to be called by
+	   `exit'.  I suspect that on some systems, and when statically
+	   linked, this will not be set by anything to any function
+	   pointer; hopefully it will be zero so we don't try to call
+	   random pointers.  */
+	cmp r0,#0
+	blne atexit(PLT)
+
+	/* Do essential libc initialization.  In statically linked
+	   programs under the GNU Hurd, this is what sets up the
+	   arguments on the stack for the code below. For dyn-link
+	   programs, this has been run already, in the .init code. */
+#ifndef PIC
+	bl __libc_init_first
+
+	/* Extract the arguments and environment as encoded on the stack
+	   and set up the arguments for `main': argc, argv, envp.  */
+	ldr r0,[sp]
+	add r1,sp,#4
+	add r2,r1,r0,lsl #2
+	add r2,r2,#4
+	/* save a copy of envp while we have it */
+	ldr r3,L_environ
+	str r2,[r3]
+
+	/* Call `_init', which is the entry point to our own `.init'
+	   section; and register with `atexit' to have `exit' call
+	   `_fini', which is the entry point to our own `.fini' section.  */
+	bl _init
+	ldr r0,L_fini
+	bl atexit
+	b L_pfini
+
+L_fini:	.word _fini
+L_environ: .word _environ
+L_pfini:
+#endif
+	/* rebuild the arg list for main() */
+	ldr r0,[sp]
+	add r1,sp,#4
+	add r2,r1,r0,lsl #2
+	add r2,r2,#4
+
+	/* Call the user's main function, and exit with its value.  */
+	bl main
+	bl exit
+	/* should never get here....*/
+	bl abort
+
+
+/* Define a symbol for the first piece of initialized data.  */
+	.data
+	.globl __data_start
+__data_start:
+	.long 0
+	.weak data_start
+	data_start = __data_start
diff --git a/sysdeps/arm/fpu/__longjmp.S b/sysdeps/arm/fpu/__longjmp.S
new file mode 100644
index 0000000000..8afa177b20
--- /dev/null
+++ b/sysdeps/arm/fpu/__longjmp.S
@@ -0,0 +1,36 @@
+/* longjmp for ARM.
+   Copyright (C) 1997, 1998 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 Library General Public License as
+   published by the Free Software Foundation; either version 2 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <sysdep.h>
+#define _SETJMP_H
+#define _ASM
+#include <bits/setjmp.h>
+
+/* __longjmp(jmpbuf, val) */
+
+ENTRY (__longjmp)
+	movs	r2, r0
+	movs	r0, r1		/* get the return value in place */
+	moveq	r1, #1		/* can't let setjmp() return zero! */
+
+	add	r2, r2, #48
+	lfmfd	f4, 4, [r2]
+
+	LOADREGS(ia, r2, {v1-v6, sl, fp, sp, pc})
+END (__longjmp)
diff --git a/sysdeps/arm/fpu/setjmp.S b/sysdeps/arm/fpu/setjmp.S
new file mode 100644
index 0000000000..790e7566d4
--- /dev/null
+++ b/sysdeps/arm/fpu/setjmp.S
@@ -0,0 +1,35 @@
+/* setjmp for ARM.
+   Copyright (C) 1997, 1998 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 Library General Public License as
+   published by the Free Software Foundation; either version 2 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <sysdep.h>
+#define _SETJMP_H
+#define _ASM
+#include <bits/setjmp.h>
+
+	/* Binary compatibility entry point.  */
+ENTRY (__setjmp)
+	mov	r1, #0
+ENTRY (__sigsetjmp)
+	/* Save registers */
+	sfmea	f4, 4, [r0]!
+	stmia	r0, {v1-v6, sl, fp, sp, lr}
+
+	/* Make a tail call to __sigjmp_save; it takes the same args.  */
+	B	PLTJMP(C_SYMBOL_NAME(__sigjmp_save))
+END (__setjmp)
diff --git a/sysdeps/arm/init-first.c b/sysdeps/arm/init-first.c
new file mode 100644
index 0000000000..7e6bcf79ff
--- /dev/null
+++ b/sysdeps/arm/init-first.c
@@ -0,0 +1,71 @@
+/* Initialization code run first thing by the ELF startup code.  For ARM.
+   Copyright (C) 1995, 1996, 1997, 1998 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 Library General Public License as
+   published by the Free Software Foundation; either version 2 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <unistd.h>
+
+extern void __libc_init (int, char **, char **);
+extern void __getopt_clean_environment (char **);
+extern void __libc_global_ctors (void);
+
+int __libc_multiple_libcs = 1;
+
+pid_t __libc_pid;
+
+static void
+init (int *data)
+{
+  int argc = *data;
+  char **argv = (void *) (data + 1);
+  char **envp = &argv[argc + 1];
+
+  __environ = envp;
+  __libc_init (argc, argv, envp);
+
+  /* This is a hack to make the special getopt in GNU libc working.  */
+  __getopt_clean_environment (envp);
+}
+
+#ifdef PIC
+/* This function is called to initialize the shared C library.
+   It is called just before the user _start code from i386/elf/start.S,
+   with the stack set up as that code gets it.  */
+
+/* NOTE!  The linker notices the magical name `_init' and sets the DT_INIT
+   pointer in the dynamic section based solely on that.  It is convention
+   for this function to be in the `.init' section, but the symbol name is
+   the only thing that really matters!!  */
+/*void _init (int argc, ...) __attribute__ ((unused, section (".init")));*/
+
+void
+_init (int argc, ...)
+{
+  init (&argc);
+
+  __libc_global_ctors ();
+}
+#endif
+
+
+void
+__libc_init_first (int argc __attribute__ ((unused)), ...)
+{
+#ifndef PIC
+  init (&argc);
+#endif
+}
diff --git a/sysdeps/arm/memset.S b/sysdeps/arm/memset.S
new file mode 100644
index 0000000000..a986d687da
--- /dev/null
+++ b/sysdeps/arm/memset.S
@@ -0,0 +1,68 @@
+/* Copyright (C) 1998 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Philip Blundell <philb@gnu.org>
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 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
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <sysdep.h>
+
+/* void *memset (dstpp, c, len) */
+
+ENTRY(memset)
+	mov	a4, a1
+	cmp	a3, $8		@ at least 8 bytes to do?
+	blt	2f
+	orr	a2, a2, a2, lsl $8
+	orr	a2, a2, a2, lsl $16
+1:
+	tst	a4, $3		@ aligned yet?
+	strneb	a2, [a4], $1
+	subne	a3, a3, $1
+	bne	1b
+	mov	ip, a2
+1:
+	cmp	a3, $8		@ 8 bytes still to do?
+	blt	2f
+	stmia	a4!, {a2, ip}
+	sub	a3, a3, $8
+	cmp	a3, $8		@ 8 bytes still to do?
+	blt	2f
+	stmia	a4!, {a2, ip}
+	sub	a3, a3, $8
+	cmp	a3, $8		@ 8 bytes still to do?
+	blt	2f
+	stmia	a4!, {a2, ip}
+	sub	a3, a3, $8
+	cmp	a3, $8		@ 8 bytes still to do?
+	stmgeia	a4!, {a2, ip}
+	subge	a3, a3, $8
+	bge	1b
+2:
+	movs	a3, a3		@ anything left?
+	RETINSTR(moveq,pc,lr)	@ nope
+	rsb	a3, a3, $7
+	add	pc, pc, a3, lsl $2
+	mov	r0, r0
+	strb	a2, [a4], $1
+	strb	a2, [a4], $1
+	strb	a2, [a4], $1
+	strb	a2, [a4], $1
+	strb	a2, [a4], $1
+	strb	a2, [a4], $1
+	strb	a2, [a4], $1
+	strb	a2, [a4], $1
+	RETINSTR(mov,pc,lr)
+END(memset)
diff --git a/sysdeps/arm/setjmp.S b/sysdeps/arm/setjmp.S
index 08cd0d254e..237cc0addd 100644
--- a/sysdeps/arm/setjmp.S
+++ b/sysdeps/arm/setjmp.S
@@ -1,5 +1,5 @@
 /* setjmp for ARM.
-   Copyright (C) 1997 Free Software Foundation, Inc.
+   Copyright (C) 1997, 1998 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
@@ -27,11 +27,8 @@ ENTRY (__setjmp)
 	mov	r1, #0
 ENTRY (__sigsetjmp)
 	/* Save registers */
-#if __ARM_USES_FP
-	sfmea	f4, 4, [r0]!
-#endif
 	stmia	r0, {v1-v6, sl, fp, sp, lr}
 
 	/* Make a tail call to __sigjmp_save; it takes the same args.  */
-	B	__sigjmp_save
-END (__sigsetjmp)
+	B	PLTJMP(C_SYMBOL_NAME(__sigjmp_save))
+END (__setjmp)
diff --git a/sysdeps/arm/sysdep.h b/sysdeps/arm/sysdep.h
index 8d1e2972df..28dd402ced 100644
--- a/sysdeps/arm/sysdep.h
+++ b/sysdeps/arm/sysdep.h
@@ -1,5 +1,5 @@
 /* Assembler macros for ARM.
-   Copyright (C) 1997 Free Software Foundation, Inc.
+   Copyright (C) 1997, 1998 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
@@ -28,19 +28,23 @@
 /* ELF uses byte-counts for .align, most others use log2 of count of bytes.  */
 #define ALIGNARG(log2) 1<<log2
 /* For ELF we need the `.type' directive to make shared libs work right.  */
-#define ASM_TYPE_DIRECTIVE(name,typearg) .type name,typearg;
+#define ASM_TYPE_DIRECTIVE(name,typearg) .type name,%##typearg;
 #define ASM_SIZE_DIRECTIVE(name) .size name,.-name
 
 /* In ELF C symbols are asm symbols.  */
 #undef	NO_UNDERSCORES
 #define NO_UNDERSCORES
 
+#define PLTJMP(_x)	_x##(PLT)
+
 #else
 
 #define ALIGNARG(log2) log2
 #define ASM_TYPE_DIRECTIVE(name,type)	/* Nothing is specified.  */
 #define ASM_SIZE_DIRECTIVE(name)	/* Nothing is specified.  */
 
+#define PLTJMP(_x)	_x
+
 #endif
 
 /* APCS-32 doesn't preserve the condition codes across function call. */
@@ -56,13 +60,10 @@
 	instr##s	regs
 #endif
 
-/* Don't do floating point */
-#define __ARM_USES_FP   1
-
 /* Define an entry point visible from C.  */
 #define	ENTRY(name)							      \
   ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name);				      \
-  ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function)			      \
+  ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),function)			      \
   .align ALIGNARG(4);							      \
   C_LABEL(name)								      \
   CALL_MCOUNT