diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2013-01-23 19:01:45 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2013-01-23 19:01:45 +0000 |
commit | c81801b09463606eb08e2aa96ad551e3324b4563 (patch) | |
tree | 8e24788800c999c6c776f0893180e3826b8e850d /libexec | |
parent | 403c20c9211ba816eb39bfdb80993ec355f48030 (diff) |
Cache flush .plt after updating its pointers to .got during the initial
object relocation, if loaded at a different address than the one it was
compiled for; unsurprisingly fixes some spurious crashes.
Diffstat (limited to 'libexec')
-rw-r--r-- | libexec/ld.so/m88k/ldasm.S | 20 | ||||
-rw-r--r-- | libexec/ld.so/m88k/rtld_machine.c | 7 | ||||
-rw-r--r-- | libexec/ld.so/m88k/syscall.h | 4 | ||||
-rw-r--r-- | libexec/ld.so/util.c | 4 |
4 files changed, 22 insertions, 13 deletions
diff --git a/libexec/ld.so/m88k/ldasm.S b/libexec/ld.so/m88k/ldasm.S index 8f9689556bd..6782e75ca43 100644 --- a/libexec/ld.so/m88k/ldasm.S +++ b/libexec/ld.so/m88k/ldasm.S @@ -1,4 +1,4 @@ -/* $OpenBSD: ldasm.S,v 1.2 2013/01/21 17:52:27 miod Exp $ */ +/* $OpenBSD: ldasm.S,v 1.3 2013/01/23 19:01:44 miod Exp $ */ /* * Copyright (c) 2013 Miodrag Vallat. @@ -186,10 +186,6 @@ DL_SYSCALL(open) DL_SYSCALL(read) jmp %r1 -_dl_cerror: - jmp.n %r1 - subu %r2, %r0, 1 - DL_SYSCALL(write) jmp %r1 @@ -216,11 +212,21 @@ ENTRY(_dl_sigprocmask) ld %r3, %r3, 0 2: or %r13, %r0, SYS_sigprocmask - tb0 0, %r0, 128 + tb0 0, %r0, 450 br _dl_cerror bcnd eq0, %r4, 3f st %r2, %r4, 0 3: jmp.n %r1 or %r2, %r0, 0 -END(sigprocmask) +END(_dl_sigprocmask) + +_dl_cerror: + jmp.n %r1 + subu %r2, %r0, 1 + +ENTRY(_dl_cacheflush) + tb0 0, %r0, 451 + br _dl_cerror | never hit + jmp %r1 +END(_dl_cacheflush) diff --git a/libexec/ld.so/m88k/rtld_machine.c b/libexec/ld.so/m88k/rtld_machine.c index 39be98b6c48..6a386324a9d 100644 --- a/libexec/ld.so/m88k/rtld_machine.c +++ b/libexec/ld.so/m88k/rtld_machine.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtld_machine.c,v 1.2 2013/01/21 17:52:27 miod Exp $ */ +/* $OpenBSD: rtld_machine.c,v 1.3 2013/01/23 19:01:44 miod Exp $ */ /* * Copyright (c) 2013 Miodrag Vallat. @@ -317,9 +317,10 @@ _dl_md_reloc_got(elf_object_t *object, int lazy) *addr + object->obj_base); } /* - * XXX We ought to invalidate I$ on the whole - * XXX plt here. + * Force a cache sync on the whole plt here, + * otherwise I$ might have stale information. */ + _dl_cacheflush(object->plt_start, object->plt_size); } } diff --git a/libexec/ld.so/m88k/syscall.h b/libexec/ld.so/m88k/syscall.h index cd82f08f478..dade9bbf74a 100644 --- a/libexec/ld.so/m88k/syscall.h +++ b/libexec/ld.so/m88k/syscall.h @@ -1,4 +1,4 @@ -/* $OpenBSD: syscall.h,v 1.1 2013/01/20 23:01:44 miod Exp $ */ +/* $OpenBSD: syscall.h,v 1.2 2013/01/23 19:01:44 miod Exp $ */ /* * Copyright (c) 2001 Niklas Hallqvist @@ -68,4 +68,6 @@ _dl_mmap(void *addr, unsigned int len, unsigned int prot, flags, fd, 0, offset)); } +int _dl_cacheflush(unsigned long, size_t); + #endif /*__DL_SYSCALL_H__*/ diff --git a/libexec/ld.so/util.c b/libexec/ld.so/util.c index ed25696d3a8..1c74814134c 100644 --- a/libexec/ld.so/util.c +++ b/libexec/ld.so/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.24 2012/08/28 16:39:09 matthew Exp $ */ +/* $OpenBSD: util.c,v 1.25 2013/01/23 19:01:44 miod Exp $ */ /* * Copyright (c) 1998 Per Fogelstrom, Opsycon AB @@ -74,7 +74,7 @@ _dl_strdup(const char *orig) * because we only free memory when 'dlclose()' is called and we can * reuse at least the memory allocated for the object descriptor. We have * one dynamic string allocated, the library name and it is likely that - * we can reuse that one to without a lot of complex colapsing code. + * we can reuse that one too without a lot of complex collapsing code. */ void * _dl_malloc(size_t need) |