[net.unix] Creating functions in data space

law@petsd.UUCP (Steve Law) (03/10/86)

> In response to George Tomasevich:
> 
I had missed that one.

> This seems to me to be very machine dependent, even compiler
> dependent. I'm sure that the compiler, in any event, would spit all
> kinds of warnings at you. Perhaps a way around it would be to gain
> access somehow to the memory management register, have a function that
> flips a bit just before calling the data code, and cleans up afterwards.
> Perhaps the problem is that C allows you to have identically named
> functions and variables, but you could get around that as well.
> 
UNIX System V link editor (ld) allows one to put functions in the .data
section of a COFF file.  All you need to do is to create a ld command
file (also called ifile).  For example, the following ifile:

     SECTIONS {
     	 .data: {
     		file1.o (.text)   /* file1.c, file2.c file3.c contain */
     	        file2.o (.text)   /* the functions text that to be    */
     	        file3.o (.text)   /* placed in the .data section of   */
     	        ...               /* the final a.out                  */
     	        }
     	 }

and the following command lines:

     cc -c file1.c file2.c file3.c
     cc -N otherfiles.c ifile

will create an a.out which will have all the functions of file[123].c in
the .data section instead of .text section.  One can also use ifile(s) to
do the following:

     - place data in .text
     - create dummy sections (e.g., store history info)
     - create holes within sections
     - align sections
     - merge sections
     - subsystem linking

and many others.  It is a very powerful tool, but some of its features
are not well documented!!!

				Steve Law

--*-------*-------*-------*-------*-------*-------*--
Name:       I. S. Law (Steve)
UUCP:       ihnp4!vax135!petsd!law
ARPA:	    vax135!petsd!law@BERKELEY
US Mail:    MS 314B; Concurrent Computer Corp.
            106 Apple St; Tinton Falls, NJ 07724
Phone:      (201) 758-7280
--*-------*-------*-------*-------*-------*-------*--

lasse@daab.UUCP (Lars Hammarstrand) (03/18/86)

In article <728@petsd.UUCP> law@petsd.UUCP writes:
>> In response to George Tomasevich:
>> 
>> 
>UNIX System V link editor (ld) allows one to put functions in the .data
 etc, etc .....
>
>     - place data in .text
>     - create dummy sections (e.g., store history info)
>     - create holes within sections
>     - align sections
>     - merge sections
>     - subsystem linking
>
>and many others.  It is a very powerful tool, but some of its features
>are not well documented!!!
>

GOOD, but now the rest of the world wonder where you can read more about it!!??


	Lars Hammarstrand.

law@pecnos.UUCP (Steve Law) (03/21/86)

In article <200@daab.UUCP> Lars Hammarstrand writes:

> In article <728@petsd.UUCP> law@petsd.UUCP writes:
> >>UNIX System V link editor (ld) allows one to put functions in the .data
> etc, etc .....
> 
> GOOD, but now the rest of the world wonder where you can read more about it!!??

COFF and COFF-based link editor (ld) are being used in both UNIX and UNIX/RTR
systems. Most of the COFF and ld features (e.g., ifile) can be found in the
COFF section and the LINK EDITOR section of

       UNIX System V Release 2.0 Support Tool Guide

This document can be purphased from AT&T.  Since UNIX/RTR exercises more
features of COFF and ld than UNIX, additional features them can be found
in one of the UNIX/RTR user's manuals.  I don't know the exact volume
number.  They used to be in volume 3 of the old user's manuals.

					Steve Law

gwyn@brl-smoke.ARPA (Doug Gwyn ) (03/23/86)

In article <200@daab.UUCP> lasse@unix.UUCP (Lars Hammarstrand) writes:
>In article <728@petsd.UUCP> law@petsd.UUCP writes:
>>> In response to George Tomasevich:
>>UNIX System V link editor (ld) allows one to put functions in the .data
> etc, etc .....
>>     - place data in .text
>>     - create dummy sections (e.g., store history info)
>>     - create holes within sections
>>     - align sections
>>     - merge sections
>>     - subsystem linking
>>and many others.  It is a very powerful tool, but some of its features
>>are not well documented!!!
>GOOD, but now the rest of the world wonder where you can read more about it!!??

Check out the "Link Editor" section of AT&T's UNIX System V
Support Tools Guide, select number 307-108.  The "COFF"
section of the same Guide is also relevant.