#include "LinkerInternals.h"
#include "RtsUtils.h"
#include "Schedule.h"
-#include "Storage.h"
#include "Sparks.h"
#include "RtsTypeable.h"
/* Hash table mapping symbol names to Symbol */
static /*Str*/HashTable *symhash;
-typedef struct {
- void *addr;
-} rootEntry;
-
/* Hash table mapping symbol names to StgStablePtr */
static /*Str*/HashTable *stablehash;
-rootEntry *root_ptr_table = NULL;
-static rootEntry *root_ptr_free = NULL;
-
-static unsigned int RPT_size = 0;
/* List of currently loaded objects */
ObjectCode *objects = NULL; /* initially empty */
#define RTS_USER_SIGNALS_SYMBOLS \
SymX(setIOManagerPipe)
#else
-#define RTS_USER_SIGNALS_SYMBOLS /* nothing */
+#define RTS_USER_SIGNALS_SYMBOLS \
+ SymX(sendIOManagerEvent) \
+ SymX(readIOManagerEvent) \
+ SymX(getIOManagerEvent) \
+ SymX(console_handler)
#endif
#ifdef TABLES_NEXT_TO_CODE
SymX(catchzh_fast) \
SymX(catchRetryzh_fast) \
SymX(catchSTMzh_fast) \
+ SymX(checkzh_fast) \
SymX(closure_flags) \
SymX(cmp_thread) \
SymX(cmpIntegerzh_fast) \
RTS_POSIX_ONLY_SYMBOLS
RTS_MINGW_ONLY_SYMBOLS
RTS_CYGWIN_ONLY_SYMBOLS
+ RTS_DARWIN_ONLY_SYMBOLS
RTS_LIBGCC_SYMBOLS
#if defined(darwin_HOST_OS) && defined(i386_HOST_ARCH)
// dyld stub code contains references to this,
};
-/* -----------------------------------------------------------------------------
- * Utilities for handling root pointers.
- * -------------------------------------------------------------------------- */
-
-
-#define INIT_RPT_SIZE 64
-
-STATIC_INLINE void
-initFreeList(rootEntry *table, nat n, rootEntry *free)
-{
- rootEntry *p;
-
- for (p = table + n - 1; p >= table; p--) {
- p->addr = (P_)free;
- free = p;
- }
- root_ptr_free = table;
-}
-
-static void
-initRootPtrTable(void)
-{
- if (RPT_size > 0)
- return;
-
- RPT_size = INIT_RPT_SIZE;
- root_ptr_table = stgMallocBytes(RPT_size * sizeof(rootEntry),
- "initRootPtrTable");
-
- initFreeList(root_ptr_table,INIT_RPT_SIZE,NULL);
-}
-
-
-static void
-enlargeRootPtrTable(void)
-{
- nat old_RPT_size = RPT_size;
-
- // 2nd and subsequent times
- RPT_size *= 2;
- root_ptr_table =
- stgReallocBytes(root_ptr_table,
- RPT_size * sizeof(rootEntry),
- "enlargeRootPtrTable");
-
- initFreeList(root_ptr_table + old_RPT_size, old_RPT_size, NULL);
-}
-
-static void
-addRootObject(void *addr)
-{
- StgWord rt;
- initRootPtrTable();
- if (root_ptr_free == NULL) {
- enlargeRootPtrTable();
- }
-
- rt = root_ptr_free - root_ptr_table;
- root_ptr_free = (rootEntry*)(root_ptr_free->addr);
- root_ptr_table[rt].addr = addr;
-}
-
-/* -----------------------------------------------------------------------------
- * Treat root pointers as roots for the garbage collector.
- * -------------------------------------------------------------------------- */
-
-void
-markRootPtrTable(evac_fn evac)
-{
- rootEntry *p, *end_root_ptr_table;
- StgPtr q;
-
- end_root_ptr_table = &root_ptr_table[RPT_size];
-
- for (p = root_ptr_table; p < end_root_ptr_table; p++) {
- q = p->addr;
-
- if (q && (q < (P_)root_ptr_table || q >= (P_)end_root_ptr_table)) {
- evac((StgClosure **)p->addr);
- }
- }
-}
-
-/* -----------------------------------------------------------------------------
- * End of utilities for handling root pointers.
- * -------------------------------------------------------------------------- */
/* -----------------------------------------------------------------------------
static void *dl_prog_handle;
#endif
-/* dlopen(NULL,..) doesn't work so we grab libc explicitly */
-#if defined(openbsd_HOST_OS)
-static void *dl_libc_handle;
-#endif
-
void
initLinker( void )
{
dl_prog_handle = RTLD_DEFAULT;
# else
dl_prog_handle = dlopen(NULL, RTLD_LAZY);
-# if defined(openbsd_HOST_OS)
- dl_libc_handle = dlopen("libc.so", RTLD_LAZY);
-# endif
# endif /* RTLD_DEFAULT */
# endif
}
if (val == NULL) {
# if defined(OBJFORMAT_ELF)
-# if defined(openbsd_HOST_OS)
- val = dlsym(dl_prog_handle, lbl);
- return (val != NULL) ? val : dlsym(dl_libc_handle,lbl);
-# elif defined(x86_64_HOST_ARCH)
+# if defined(x86_64_HOST_ARCH)
val = dlsym(dl_prog_handle, lbl);
if (val >= (void *)0x80000000) {
void *new_val;
} else {
return val;
}
-# else /* not openbsd */
+# else
return dlsym(dl_prog_handle, lbl);
# endif
# elif defined(OBJFORMAT_MACHO)
+ sym->Value);
} else {
copyName ( sym->Name, strtab, symbol, 1000-1 );
- (void*)S = lookupLocalSymbol( oc, symbol );
+ S = (UInt32) lookupLocalSymbol( oc, symbol );
if ((void*)S != NULL) goto foundit;
- (void*)S = lookupSymbol( symbol );
+ S = (UInt32) lookupSymbol( symbol );
if ((void*)S != NULL) goto foundit;
zapTrailingAtSign ( symbol );
- (void*)S = lookupLocalSymbol( oc, symbol );
+ S = (UInt32) lookupLocalSymbol( oc, symbol );
if ((void*)S != NULL) goto foundit;
- (void*)S = lookupSymbol( symbol );
+ S = (UInt32) lookupSymbol( symbol );
if ((void*)S != NULL) goto foundit;
/* Newline first because the interactive linker has printed "linking..." */
errorBelch("\n%s: unknown symbol `%s'", oc->fileName, symbol);
S = (Elf_Addr)S_tmp;
} else {
stableVal = deRefStablePtr( stablePtr );
- addRootObject((void*)P);
S_tmp = stableVal;
S = (Elf_Addr)S_tmp;
}