jonathan@COMP.VUW.AC.NZ (12/18/89)
Test0 fails to run on machines that do not allow the data segment to
be executed (for example, Pyramids running OSx 4.n).
The following diff fixes this problem on a Pyramid.
*** test.hello.cc.DIST Thu Nov 9 00:28:31 1989
--- test.hello.cc Mon Dec 18 13:18:39 1989
***************
*** 20,25 ****
--- 20,35 ----
#endif
+ #ifdef __pyr__
+ #define MUST_MPROTECT
+ #include <sys/mman.h>
+
+ extern "C" {
+ int
+ mprotect (char *, int, int);
+ }
+ #endif
+
class tfile
{
public:
***************
*** 101,106 ****
--- 111,128 ----
read (fd, (char*) init_fn, size);
close (fd);
+
+ #ifdef MUST_MPROTECT
+ {
+ void * rounded_size = (void *) ((size + pagsiz-1)&~(pagsiz-1));
+ int status = mprotect ((char*)init_fn, round_size,
+ PROT_READ|PROT_EXEC|PROT_WRITE);
+ if (status !=0 ) {
+ perror ("making dynamically loaded code executable");
+ exit(errno);
+ }
+ }
+ #endif /* MUST_MPROTECT */
fprintf (stderr, "load symbol-table at address 0x%x\n", init_fn);