Xref: utzoo comp.sys.ibm.pc:10603 comp.sys.mac:10996 comp.sys.atari.st:6945 Path: utzoo!mnetor!uunet!husc6!bbn!uwmcsd1!ig!jade!violet.berkeley.edu!edmoy From: edmoy@violet.berkeley.edu Newsgroups: comp.sys.ibm.pc,comp.sys.mac,comp.sys.atari.st Subject: Re: LSC, function pointers, and segments Message-ID: <6529@jade.BERKELEY.EDU> Date: 11 Jan 88 19:12:43 GMT References: <782@daisy.UUCP> <22358@ucbvax.BERKELEY.EDU> <8217@prls.UUCP> Sender: usenet@jade.BERKELEY.EDU Reply-To: edmoy@violet.berkeley.edu () Organization: University of California, Berkeley Lines: 26 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