summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpho@cielonegro.org <unknown>2010-11-30 12:14:25 +0000
committerpho@cielonegro.org <unknown>2010-11-30 12:14:25 +0000
commit819909d2bc253ed1630880f82276176432b17803 (patch)
tree91ee2de91ba23e70b526660331e253cad70320b4
parent7217f562ed08b7ef8a702065d437f7b6366aea88 (diff)
downloadhaskell-819909d2bc253ed1630880f82276176432b17803.tar.gz
rts/Linker.c (ocFlushInstructionCache):
I found this function causes a segfault when ocAllocateSymbolExtras() has allocated a separate memory region for jump islands.
-rw-r--r--rts/Linker.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/rts/Linker.c b/rts/Linker.c
index c92ede50eb..5f8ce13ea3 100644
--- a/rts/Linker.c
+++ b/rts/Linker.c
@@ -2393,13 +2393,12 @@ static SymbolExtra* makeSymbolExtra( ObjectCode* oc,
Because the PPC has split data/instruction caches, we have to
do that whenever we modify code at runtime.
*/
-
-static void ocFlushInstructionCache( ObjectCode *oc )
+static void ocFlushInstructionCacheFrom(void* begin, size_t length)
{
- int n = (oc->fileSize + sizeof( SymbolExtra ) * oc->n_symbol_extras + 3) / 4;
- unsigned long *p = (unsigned long *) oc->image;
+ size_t n = (length + 3) / 4;
+ unsigned long* p = begin;
- while( n-- )
+ while (n--)
{
__asm__ volatile ( "dcbf 0,%0\n\t"
"sync\n\t"
@@ -2413,6 +2412,14 @@ static void ocFlushInstructionCache( ObjectCode *oc )
"isync"
);
}
+static void ocFlushInstructionCache( ObjectCode *oc )
+{
+ /* The main object code */
+ ocFlushInstructionCacheFrom(oc->image + oc->misalignment, oc->fileSize);
+
+ /* Jump Islands */
+ ocFlushInstructionCacheFrom(oc->symbol_extras, sizeof(SymbolExtra) * oc->n_symbol_extras);
+}
#endif
/* --------------------------------------------------------------------------