summaryrefslogtreecommitdiffstats
path: root/libexec/rtld-elf/ia64
diff options
context:
space:
mode:
authorkan <kan@FreeBSD.org>2003-05-29 22:58:26 +0000
committerkan <kan@FreeBSD.org>2003-05-29 22:58:26 +0000
commit949c40c5fd683b40f39ebfa2783d06b8226148ab (patch)
treeb9989a6b77c2c503eafdb3cf6bf13370f5c6396b /libexec/rtld-elf/ia64
parentb292a2679ee1e9385409c38e0e898f0c2f4cb41c (diff)
downloadFreeBSD-src-949c40c5fd683b40f39ebfa2783d06b8226148ab.zip
FreeBSD-src-949c40c5fd683b40f39ebfa2783d06b8226148ab.tar.gz
Allow threading libraries to register their own locking
implementation in case default one provided by rtld is not suitable. Consolidate various identical MD lock implementation into a single file using appropriate machine/atomic.h. Approved by: re (scottl)
Diffstat (limited to 'libexec/rtld-elf/ia64')
-rw-r--r--libexec/rtld-elf/ia64/reloc.c14
-rw-r--r--libexec/rtld-elf/ia64/rtld_machdep.h11
-rw-r--r--libexec/rtld-elf/ia64/rtld_start.S96
3 files changed, 33 insertions, 88 deletions
diff --git a/libexec/rtld-elf/ia64/reloc.c b/libexec/rtld-elf/ia64/reloc.c
index 7db2823..0c62a87 100644
--- a/libexec/rtld-elf/ia64/reloc.c
+++ b/libexec/rtld-elf/ia64/reloc.c
@@ -122,8 +122,8 @@ alloc_fptrs(Obj_Entry *obj, bool mapped)
}
/*
- * This assertion is necessary to guarantee function pointer
- * uniqueness
+ * This assertion is necessary to guarantee function pointer
+ * uniqueness
*/
assert(fptrs != NULL);
@@ -136,12 +136,12 @@ free_fptrs(Obj_Entry *obj, bool mapped)
struct fptr **fptrs;
size_t fbytes;
- fptrs = obj->priv;
+ fptrs = obj->priv;
if (fptrs == NULL)
return;
fbytes = obj->nchains * sizeof(struct fptr *);
- if (mapped)
+ if (mapped)
munmap(fptrs, fbytes);
else
free(fptrs);
@@ -186,7 +186,7 @@ reloc_non_plt_obj(Obj_Entry *obj_rtld, Obj_Entry *obj, const Elf_Rela *rela,
/*
* We have to make sure that all @fptr references to
* the same function are identical so that code can
- * compare function pointers.
+ * compare function pointers.
*/
const Elf_Sym *def;
const Obj_Entry *defobj;
@@ -313,8 +313,8 @@ done:
if (cache)
munmap(cache, bytes);
- /*
- * Release temporarily mapped fptrs if relocating
+ /*
+ * Release temporarily mapped fptrs if relocating
* rtld object itself. A new table will be created
* in make_function_pointer using malloc when needed.
*/
diff --git a/libexec/rtld-elf/ia64/rtld_machdep.h b/libexec/rtld-elf/ia64/rtld_machdep.h
index a0ea72f..bf1261e 100644
--- a/libexec/rtld-elf/ia64/rtld_machdep.h
+++ b/libexec/rtld-elf/ia64/rtld_machdep.h
@@ -29,6 +29,11 @@
#ifndef RTLD_MACHDEP_H
#define RTLD_MACHDEP_H 1
+#include <sys/types.h>
+#include <machine/atomic.h>
+
+#define CACHE_LINE_SIZE 128
+
/*
* Macros for cracking ia64 function pointers.
*/
@@ -50,10 +55,4 @@ Elf_Addr reloc_jmpslot(Elf_Addr *, Elf_Addr, const struct Struct_Obj_Entry *,
void *make_function_pointer(const Elf_Sym *, const struct Struct_Obj_Entry *);
void call_initfini_pointer(const struct Struct_Obj_Entry *, Elf_Addr);
-/* Atomic operations. */
-int cmp0_and_store_int(volatile int *, int);
-void atomic_add_int(volatile int *, int);
-void atomic_incr_int(volatile int *);
-void atomic_decr_int(volatile int *);
-
#endif
diff --git a/libexec/rtld-elf/ia64/rtld_start.S b/libexec/rtld-elf/ia64/rtld_start.S
index b4408c6..1585207 100644
--- a/libexec/rtld-elf/ia64/rtld_start.S
+++ b/libexec/rtld-elf/ia64/rtld_start.S
@@ -50,7 +50,7 @@ ENTRY(_rtld_start, 0)
;;
sub out0=r14,r15 // out0 is image base address
br.call.sptk.many rp=_rtld_reloc // fixup image
-
+
add sp=-16,sp // 16 bytes for us, 16 for _rtld
;;
mov out0=in0
@@ -60,7 +60,7 @@ ENTRY(_rtld_start, 0)
br.call.sptk.many rp=_rtld // r8=_rtld(sp, &exit_proc, &obj_main)
add r16=16,sp // address for exit proc
- ;;
+ ;;
ld8 r15=[r16] // read exit proc
add sp=16,sp // readjust stack
mov b7=r8 // address of real _start
@@ -106,12 +106,12 @@ ENTRY(_rtld_bind_start, 0)
stf.spill [r17]=f10,32
stf.spill [r18]=f11,32
mov out0=r16 // Obj_Entry for caller
- ;;
+ ;;
} { .mmi
stf.spill [r17]=f12,32
stf.spill [r18]=f13,32
shladd out1=r15,3,out1 // rela offset = 24 * index
- ;;
+ ;;
} { .mmb
stf.spill [r17]=f14,32
stf.spill [r18]=f15,32
@@ -125,21 +125,21 @@ ENTRY(_rtld_bind_start, 0)
ld8 r1=[r8] // target gp
mov ar.pfs=loc0 // clean up
mov rp=loc1
-} { .mmi
+} { .mmi
ldf.fill f8=[r17],32 // restore float arguments
ldf.fill f9=[r18],32
mov r8=loc2 // restore structure pointer
- ;;
+ ;;
} { .mmi
ldf.fill f10=[r17],32
ldf.fill f11=[r18],32
mov r9=loc3
- ;;
+ ;;
} { .mmi
ldf.fill f12=[r17],32
ldf.fill f13=[r18],32
mov r10=loc4
- ;;
+ ;;
} { .mmi
ldf.fill f14=[r17],32
ldf.fill f15=[r18],32
@@ -157,69 +157,15 @@ ENTRY(_rtld_bind_start, 0)
}
END(_rtld_bind_start)
-/*
- * int cmp0_and_store_int(volatile int *p, int newval);
- *
- * If an int holds 0, store newval into it; else do nothing. Returns
- * the previous value.
- */
-ENTRY(cmp0_and_store_int, 2)
- mov ar.ccv=0
- ;;
- cmpxchg4.acq r8=[in0],in1,ar.ccv
- br.ret.sptk.many rp
-END(cmp0_and_store_int)
-
-ENTRY(atomic_add_int, 2)
-1: ld4 r14=[in0]
- ;;
- mov ar.ccv=r14
- add r15=in1,r14
- ;;
- cmpxchg4.acq r16=[in0],r15,ar.ccv
- ;;
- cmp.ne p6,p0=r14,r16
-(p6) br.cond.spnt.few 1b
- br.ret.sptk.many rp
-END(atomic_add_int)
-
-/* Atomically increment an int. */
-ENTRY(atomic_incr_int, 1)
-1: ld4 r14=[in0]
- ;;
- mov ar.ccv=r14
- add r15=1,r14
- ;;
- cmpxchg4.acq r16=[in0],r15,ar.ccv
- ;;
- cmp.ne p6,p0=r14,r16
-(p6) br.cond.spnt.few 1b
- br.ret.sptk.many rp
-END(atomic_incr_int)
-
-/* Atomically decrement an int. */
-ENTRY(atomic_decr_int, 1)
-1: ld4 r14=[in0]
- ;;
- mov ar.ccv=r14
- add r15=-1,r14
- ;;
- cmpxchg4.acq r16=[in0],r15,ar.ccv
- ;;
- cmp.ne p6,p0=r14,r16
-(p6) br.cond.spnt.few 1b
- br.ret.sptk.many rp
-END(atomic_decr_int)
-
#define DT_NULL 0 /* Terminating entry. */
#define DT_RELA 7 /* Address of ElfNN_Rela relocations. */
#define DT_RELASZ 8 /* Total size of ElfNN_Rela relocations. */
#define DT_RELAENT 9 /* Size of each ElfNN_Rela relocation entry. */
-
+
#define R_IA64_NONE 0 /* None */
#define R_IA64_DIR64LSB 0x27 /* word64 LSB S + A */
#define R_IA64_REL64LSB 0x6f /* word64 LSB BD + A */
-
+
/*
* _rtld_reloc: relocate the rtld image, apart from @fptrs.
*
@@ -233,7 +179,7 @@ END(atomic_decr_int)
STATIC_ENTRY(_rtld_reloc, 1)
alloc loc0=ar.pfs,1,2,0,0
mov loc1=rp
- ;;
+ ;;
movl r15=@gprel(_DYNAMIC) // find _DYNAMIC etc.
;;
add r15=r15,gp // relocate _DYNAMIC etc.
@@ -244,24 +190,24 @@ STATIC_ENTRY(_rtld_reloc, 1)
;;
cmp.eq p6,p0=DT_NULL,r16 // done?
(p6) br.cond.dpnt.few 2f
- ;;
+ ;;
cmp.eq p6,p0=DT_RELA,r16
- ;;
+ ;;
(p6) add r18=r17,in0 // found rela section
- ;;
+ ;;
cmp.eq p6,p0=DT_RELASZ,r16
- ;;
+ ;;
(p6) mov r19=r17 // found rela size
- ;;
+ ;;
cmp.eq p6,p0=DT_RELAENT,r16
- ;;
+ ;;
(p6) mov r22=r17 // found rela entry size
;;
br.sptk.few 1b
-
-2:
+
+2:
ld8 r15=[r18],8 // read r_offset
- ;;
+ ;;
ld8 r16=[r18],8 // read r_info
add r15=r15,in0 // relocate r_offset
;;
@@ -284,7 +230,7 @@ STATIC_ENTRY(_rtld_reloc, 1)
3: cmp.ltu p6,p0=0,r19 // more?
(p6) br.cond.dptk.few 2b // loop
-
+
mov r8=0 // success return value
;;
br.cond.sptk.few 9f // done
OpenPOWER on IntegriCloud