1 /* -----------------------------------------------------------------------------
2 * $Id: LinkerBasic.c,v 1.2 2001/02/12 13:03:17 sewardj Exp $
4 * (c) The GHC Team, 2000
8 * ---------------------------------------------------------------------------*/
12 #include "StoragePriv.h"
13 #include "LinkerInternals.h"
15 /* List of currently loaded objects */
16 ObjectCode *objects = NULL; /* initially empty */
18 /* -----------------------------------------------------------------------------
19 * Look up an address to discover whether it is in text or data space.
21 * Used by the garbage collector when walking the stack.
22 * -------------------------------------------------------------------------- */
24 static __inline__ SectionKind
25 lookupSection ( void* addr )
30 for ( oc = objects; oc; oc = oc->next ) {
31 for (i = 0; i < oc->n_sections; i++) {
32 if (oc->sections[i].start <= addr
33 && addr <= oc->sections[i].end)
34 return oc->sections[i].kind;
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);