Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ execseg(S) — Xenix 2.3.4g

Media Vault

Software Library

Restoration Projects

Artifacts Sought



     EXECSEG(S)               XENIX System V                EXECSEG(S)



     Name
          execseg - Makes a data region executable.

     Syntax
          #include <xdata.h>

          excode_t execseg(oldaddr, size)
          exdata_t oldaddr;
          unsigned size;

          int unexecseg(addr)
          excode_t addr;

     Description
          execseg(S) is passed the current data address and size of
          the region to be executed and it returns the starting
          address of a region that is at least size number of bytes
          which can safely be branched to.  On the Intel 8086 and
          80286, processor an alias CS descriptor is associated with
          the same memory as the data segment in which the oldaddr
          region lies. This means that offsets in the executable
          segment to access a given byte are essentially the same as
          the offsets in the original data segment, except the
          selector is different.

          Note that ``excode_t'' and ``exdata_t'' are `far' pointers
          on the 8086 and 80286.  On an architecture where pages in
          the same `segment' are any combination of
          read/write/execute, the returned address is identical to the
          parameter passed to execseg(S).

          We recommend that programs using this function on 8086- and
          80286-based processors be large model, or that programmers
          be very familiar with ``hybrid model'' as well as with the
          use and misuse of far data.

          When an error occurs, execseg(S) returns ((excode_t)-1),
          with errno set to ENONEM.  Errors include an invalid data
          address or size, and an inability to allocate a new data
          selector.

          The unexecseg() system call disables an addr previously
          returned from execseg(S) from being used as an executable
          region.  Specifically, on the 8086 and 80286 architectures,
          this call frees the selector used for the executable region.
          It returns 0 on success, or a -1 on error. For example, if
          addr is not an address returned by execseg(S), then a -1 is
          returned and it cn be used as an executable region.







     Page 1                                           (printed 8/7/87)





     EXECSEG(S)               XENIX System V                EXECSEG(S)



          Example:


              excode_t funcp; char far *datap;
                 .
                 .
                 .
              datap=brkctl(BR_NEWSEG,1000L,0L);
              load_with_code(datap,1000)        /*loads executable code into
                                         data region datap*/
              funcp=execseg(datap,1000); (*funcp)()
              /*call subroutine*/ if (unexecseg (funcp)==-1){
               printf("unexecseg failed\n"); exit(1); }

     Notes
          On the Intel 8086 and 80286 architectures, execseg(S)
          expects far addresses to be passed.  Only experienced
          programmers should use this feature.

          Since the execseg return value and address arguments are
          `far' pointers, any program including xdata.h must be
          compiled using the -Me option.

          The following restrictions apply to the execute data system
          call.  Even though an address and size are passed to
          execseg, the entire segment containing the requested
          addresses are aliased.  The address and size are validated
          before the aliasing is allowed.  No part of the data segment
          that is aliased may be deallocated (via sbrk(S) or
          brkctl(S)) while it is aliased.  This restriction applies to
          the entire segment that is aliased, even if only a small
          piece of the segment was aliased.  After unexecseging the
          aliased segment, the data segment may be deallocated.  Each
          call to execseg results in a new alias segment being used,
          even if the data segment is already aliased.

          Due to compiler confusion, you may get the message ``at
          least one void operand'' when using execseg.  Please ignore
          it.
















     Page 2                                           (printed 8/7/87)



Typewritten Software • bear@typewritten.org • Edmonds, WA 98026