1 /* -----------------------------------------------------------------------------
2 * $Id: LinkerBasic.c,v 1.3 2001/08/14 13:40:09 sewardj 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 (i = 0; i < oc->n_sections; i++) {
33 if (oc->sections[i].start <= addr
34 && addr <= oc->sections[i].end)
35 return oc->sections[i].kind;
38 return SECTIONKIND_OTHER;
42 is_dynamically_loaded_code_or_rodata_ptr ( void* p )
44 SectionKind sk = lookupSection(p);
45 ASSERT (sk != SECTIONKIND_NOINFOAVAIL);
46 return (sk == SECTIONKIND_CODE_OR_RODATA);
51 is_dynamically_loaded_rwdata_ptr ( void* p )
53 SectionKind sk = lookupSection(p);
54 ASSERT (sk != SECTIONKIND_NOINFOAVAIL);
55 return (sk == SECTIONKIND_RWDATA);
60 is_not_dynamically_loaded_ptr ( void* p )
62 SectionKind sk = lookupSection(p);
63 ASSERT (sk != SECTIONKIND_NOINFOAVAIL);
64 return (sk == SECTIONKIND_OTHER);