[comp.sys.nsc.32k] Bug in SysV ld?

idall@augean.OZ (Ian Dall) (08/04/87)

I've been trying to build GNU emacs (version 17) on my ICM 3216 (SysV). I can't
get unexec to work and the reason seems to be that there is a hole in the
virtual address space of executables produced by ld.

The hole is between the .text and .data segments. Its size varies depending
on the size of .text (presumably) but it is NOT just the gap to the next
page boundary.

Is this a bug? Admittedly the wasted virtual address space would not normally
be a problem. Interestingly the .data segment doesn't start on a page boundary.

There is ld -N but that has the undesirable side effect of making the text
segment unsharable.
-- 
 Ian Dall           "In any argument there will be people on your
                     side who you wish were on the other side."
idall@augean.oz

joer@nscpdc.NSC.COM ( Joe Rawlings ) (08/13/87)

Edited for brevity sake:


In article <224@augean.OZ> idall@augean.OZ (Ian Dall) writes:
>I've been trying to build GNU emacs (version 17) on my ICM 3216 (SysV). I can't
>get unexec to work and the reason seems to be that there is a hole in the
>virtual address space of executables produced by ld.
>
>The hole is between the .text and .data segments. Its size varies depending
>on the size of .text (presumably) but it is NOT just the gap to the next
>page boundary.
>
>Is this a bug? Admittedly the wasted virtual address space would not normally
>be a problem. Interestingly the .data segment doesn't start on a page boundary.
>
>There is ld -N but that has the undesirable side effect of making the text
>segment unsharable.
>-- 

No, it is not a bug.  The text region is a read only region.  The data region
is a read/write region.  The kernel supports a region granularity of 64K.
When the file is on disk, the text and data regions are adjacent (no gap).

When a program is loaded, the text region is assigned enough pages to store 
all the text and will almost always contain a small portion of the data.

Likewise, the data region is assigned enough pages to store all the data 
and will almost always start off with a small amount of text.  UNIX (tm) 
knows where the actual data segment starts.  

As an example, assume a program that has equal sized text and data segments 
and occupies 5 pages.  When the program is loaded, the text segment will 
contain 3 pages, the last of which contains some data, and the data segment 
will contain 3 pages, the first of which will contain some text.  The middle 
page is duplicated, once in each region.

There is a gentleman who had the same problem you are having with version
17 last Februrary.  He has now sucessfully ported version 18 of Gnuemacs
to his ICM-3216 and has posted instructions and help files to the net on
this same group.  If you are interested and can obtain version 18, I can
email you his notes.  By the way, he solved the gap problem by filling
in "0"'s and adjusting address data and eof of text to a 64K boundry.

JR

-- 
/****************************************************************************** *                                                                             *
*  Joe Rawlings                         nsc!nscpdc!joer                       * *  ICM Product Support                  tektronix!reed!nscpdc!joer            *
*  National Semiconductor Corp.         1-800-222-2433 (outside Oregon)       * *  Portland Development Center          (503)-629-4414 (Oregon/World)         *
*                                                                             * ******************************************************************************/