gardner@prls.UUCP (Robert Gardner) (01/05/88)
I started working on segmenting a large program that uses function pointers rather extensively and got worried about assigning a function pointer in one segment, unloading that segment, and having it accessed later from another segment. Is the function pointer still valid? Interestingly, when I step through the code with TMON I noticed that when the function pointer is used it is called via JSR (A0), as expected, but the next function called is something like JMP xx(A5), which is usually the type of call you see in the jump table for a loaded segment, which is replaced by _LoadSeg if the segment is unloaded. (I haven't yet had time to see what it says when the segment is unloaded.) So, it appears that the function pointer should still be valid, even if the segment containing the function gets unloaded. I would like to know if this is true, even for static functions, and if so, what kind of magic makes it possible. Thank you, Robert Gardner
gardner@prls.UUCP (Robert Gardner) (01/05/88)
Sorry about that posting. Forgot to edit the newsgroups line. Robert Gardner
edmoy@violet.berkeley.edu (01/12/88)
In article <8217@prls.UUCP> gardner@prls.UUCP (Robert Gardner) writes: >I started working on segmenting a large program that uses function pointers >rather extensively and got worried about assigning a function pointer >in one segment, unloading that segment, and having it accessed later from >another segment. Is the function pointer still valid? > >Interestingly, when I step through the code with TMON I noticed that when >the function pointer is used it is called via JSR (A0), as expected, >but the next function called is something like JMP xx(A5), which is usually >the type of call you see in the jump table for a loaded segment, which >is replaced by _LoadSeg if the segment is unloaded. (I haven't yet had time >to see what it says when the segment is unloaded.) A compiler can, under normal circumstances always use the jump table address to reference the function. A smart compiler/linker could optimize some of these into direct addresses, if the calling function is in the same segment as the called function (and thus the segament is guaranteed to be loaded already). Edward Moy Workstation Software Support University of California Berkeley, CA 94720 edmoy@violet.Berkeley.EDU ucbvax!violet!edmoy