1 /* -----------------------------------------------------------------------------
2 * $Id: LinkerBasic.c,v 1.1 2001/02/11 17:51:07 simonmar Exp $
4 * (c) The GHC Team, 2000
8 * ---------------------------------------------------------------------------*/
11 #include "StoragePriv.h"
12 #include "LinkerInternals.h"
14 /* List of currently loaded objects */
15 ObjectCode *objects = NULL; /* initially empty */
17 /* -----------------------------------------------------------------------------
18 * Look up an address to discover whether it is in text or data space.
20 * Used by the garbage collector when walking the stack.
21 * -------------------------------------------------------------------------- */
23 static __inline__ SectionKind
24 lookupSection ( void* addr )
29 for ( oc = objects; oc; oc = oc->next ) {
30 for (i = 0; i < oc->n_sections; i++) {
31 if (oc->sections[i].start <= addr
32 && addr <= oc->sections[i].end)
33 return oc->sections[i].kind;
36 return SECTIONKIND_OTHER;
40 is_dynamically_loaded_code_or_rodata_ptr ( void* p )
42 SectionKind sk = lookupSection(p);
43 ASSERT (sk != SECTIONKIND_NOINFOAVAIL);
44 return (sk == SECTIONKIND_CODE_OR_RODATA);
49 is_dynamically_loaded_rwdata_ptr ( void* p )
51 SectionKind sk = lookupSection(p);
52 ASSERT (sk != SECTIONKIND_NOINFOAVAIL);
53 return (sk == SECTIONKIND_RWDATA);
58 is_not_dynamically_loaded_ptr ( void* p )
60 SectionKind sk = lookupSection(p);
61 ASSERT (sk != SECTIONKIND_NOINFOAVAIL);
62 return (sk == SECTIONKIND_OTHER);