Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site ttrdc.UUCP Path: utzoo!watmath!clyde!cbosgd!ihnp4!ltuxa!ttrdc!levy From: levy@ttrdc.UUCP (Daniel R. Levy) Newsgroups: net.lang.c,net.unix-wizards,net.arch Subject: Re: (3b2) functions in data space Message-ID: <802@ttrdc.UUCP> Date: Mon, 17-Mar-86 22:32:29 EST Article-I.D.: ttrdc.802 Posted: Mon Mar 17 22:32:29 1986 Date-Received: Wed, 19-Mar-86 05:07:21 EST References: <728@petsd.UUCP> <1486@devwrl.DEC.COM> <622@bentley.UUCP> Organization: AT&T, Computer Systems Division, Skokie, IL Lines: 58 Xref: watmath net.lang.c:8184 net.unix-wizards:17259 net.arch:2855 In article <622@bentley.UUCP>, kwh@bentley.UUCP (KW Heuer) writes: >I've changed the cross-posting from net.unix to net.unix-wizards, as >this is no longer a neophyte question. >... >The person who started this discussion was already able to create code >in the .data space; whether it's done by the loader or at run-time by >the program is irrelevant. The question is whether it's possible to >_execute_ such a function. On a vax, you can. On a pdp11 with split >I/D, you can't, because .text and .data addresses are each 16 bits, >so an attempt to call a function from .data space will actually call >the function at the same address in .text space. (The workaround is >to use ld -N, so you don't have split I/D.) The remainder of this >discussion focuses on the 3b2, where .text and .data addresses have >separate ranges (.text normally starts at 0x80800000, .data at >0x80880000). >[more discussion, speculation] Well, it IS possible on the 3b2 and very simply. Not only is it possible to read text space but it is also possible to run data space. Here's a quickie program which works on the 3b2: main() { char arr[100]; /* needn't be nearly this big but what the heck */ void hello(); charcopy(hello,arr,100); printf("I've now copied text space to data space.\n"); run(arr); printf("I've now run data space.\n"); } void hello() { printf("Hello world\n"); } charcopy(a,b,c) char *a, *b; int c; { while (c--) *b++ = *a++; } run(stuff) char (*stuff)(); { (*stuff)(); } Now maybe some pundit out there can explain WHY this works :-). -- ------------------------------- Disclaimer: The views contained herein are | dan levy | yvel nad | my own and are not at all those of my em- | an engihacker @ | ployer or the administrator of any computer | at&t computer systems division | upon which I may hack. | skokie, illinois | -------------------------------- Path: ..!{akgua,homxb,ihnp4,ltuxa,mvuxa, vax135}!ttrdc!levy