1 /* -----------------------------------------------------------------------------
2 * $Id: LinkerBasic.c,v 1.6 2002/11/21 10:04:21 simonmar Exp $
4 * (c) The GHC Team, 2000
8 * ---------------------------------------------------------------------------*/
10 #include "PosixSource.h"
13 #include "StoragePriv.h"
14 #include "LinkerInternals.h"
16 /* List of currently loaded objects */
17 ObjectCode *objects = NULL; /* initially empty */
19 /* -----------------------------------------------------------------------------
20 * Look up an address to discover whether it is in text or data space.
22 * Used by the garbage collector when walking the stack.
23 * -------------------------------------------------------------------------- */
25 static __inline__ SectionKind
26 lookupSection ( void* addr )
31 for (oc=objects; oc; oc=oc->next) {
32 for (se=oc->sections; se; se=se->next) {
33 if (se->start <= addr && addr <= se->end)
37 return SECTIONKIND_OTHER;
41 is_dynamically_loaded_code_or_rodata_ptr ( void* p )
43 SectionKind sk = lookupSection(p);
44 ASSERT (sk != SECTIONKIND_NOINFOAVAIL);
45 return (sk == SECTIONKIND_CODE_OR_RODATA);
50 is_dynamically_loaded_rwdata_ptr ( void* p )
52 SectionKind sk = lookupSection(p);
53 ASSERT (sk != SECTIONKIND_NOINFOAVAIL);
54 return (sk == SECTIONKIND_RWDATA);
59 is_not_dynamically_loaded_ptr ( void* p )
61 SectionKind sk = lookupSection(p);
62 ASSERT (sk != SECTIONKIND_NOINFOAVAIL);
63 return (sk == SECTIONKIND_OTHER);