[gnu.utils.bug] perprocess variable diffs to ld.c

ham@Neon.Stanford.EDU (Peter R. Ham) (09/14/89)

("New file: " "/xxV/cmds/gld/pgld/mi/a.out.h")
#ifndef __A_OUT_GNU_H__
#define __A_OUT_GNU_H__

#define __GNU_EXEC_MACROS__

#ifndef __STRUCT_EXEC_OVERRIDE__

#ifdef WITH_PERPROCESS_VARIABLES
struct exec
{
  unsigned long a_info;		/* Use macros N_MAGIC, etc for access */
  unsigned a_text;		/* length of text, in bytes */
  unsigned a_data;		/* length of data, in bytes */
  unsigned a_bss;		/* length of uninitialized data area for file, in bytes */
  unsigned a_perprocess;	/* length of perprocess, in bytes */
  unsigned a_perprocess_bss; 	/* length of uninitialized perprocess area for file, in bytes */
  unsigned a_syms;		/* length of symbol table data in file, in bytes */
  unsigned a_entry;		/* start address */
  unsigned a_trsize;		/* length of relocation info for text, in bytes */
  unsigned a_drsize;		/* length of relocation info for data, in bytes */
  unsigned a_prsize;		/* length of relocation info for perprocess, in bytes */
};

/*
** Macro definitions for V system compatibility.
*/
#define bhdr exec
#define tsize a_text
#define dsize a_data

#else
struct exec
{
  unsigned long a_info;		/* Use macros N_MAGIC, etc for access */
  unsigned a_text;		/* length of text, in bytes */
  unsigned a_data;		/* length of data, in bytes */
  unsigned a_bss;		/* length of uninitialized data area for file, in bytes */
  unsigned a_syms;		/* length of symbol table data in file, in bytes */
  unsigned a_entry;		/* start address */
  unsigned a_trsize;		/* length of relocation info for text, in bytes */
  unsigned a_drsize;		/* length of relocation info for data, in bytes */
};
#endif WITH_PERPROCESS_VARIABLES

#endif /* __STRUCT_EXEC_OVERRIDE__ */

/* these go in the N_MACHTYPE field */
enum machine_type {
  M_OLDSUN2 = 0,
  M_68010 = 1,
  M_68020 = 2,
  M_SPARC = 3,
  /* skip a bunch so we don't run into any of sun's numbers */
  M_386 = 100,
};

#define N_MAGIC(exec) ((exec).a_info)
#define N_MACHTYPE(exec) ((enum machine_type)(((exec).a_info >> 16) & 0xff))
#define N_FLAGS(exec) (((exec).a_info >> 24) & 0xff)
#define N_SET_INFO(exec, magic, type, flags) \
	((exec).a_info = ((magic) & 0xffff) \
	 | (((int)(type) & 0xff) << 16) \
	 | (((flags) & 0xff) << 24))
#if 0
/*
** This macro is not used by 
** the V system.
*/
#define N_SET_MAGIC(exec, magic) \
	((exec).a_info = (((exec).a_info & 0xffff0000) | ((magic) & 0xffff)))
#endif
#define N_SET_MAGIC(exec, magic) \
	((exec).a_info = (magic))

#define N_SET_MACHTYPE(exec, machtype) \
	((exec).a_info = \
	 ((exec).a_info&0xff00ffff) | ((((int)(machtype))&0xff) << 16))

#define N_SET_FLAGS(exec, flags) \
	((exec).a_info = \
	 ((exec).a_info&0x00ffffff) | (((flags) & 0xff) << 24))

/* Code indicating object file or impure executable.  */
#ifdef WITH_PERPROCESS_VARIABLES
#define PERPROCESS_SEGMENT_OBJECT_MAGIC 0420
#define OMAGIC PERPROCESS_SEGMENT_OBJECT_MAGIC 
#else
#define OMAGIC 0407
#endif WITH_PERPROCESS_VARIABLES

/* Code indicating pure executable.  */
#define NMAGIC 0410
/* Code indicating demand-paged executable.  */
/*
** This is different for the V system.
*/

#define PROC_FAM_68000		0	/* 68000 family */
#define PROC_FAM_VAX11		1	/* VAX family */
#define BuildMagic(format, family)  ((0x80|'V')<<24|((format)<<16)|(family))
#define DEMAND_PAGEABLE	42	/* Text and data aligned on 1k boundaries */
#define VMAGIC_M68K		BuildMagic(DEMAND_PAGEABLE,PROC_FAM_68000)
#define VMAGIC_VAX		BuildMagic(DEMAND_PAGEABLE,PROC_FAM_VAX11)

#ifdef WITH_PERPROCESS_VARIABLES
#define PERPROCESS_SEGMENT (64|DEMAND_PAGEABLE)
				/* Additional "perprocess" segment */ 

#define VPERPROCESS_MAGIC_VAX	BuildMagic(PERPROCESS_SEGMENT,PROC_FAM_VAX11)
#define VPERPROCESS_MAGIC_M68K	BuildMagic(PERPROCESS_SEGMENT,PROC_FAM_68000)
#define VPERPROCESS_MAGIC_PMAX	BuildMagic(PERPROCESS_SEGMENT,PROC_FAM_MIPSCO)

#ifdef m68k
#define ZMAGIC VPERPROCESS_MAGIC_M68K
#endif

#ifdef VAX
#define ZMAGIC VPERPROCESS_MAGIC_VAX
#endif

#else WITH_PERPROCESS_VARIABLES
#ifdef m68k
#define ZMAGIC VMAGIC_M68K
#endif

#ifdef VAX
#define ZMAGIC VMAGIC_VAX
#endif
#endif WITH_PERPROCESS_VARIABLES

#define N_BADMAG(x)					\
 (N_MAGIC(x) != OMAGIC && N_MAGIC(x) != NMAGIC		\
  && N_MAGIC(x) != ZMAGIC)

#define _N_BADMAG(x)					\
 (N_MAGIC(x) != OMAGIC && N_MAGIC(x) != NMAGIC		\
  && N_MAGIC(x) != ZMAGIC)

#define _N_HDROFF(x) (SEGMENT_SIZE - sizeof (struct exec))

#define N_TXTOFF(x) \
 (N_MAGIC(x) == ZMAGIC ? _N_HDROFF((x)) + sizeof (struct exec) : sizeof (struct exec))

#define N_DATOFF(x) (N_TXTOFF(x) + (x).a_text)

#ifdef WITH_PERPROCESS_VARIABLES
#define N_PEROFF(x) (N_DATOFF(x) + (x).a_data)

#define N_TRELOFF(x) (N_PEROFF(x) + (x).a_perprocess)
#else
#define N_TRELOFF(x) (N_DATOFF(x) + (x).a_data)
#endif WITH_PERPROCESS_VARIABLES

#define N_DRELOFF(x) (N_TRELOFF(x) + (x).a_trsize)

#ifdef WITH_PERPROCESS_VARIABLES
#define N_PRELOFF(x) (N_DRELOFF(x) + (x).a_drsize)
#define N_SYMOFF(x) (N_PRELOFF(x) + (x).a_prsize)
#else
#define N_SYMOFF(x) (N_DRELOFF(x) + (x).a_drsize)
#endif WITH_PERPROCESS_VARIABLES

#define N_STROFF(x) (N_SYMOFF(x) + (x).a_syms)

/* Address of text segment in memory after it is loaded.  */
#ifndef m68k
#define N_TXTADDR(x) 0
#else
#define N_TXTADDR(x) 0x40000
#endif

#define PAGE_SIZE SEGMENT_SIZE

/* Address of data segment in memory after it is loaded.
   Note that it is up to you to define SEGMENT_SIZE
   on machines not listed here.  */

#ifdef VAX
#define SEGMENT_SIZE 1024
#endif
/* ???? #undef vax Should this be here? */
#ifdef is68k
#define SEGMENT_SIZE 0x20000
#endif

#ifdef m68k
#define SEGMENT_SIZE (1024 * 8)
#endif

#ifndef N_DATADDR
#define N_DATADDR(x) \
    (N_MAGIC(x)==OMAGIC? (N_TXTADDR(x)+(x).a_text) \
     : (SEGMENT_SIZE + ((N_TXTADDR(x)+(x).a_text-1) & ~(SEGMENT_SIZE-1))))
#endif

/* Address of bss segment in memory after it is loaded.  */
#define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data)

#ifdef WITH_PERPROCESS_VARIABLES
#define N_PERPROCESS_ADDR(x) ( N_BSS_ADDR(x) + (x).a_bss  ) 

#define N_PERPROCESS_BSS_ADDR(x) ( N_PERPROCESS_ADDR(x) + (x).a_perprocess  ) 
#endif WITH_PERPROCESS_VARIABLES


struct nlist {
  union {
    char *n_name;
    struct nlist *n_next;
    long n_strx;
  } n_un;
  unsigned char n_type;
  char n_other;
  short n_desc;
  unsigned long n_value;
};

#define N_UNDF 0
#define N_ABS 2
#define N_TEXT 4
#define N_DATA 6
#define N_BSS 8
#define N_FN 15

#ifdef WITH_PERPROCESS_VARIABLES
#define N_PERPROCESS 0xc    /* These last two defines may overlap with some others. */
#define N_PERPROCESS_BSS 0xe /* N_INDR is 0xa, I don't know what else follows in
				stabs.h or something. I'm pretty sure that the
				next one is 0x20 for gensym (sp.) stab or
				0x14 for the set symbols. I think that the
			        assembler uses these so it will have to be
				recompiled. */
#endif WITH_PERPROCESS_VARIABLES

#define N_EXT 1
#define N_TYPE 036
#define N_STAB 0340

/* The following type indicates the definition of a symbol as being
   an indirect reference to another symbol.  The other symbol
   appears as an undefined reference, immediately following this symbol.

   Indirection is asymmetrical.  The other symbol's value will be used
   to satisfy requests for the indirect symbol, but not vice versa.
   If the other symbol does not have a definition, libraries will
   be searched to find a definition.  */
#define N_INDR 0xa

/* The following symbols refer to set elements.
   All the N_SET[ATDB] symbols with the same name form one set.
   Space is allocated for the set in the text section, and each set
   element's value is stored into one word of the space.
   The first word of the space is the length of the set (number of elements).

   The address of the set is made into an N_SETV symbol
   whose name is the same as the name of the set.
   This symbol acts like a N_DATA global symbol
   in that it can satisfy undefined external references.  */

/* These appear as input to LD, in a .o file.  */
#define	N_SETA	0x14		/* Absolute set element symbol */
#define	N_SETT	0x16		/* Text set element symbol */
#define	N_SETD	0x18		/* Data set element symbol */
#define	N_SETB	0x1A		/* Bss set element symbol */
#ifdef WITH_PERPROCESS_VARIABLES
#define	N_SETP	0x1E		/* Peprocess set element symbol */
#define	N_SETPB	0x20		/* Perprocess bss set element symbol */
#endif WITH_PERPROCESS_VARIABLES

/* This is output from LD.  */
#define N_SETV	0x1C		/* Pointer to set vector in data area.  */

/* This structure describes a single relocation to be performed.
   The text-relocation section of the file is a vector of these structures,
   all of which apply to the text section.
   Likewise, the data-relocation section applies to the data section.  */

struct relocation_info
{
  /* Address (within segment) to be relocated.  */
  int r_address;
  /* The meaning of r_symbolnum depends on r_extern.  */
  unsigned int r_symbolnum:24;
  /* Nonzero means value is a pc-relative offset
     and it should be relocated for changes in its own address
     as well as for changes in the symbol or section specified.  */
  unsigned int r_pcrel:1;
  /* Length (as exponent of 2) of the field to be relocated.
     Thus, a value of 2 indicates 1<<2 bytes.  */
  unsigned int r_length:2;
  /* 1 => relocate with value of symbol.
          r_symbolnum is the index of the symbol
	  in file's the symbol table.
     0 => relocate with the address of a segment.
          r_symbolnum is N_TEXT, N_DATA, N_BSS or N_ABS
	  (the N_EXT bit may be set also, but signifies nothing).  */
  unsigned int r_extern:1;
#ifdef WITH_PERPROCESS_VARIABLES
  unsigned int r_bsr:1, /* OVE: used on ns32k based systems, if you want */
 r_disp:1, /* OVE: used on ns32k based systems, if you want */
 nuthin:2;
#else WITH_PERPROCESS_VARIABLES
  /* Four bits that aren't used, but when writing an object file
     it is desirable to clear them.  */
  unsigned int r_pad:4;
#endif WITH_PERPROCESS_VARIABLES
};


#endif /* __A_OUT_GNU_H__ */
*** /xxV/cmds/gld/pgld/mi/ld.c	Wed Sep 13 17:30:33 1989
--- /xxV/cmds/gld/dist/ld.c	Tue Aug  8 14:41:31 1989
***************
*** 33,229 ****
  #include <a.out.h>
  #endif
  
- /*
- ** Byte swapping code.
- */
- #ifdef MUST_BYTE_SWAP
- #define WHEN_BYTE_SWAPPING(stmt) {stmt}
- 
- void
- byte_swap_long_in_place(src, count)
-     register char *src;
-     register int count;
-     /* Byte swap the longs in "src" without copying them anywhere.  "count" 
-      * gives the number of bytes to swap.  It is truncated to an integral
-      * number of longwords (i.e. divisible by four).
-      */
-   {
-     register char *dst = src + 3;
-     register unsigned int temp;
- 
-     count >>= 2;	/* number of longs */
-     
-     while (count-- > 0)
-       {
- 	temp = *src; *src++ = *dst; *dst-- = temp;
- 	temp = *src; *src++ = *dst; *dst-- = temp;
- 	src += 2;
- 	dst += 6;
-       }
-   }
- 
- #define	UR_BITS	3		/* lg(# of times loop unrolled) */
- #define	UR_TIMES (1<<UR_BITS)	/* # of times loop unrolled */
- #define	UR_MASK	(UR_TIMES - 1)
- 
- void
- byte_swap_short_copy(from, to, bytes)
- register char *from, *to;
- unsigned bytes;
- {
- 	register unsigned long temp;
- 	register int	shorts;
- 	
- 	shorts = (bytes>>1)+1;
- 	while ((--shorts)&UR_MASK)/* until remainder is multiple of UR_TIMES */
- 	  {
- 		temp = *from++;
- 		*to++ = *from++;
- 		*to++ = temp;
- 	   }
- 	
- 	shorts >>= UR_BITS;   /* n /= UR_TIMES, # of times for unrolled loop */
- 	while (--shorts >= 0) {
- 
- #define	STEP	temp = *from++;*to++ = *from++;*to++ = temp;
- 
- #if	UR_BITS == 0
- 		STEP
- #endif	UR_BITS == 0
- 
- #if	UR_BITS == 1
- 		STEP
- 		STEP
- #endif	UR_BITS == 1
- 
- #if	UR_BITS == 2
- 		STEP
- 		STEP
- 		STEP
- 		STEP
- #endif	UR_BITS == 2
- 
- #if	UR_BITS == 3
- 		STEP
- 		STEP
- 		STEP
- 		STEP
- 		STEP
- 		STEP
- 		STEP
- 		STEP
- #endif	UR_BITS == 3
- 
- #if	UR_BITS == 4
- 		STEP
- 		STEP
- 		STEP
- 		STEP
- 		STEP
- 		STEP
- 		STEP
- 		STEP
- 		STEP
- 		STEP
- 		STEP
- 		STEP
- 		STEP
- 		STEP
- 		STEP
- 		STEP
- #endif	UR_BITS == 4
- 
- 	}
- } /* byte_swap_short_copy */
- 
- 
- void
- byte_swap_short_in_place(ptr, n)
-     char *ptr;
-     unsigned n;
-   {
-     byte_swap_short_copy(ptr, ptr, n);
-   }
- 
- void
- byte_swap_exec(x)
- struct exec *x;
- {
-   byte_swap_long_in_place(x, sizeof (struct exec));
- }
- 
- byte_swap_nlist(x)
- struct nlist *x;
- {
-   byte_swap_long_in_place(&(x->n_un.n_strx), sizeof (x->n_un.n_strx));
-   byte_swap_short_in_place(&(x->n_desc), sizeof (x->n_desc));
-   byte_swap_long_in_place(&(x->n_value), sizeof (x->n_value));
- 
- }
- 
- void
- byte_swap_nlist_array(x, n)
- struct nlist *x;
- int n;
- {
-   struct nlist *p = x;
- 
-   while ( p < ( x + n ))
-     {
-       byte_swap_nlist(p);
-       p++;
-     }
- }
- 
- byte_swap_relocation_info(relptr, relend)
-    struct relocation_info *relptr, *relend;
-   {
-     while (relptr < relend)
-       {
- 	register unsigned char c;
- 	register unsigned char *cp;
- 
- 	byte_swap_long_in_place(relptr, 2*sizeof(long));
- 	cp = (unsigned char *)&((long *)relptr)[1];
- 	c = cp[0];
- 	cp[0] = cp[1];
- 	cp[1] = cp[2];
- 	cp[2] = cp[3];
- 	cp[3] = (c>>4) |	/* move filler 4 bits */
- 		((c&0x08)<<1) |	/* move r_extern */
- 		((c&0x06)<<4) |	/* move r_length */
- 		((c&0x01)<<7);	/* move r_pcrel */
- 	relptr++;
-       }
-   }
- 
- unbyte_swap_relocation_info(relptr, relend)
-    struct relocation_info *relptr, *relend;
-   {
-     while (relptr < relend)
-       {
- 	register unsigned char c;
- 	register unsigned char *cp;
- 
- 	byte_swap_long_in_place(relptr, 2*sizeof(long));
- 	cp = (unsigned char *)&((long *)relptr)[1];
- 	c = cp[0];
- 	cp[0] = cp[1];
- 	cp[1] = cp[2]; /* These next two lines are a little suspect. */
- 	cp[2] = cp[3];
- 	cp[3] = (c<<4) |	/* move filler 4 bits */
- 	        ((c&0x10)>>1) |	/* move r_extern */
- 		((c&0x60)>>4) |	/* move r_length */
- 		((c&0x80)>>7);	/* move r_pcrel */
- 	relptr++;
-       }
-   }
- 
- #else
- #define WHEN_BYTE_SWAPPING(stmt) 
- #endif
- 
- 
  #ifndef N_SET_MAGIC
  #define N_SET_MAGIC(exec, val)  ((exec).a_magic = val)
  #endif
--- 33,38 ----
***************
*** 665,674 ****
  
  symbol *edata_symbol;   /* the symbol _edata */
  symbol *etext_symbol;   /* the symbol _etext */
- #ifdef WITH_PERPROCESS_VARIABLES
- symbol *ebss_symbol;   /* the symbol _etext */
- symbol *eperprocess_symbol;   /* the symbol _etext */
- #endif WITH_PERPROCESS_VARIABLES
  symbol *end_symbol;	/* the symbol _end */
  
  /* Each input file, and each library member ("subfile") being loaded,
--- 474,479 ----
***************
*** 719,728 ****
    struct relocation_info *textrel;
    /* Data reloc info saved by `write_data' for `copdatrel'.  */
    struct relocation_info *datarel;
- #ifdef WITH_PERPROCESS_VARIABLES
-   /* Perprocess reloc info saved by `write_perprocess' for `copperrel'.  */
-   struct relocation_info *perprocessrel;
- #endif WITH_PERPROCESS_VARIABLES
  
    /* Relation of this file's segments to the output file */
  
--- 524,529 ----
***************
*** 732,744 ****
    int data_start_address;
    /* Start of this file's bss seg in the output file core image.  */
    int bss_start_address;
- #ifdef WITH_PERPROCESS_VARIABLES
-   /* Start of this file's perprocess seg in the output file core image.  */
-   int perprocess_start_address;
-   /* Start of this file's perprocess_bss seg in the output file core image.  */
-   int perprocess_bss_start_address;
- #endif WITH_PERPROCESS_VARIABLES
- 
    /* Offset in bytes in the output file symbol table
       of the first local symbol for this file.  Set by `write_file_symbols'.  */
    int local_syms_offset;
--- 533,538 ----
***************
*** 766,780 ****
    /* 1 means search a set of directories for this file.  */
    char search_dirs_flag;
  
- #ifdef WITH_PERPROCESS_VARIABLES
    /* 1 means this is base file of incremental load.
-      Do not load this file's text or data or perprocess.
-      Also default text_start to after this file's perprocess bss. */
- #else  WITH_PERPROCESS_VARIABLES
-   /* 1 means this is base file of incremental load.
       Do not load this file's text or data.
       Also default text_start to after this file's bss. */
- #endif WITH_PERPROCESS_VARIABLES
    char just_syms_flag;
  };
  
--- 560,568 ----
***************
*** 785,799 ****
  /* Length of that vector.  */
  int number_of_files;
  
- #ifdef WITH_PERPROCESS_VARIABLES
- /* When loading the text, data, and perprocess, we can avoid doing a close
-    and another open between members of the same library.
- 
-    These two variables remember the file that is currently open.
-    Both are zero if no file is open.
- 
-    See `each_file' and `file_close'.  */
- #else  WITH_PERPROCESS_VARIABLES
  /* When loading the text and data, we can avoid doing a close
     and another open between members of the same library.
  
--- 573,578 ----
***************
*** 801,807 ****
     Both are zero if no file is open.
  
     See `each_file' and `file_close'.  */
- #endif WITH_PERPROCESS_VARIABLES
  
  struct file_entry *input_file;
  int input_desc;
--- 580,585 ----
***************
*** 828,843 ****
  int text_size;		/* total size of text of all input files.  */
  int data_size;		/* total size of data of all input files.  */
  int bss_size;		/* total size of bss of all input files.  */
- #ifdef WITH_PERPROCESS_VARIABLES
- int perprocess_size;		/* total size of perprocess of all input files.  */
- int perprocess_bss_size;		/* total size of perprocess_bss of all input files.  */
- #endif WITH_PERPROCESS_VARIABLES
  int text_reloc_size;	/* total size of text relocation of all input files.  */
  int data_reloc_size;	/* total size of data relocation of all input */
  			/* files.  */
- #ifdef WITH_PERPROCESS_VARIABLES
- int perprocess_reloc_size;	/* total size of perprocess relocation of all input */
- #endif WITH_PERPROCESS_VARIABLES
  
  /* Specifications of start and length of the area reserved at the end
     of the text segment for the set vectors.  Computed in 'digest_symbols' */
--- 606,614 ----
***************
*** 856,875 ****
  
  int data_pad;
  
- #ifdef WITH_PERPROCESS_VARIABLES
- 
- /* Amount of space needed to pad the bss segment to a page boundary */
- int bss_pad;
- 
- /* Amount of perprocess bss segment to include as part of the perprocess segment.  */
- 
- int perprocess_pad;
- 
- /* Amount of space needed to pad the perprocess bss segment to a page boundary */
- int perprocess_bss_pad;
- 
- #endif WITH_PERPROCESS_VARIABLES
- 
  /* Format of __.SYMDEF:
     First, a longword containing the size of the 'symdef' data that follows.
     Second, zero or more 'symdef' structures.
--- 627,632 ----
***************
*** 894,905 ****
  /* Address we decide the data section will be loaded at.  */
  int data_start;
  
- #ifdef WITH_PERPROCESS_VARIABLES
- int perprocess_start;
- 
- int perprocess_bss_start;
- #endif WITH_PERPROCESS_VARIABLES
- 
  /* `text-start' address is normally this much plus a page boundary.
     This is not a user option; it is fixed for each system.  */
  int text_start_alignment;
--- 651,656 ----
***************
*** 912,935 ****
     This prevents data_start from being set later to default values.  */
  int Tdata_flag_specified;
  
- #ifdef WITH_PERPROCESS_VARIABLES
- /* Nonzero if -Tperprocess was specified in the command line.
-    This prevents perprocess_start from being set later to default values.  */
- int Tperprocess_flag_specified;
- #endif WITH_PERPROCESS_VARIABLES
- 
  /* Size to pad data section up to.
     We simply increase the size of the data section, padding with zeros,
     and reduce the size of the bss section to match.  */
  int specified_data_size;
  
- #ifdef WITH_PERPROCESS_VARIABLES
- /* Size to pad perprocess section up to.
-    We simply increase the size of the perprocess section, padding with zeros,
-    and reduce the size of the perprocess bss section to match.  */
- int specified_perprocess_size;
- #endif WITH_PERPROCESS_VARIABLES
- 
  /* Magic number to use for the output file, set by switch.  */
  int magic;
  
--- 663,673 ----
***************
*** 1013,1021 ****
  void write_text ();
  void read_file_relocation ();
  void write_data ();
- #ifdef WITH_PERPROCESS_VARIABLES
- void write_perprocess ();
- #endif WITH_PERPROCESS_VARIABLES
  void write_rel ();
  void write_syms ();
  void write_symsegs ();
--- 751,756 ----
***************
*** 1026,1042 ****
  char *get_file_name ();
  symbol *getsym (), *getsym_soft ();
  
- 
  int
  main (argc, argv)
       char **argv;
       int argc;
  {
- #ifdef WITH_PERPROCESS_VARIABLES
-   page_size = SEGMENT_SIZE;
- #else  WITH_PERPROCESS_VARIABLES
    page_size = getpagesize ();
- #endif WITH_PERPROCESS_VARIABLES
    progname = argv[0];
  
    /* Clear the cumulative info on the output file.  */
--- 761,772 ----
***************
*** 1044,1065 ****
    text_size = 0;
    data_size = 0;
    bss_size = 0;
- #ifdef WITH_PERPROCESS_VARIABLES
-   perprocess_size = 0;
-   perprocess_bss_size = 0;
- #endif WITH_PERPROCESS_VARIABLES
- 
    text_reloc_size = 0;
    data_reloc_size = 0;
- #ifdef WITH_PERPROCESS_VARIABLES
-   perprocess_reloc_size = 0;
- #endif WITH_PERPROCESS_VARIABLES
  
    data_pad = 0;
    text_pad = 0;
- #ifdef WITH_PERPROCESS_VARIABLES
-   perprocess_pad = 0;
- #endif WITH_PERPROCESS_VARIABLES
  
    /* Initialize the data about options.  */
  
--- 774,784 ----
***************
*** 1073,1082 ****
    force_common_definition = 0;
    T_flag_specified = 0;
    Tdata_flag_specified = 0;
- #ifdef WITH_PERPROCESS_VARIABLES
-   Tperprocess_flag_specified = 0;
- #endif WITH_PERPROCESS_VARIABLES
- 
    magic = DEFAULT_MAGIC;
    make_executable = 1;
    force_executable = 0;
--- 792,797 ----
***************
*** 1104,1114 ****
    decode_command (argc, argv);
  
    /* Create the symbols `etext', `edata' and `end'.  */
- #ifdef WITH_PERPROCESS_VARIABLES
-   /* and 'ebss' and 'eperprocess'. */
- #endif WITH_PERPROCESS_VARIABLES
  
!  if (!relocatable_output)
      symtab_init ();
  
    /* Determine whether to count the header as part of
--- 819,826 ----
    decode_command (argc, argv);
  
    /* Create the symbols `etext', `edata' and `end'.  */
  
!   if (!relocatable_output)
      symtab_init ();
  
    /* Determine whether to count the header as part of
***************
*** 1205,1217 ****
  	return 2;
        if (! strcmp (&arg[2], "data"))
  	return 2;
- #ifdef WITH_PERPROCESS_VARIABLES
-       /*
-       ** I'm not sure why this is here.
-       */
-       if (! strcmp (&arg[2], "perprocess"))
- 	return 2;
- #endif WITH_PERPROCESS_VARIABLES
        return 1;
      }
  
--- 917,922 ----
***************
*** 1376,1389 ****
        Tdata_flag_specified = 1;
        return;
      }
- #ifdef WITH_PERPROCESS_VARIABLES
-   if (! strcmp (swt + 1, "Tperprocess"))
-     {
-       perprocess_start = parse (arg, "%x", "invalid argument to -Tperprocess");
-       Tperprocess_flag_specified = 1;
-       return;
-     }
- #endif WITH_PERPROCESS_VARIABLES
    if (! strcmp (swt + 1, "noinhibit-exec"))
      {
        force_executable = 1;
--- 1081,1086 ----
***************
*** 1440,1451 ****
        output_filename = arg;
        return;
  
- #ifdef WITH_PERPROCESS_VARIABLES
-     case 'P':
-       specified_perprocess_size = parse (arg, "%x", "invalid argument to -P");
-       return;
- #endif WITH_PERPROCESS_VARIABLES
- 
      case 'r':
        relocatable_output = 1;
        magic = OMAGIC;
--- 1137,1142 ----
***************
*** 1722,1728 ****
    len = read (desc, loc, sizeof (struct exec));
    if (len != sizeof (struct exec))
      fatal_with_file ("failure reading header of ", entry);
-   WHEN_BYTE_SWAPPING(byte_swap_exec(&(entry->header));)
    if (N_BADMAG (*loc))
      fatal_with_file ("bad magic number in ", entry);
  
--- 1413,1418 ----
***************
*** 1749,1760 ****
    lseek (desc, N_SYMOFF (entry->header) + entry->starting_offset, 0);
    if (entry->header.a_syms != read (desc, entry->symbols, entry->header.a_syms))
      fatal_with_file ("premature end of file in symbols of ", entry);
!   WHEN_BYTE_SWAPPING(byte_swap_nlist_array(entry->symbols,
! 			entry->header.a_syms / (sizeof (struct nlist)));)
    lseek (desc, N_STROFF (entry->header) + entry->starting_offset, 0);
    if (sizeof str_size != read (desc, &str_size, sizeof str_size))
      fatal_with_file ("bad string table size in ", entry);
!   WHEN_BYTE_SWAPPING(byte_swap_long_in_place(&str_size, sizeof str_size);)
    entry->string_size = str_size;
  }
  
--- 1439,1449 ----
    lseek (desc, N_SYMOFF (entry->header) + entry->starting_offset, 0);
    if (entry->header.a_syms != read (desc, entry->symbols, entry->header.a_syms))
      fatal_with_file ("premature end of file in symbols of ", entry);
! 
    lseek (desc, N_STROFF (entry->header) + entry->starting_offset, 0);
    if (sizeof str_size != read (desc, &str_size, sizeof str_size))
      fatal_with_file ("bad string table size in ", entry);
! 
    entry->string_size = str_size;
  }
  
***************
*** 2015,2030 ****
  	  reftype = "defined in BSS section";
  	  break;
  
- #ifdef WITH_PERPROCESS_VARIABLES
- 	case N_PERPROCESS:
- 	  reftype = "defined in perprocess section";
- 	  break;
- 
- 	case N_PERPROCESS_BSS:
- 	  reftype = "defined in perprocess BSS section";
- 	  break;
- #endif WITH_PERPROCESS_VARIABLES
- 
  	case N_SETT:
  	  reftype = "is a text set element";
  	  break;
--- 1704,1709 ----
***************
*** 2037,2052 ****
  	  reftype = "is a BSS set element";
  	  break;
  
- #ifdef WITH_PERPROCESS_VARIABLES
- 	case N_SETP:
- 	  reftype = "is a perprocess set element";
- 	  break;
- 
- 	case N_SETPB:
- 	  reftype = "is a perprocess BSS set element";
- 	  break;
- #endif WITH_PERPROCESS_VARIABLES
- 
  	case N_SETA:
  	  reftype = "is an absolute set element";
  	  break;
--- 1716,1721 ----
***************
*** 2055,2067 ****
  	  reftype = "defined in data section as vector";
  	  break;
  
- #ifdef WITH_PERPROCESS_VARIABLES
- /*
- **      Should there be a vector in the perprocess section, too?
- **      Probably, but I will wait until I handle C++ completely.
- */
- #endif WITH_PERPROCESS_VARIABLES
- 
  	case N_INDR:
  	  reftype = (char *) alloca (23
  				     + strlen ((nlist_p + 1)->n_un.n_strx
--- 1724,1729 ----
***************
*** 2481,2496 ****
  
    /* Compute total size of sections */
  
- #ifdef WITH_PERPROCESS_VARIABLES
-   /*
-   ** This next call side effects the global variables
-   ** text_size, data_size, ... 
-   */
- #endif WITH_PERPROCESS_VARIABLES
- 
    each_file (consider_file_section_lengths, 0);
  
- 
    /* If necessary, pad text section to full page in the file.
       Include the padding in the text segment size.  */
  
--- 2143,2150 ----
***************
*** 2508,2589 ****
    if (! Tdata_flag_specified)
      data_start = N_DATADDR (outheader) + text_start - N_TXTADDR (outheader);
  
- #ifdef WITH_PERPROCESS_VARIABLES
- /*
- ** The end of the perprocess segment will be double page
- ** aligned by caluclating the "perprocess_pad" after the
- ** relocation calculations are done to insure that the
- ** perprocess_bss segment abuts the perprocess segment
- ** exactly, so that some of the perprocess bss segment
- ** is incorporated into the perprocess_pad so that no
- ** space is wasted, just for padding.
- */
- /*
- ** The data pad must be known before the perprocess_start is
- ** calculated, but the data_pad cannot be added in to
- ** data size until after relocate_file_address is called on
- ** each entry file so that the data and data bss segments bill
- ** abut precisely.  For this same reason, the perprocess_pad 
- ** is not added in until after this also.
- */
- 
- 
- /*
- **  Figure the data_pad now, but don't add it in to data size until
- ** after the file address and symbols are relocated, 
- ** so that it overlaps with the bss addresses.  
- */
- 
-   if (specified_data_size && specified_data_size > data_size)
-     data_pad = specified_data_size - data_size;
- 
-   {
- 
-     /*
-     ** Use these temporary variables to determine the beginning of the
-     ** perprocess segment before the padding is actually added into
-     ** the data and bss segments to make them page aligned.
-     */
-     int data_size_after_page_aligning = 0;
-     int bss_size_after_page_aligning  = 0;
- 
-   if (magic == ZMAGIC)
-     {
- 
-       data_pad = ((data_pad + data_size + page_size - 1) & (- page_size))
- 	- data_size;
- 
-       data_size_after_page_aligning = data_size;
-       bss_size_after_page_aligning  = bss_size;
- 
-       /*
-       ** Incorporate some of the bss segment into the data_pad to 
-       ** save space in the executing program image.
-       */
-       bss_size_after_page_aligning -=  data_pad;
- 
-       if (bss_size_after_page_aligning < 0) bss_size_after_page_aligning = 0;
- 
-       data_size_after_page_aligning += data_pad;
- 
-       bss_pad = ((bss_pad + bss_size_after_page_aligning 
- 		  + page_size - 1) & (- page_size))
- 	- bss_size_after_page_aligning;
- 
-       bss_size_after_page_aligning += bss_pad;
- 
-     }
- 
-   /* Make the perprocess segment address start in memory on a suitable boundary.  */
- 
-   if (! Tperprocess_flag_specified)
-     perprocess_start = data_start + data_size_after_page_aligning + 
-       bss_size_after_page_aligning;
- 
-   perprocess_bss_start = perprocess_start + perprocess_size;
- }
- #endif WITH_PERPROCESS_VARIABLES
- 
    /* Set up the set element vector */
  
    if (!relocatable_output)
--- 2162,2167 ----
***************
*** 2717,2724 ****
  	}
      }
  
- #ifdef WITH_PERPROCESS_VARIABLES
- #else  WITH_PERPROCESS_VARIABLES
    if (end_symbol)		/* These are null if -r.  */
      {
        etext_symbol->value = text_size + text_start;
--- 2295,2300 ----
***************
*** 2725,2733 ****
        edata_symbol->value = data_start + data_size;
        end_symbol->value = data_start + data_size + bss_size;
      }
- #endif WITH_PERPROCESS_VARIABLES
  
- 
    /* Figure the data_pad now, so that it overlaps with the bss addresses.  */
  
    if (specified_data_size && specified_data_size > data_size)
--- 2301,2307 ----
***************
*** 2741,2798 ****
    if (bss_size < 0) bss_size = 0;
  
    data_size += data_pad;
- 
- #ifdef WITH_PERPROCESS_VARIABLES
-   /*
-   ** Align the end of the perprocess segment to a page boundary and
-   ** incorporate part of the following perprocess bss segment into the
-   ** the padding to save space in the executable image.  
-   ** Adding in the padding to perprocess_size must be done here, after 
-   ** the relocation of addresses, so that the perprocess data and the
-   ** perprocess bss data abut exactly as if there were no padding.
-   */
- 
-   if (magic == ZMAGIC)
-     perprocess_pad = 
-       ((perprocess_pad + perprocess_size + page_size - 1) & (- page_size))
-                - perprocess_size;
- 
-   perprocess_bss_size -= perprocess_pad;
-   if (perprocess_bss_size < 0) perprocess_bss_size = 0;
- 
-   perprocess_size += perprocess_pad;
-   /*
-   ** Make sure that the perprocess bss segment is also page aligned.
-   */
-   if (magic == ZMAGIC)
-     perprocess_bss_pad = 
-       ((perprocess_bss_pad + perprocess_bss_size + page_size - 1) & (- page_size))
-                - perprocess_bss_size;
- 
-   perprocess_bss_size += perprocess_bss_pad;
- 
- /*
- ** These symbols point to the page aligned ends of all of these segments,
- ** regardless if any of the bss segment data was promoted to data or
- ** perprocess to fill in the padding for alignment.
- */
-   if (end_symbol)		/* These are null if -r.  */
-     {
-       /*
-       ** These numbers are calculated a little weird.
-       ** They could probably be calculated more uniformly,
-       ** but I'm not sure if all of the appropriate
-       ** values are every really initialized.
-       */
-       etext_symbol->value = text_size + text_start;
-       edata_symbol->value = data_start + data_size;
-       ebss_symbol->value = perprocess_start;
-       eperprocess_symbol->value = perprocess_start + perprocess_size;
-       end_symbol->value = perprocess_start + perprocess_size + 
- 	perprocess_bss_size;
-     }
- #endif WITH_PERPROCESS_VARIABLES
- 
  }
  
  /* Accumulate the section sizes of input file ENTRY
--- 2315,2320 ----
***************
*** 2820,2843 ****
    data_size += entry->header.a_data;
    entry->bss_start_address = bss_size;
    bss_size += entry->header.a_bss;
- #ifdef WITH_PERPROCESS_VARIABLES
- /*
- ** This is a little confusing.
- ** Are the effects of these statements undone somewhere?
- */
-   entry->perprocess_start_address = perprocess_size;
-   perprocess_size += entry->header.a_perprocess;
-   entry->perprocess_bss_start_address = perprocess_bss_size;
-   perprocess_bss_size += entry->header.a_perprocess_bss;
- #endif WITH_PERPROCESS_VARIABLES
  
    text_reloc_size += entry->header.a_trsize;
    data_reloc_size += entry->header.a_drsize;
- #ifdef WITH_PERPROCESS_VARIABLES
-   perprocess_reloc_size += 
-     entry->header.a_prsize;
- #endif WITH_PERPROCESS_VARIABLES
- 
  }
  
  /* Determine where the sections of ENTRY go into the output file,
--- 2342,2350 ----
***************
*** 2855,2868 ****
    entry->data_start_address += data_start;
    entry->bss_start_address += data_start + data_size;
  
- #ifdef WITH_PERPROCESS_VARIABLES
-   /* Note that `perprocess_start' and `perprocess_size' have not yet been
-      adjusted for `perprocess_pad'.  If they had been, we would get the wrong
-      results here.  */
-   entry->perprocess_start_address += perprocess_start;
-   entry->perprocess_bss_start_address += perprocess_start + perprocess_size;
- #endif WITH_PERPROCESS_VARIABLES
- 
    {
      register struct nlist *p;
      register struct nlist *end
--- 2362,2367 ----
***************
*** 2893,2925 ****
  	    p->n_value += entry->bss_start_address
  	      - entry->header.a_text - entry->header.a_data;
  	    break;
- #ifdef WITH_PERPROCESS_VARIABLES
- 	  case N_PERPROCESS:
- 	  case N_SETP:
- 	    /* A symbol whose value is in the PERPROCESS section
- 	       is present in the input file as if the PERPROCESS section
- 	       started at 0.*/
- 	    p->n_value += 
- 	      (entry->perprocess_start_address - perprocess_start);
- 	    break;
- 	  case N_PERPROCESS_BSS:
- 	  case N_SETPB:
- 	    /*
- 	    ** I'm having a lot of problems with this one.
- 	    */
- 	    /* likewise for symbols with value in BSS.  */
- 	    p->n_value += 
- 	      ( entry->perprocess_bss_start_address 
- 	       - perprocess_start)
- 		- entry->header.a_perprocess;  
- 	    break;
- 	  default:
- 	    /* abort(); This shouldn't be here since falling through the
- 	       case is valid, but I don't like that idea as far as
- 	       debugability goes. What if an invalid segment number passes
- 	       through here? */
- 	    break;
- #endif WITH_PERPROCESS_VARIABLES
  	  }
        }
    }
--- 2392,2397 ----
***************
*** 2968,2989 ****
    if (entry->just_syms_flag)
      fprintf (outfile, " symbols only\n", 0);
    else
- #ifdef WITH_PERPROCESS_VARIABLES
-     fprintf (outfile, " text %x(%x), data %x(%x), bss %x(%x), perprocess %x(%x)\
- , perprocess_bss %x(%x) hex\n",
- 	     entry->text_start_address, entry->header.a_text,
- 	     entry->data_start_address, entry->header.a_data,
- 	     entry->bss_start_address, entry->header.a_bss,
- 	     entry->perprocess_start_address, 
- 		entry->header.a_perprocess,
- 	     entry->perprocess_bss_start_address, 
- 		entry->header.a_perprocess_bss);
- #else
      fprintf (outfile, " text %x(%x), data %x(%x), bss %x(%x) hex\n",
  	     entry->text_start_address, entry->header.a_text,
  	     entry->data_start_address, entry->header.a_data,
  	     entry->bss_start_address, entry->header.a_bss);
- #endif WITH_PERPROCESS_VARIABLES
  }
  
  void
--- 2440,2449 ----
***************
*** 3082,3092 ****
  	  next->line = next->sym->n_desc;
  	  return 1;
  	case N_DSLINE:
- #ifdef WITH_PERPROCESS_VARIABLES
  	  if (!use_data_symbols) continue;
- #else WITH_PERPROCESS_VARIABLES
- 	  if (!(use_data_symbols == 1)) continue;
- #endif WITH_PERPROCESS_VARIABLES
  	  next->line = next->sym->n_desc;
  	  return 1;
  #ifdef HAVE_SUN_STABS
--- 2542,2548 ----
***************
*** 3197,3228 ****
  
    int use_data_symbols;
  
- #ifdef WITH_PERPROCESS_VARIABLES
    if (next->sym)
-     {
-       switch (next->sym->n_type & N_TYPE)
- 	{
- 	case N_DATA:
- 	  use_data_symbols = 1;
- 	  break;
- 	case N_PERPROCESS:
- 	  use_data_symbols = 2;
- 	  break;
- 	default:
- 	  use_data_symbols = 0;
- 	  break;
- 	}
-     }
-   else
-     return current->line;
- #else WITH_PERPROCESS_VARIABLES
-   if (next->sym)
      use_data_symbols = (next->sym->n_type & N_TYPE) == N_DATA;
    else
      return current->line;
- #endif WITH_PERPROCESS_VARIABLES
  
- 
    /* Go back to the beginning if we've already passed it.  */
    if (current->sym->n_value > address)
      {
--- 2653,2663 ----
***************
*** 3267,3318 ****
       FILE *outfile;
       unsigned char *nlist_bitvector;
  {
- #ifdef WITH_PERPROCESS_VARIABLES
-   struct relocation_info *reloc_start, *reloc;
-   int reloc_size;
-   int start_of_segment;
-   struct nlist *start_of_syms = entry->symbols;
-   struct line_debug_entry *state_pointer;
-   register struct line_debug_entry *current, *next, *source;
-   /* Assigned to generally static values; should not be written into.  */
-   char *errfmt;
-   /* Assigned to alloca'd values cand copied into; should be freed
-      when done.  */
-   char *errmsg;
-   int invalidate_line_number;
- 
-   switch (data_segment)
-     {
-     case 0:
-       /* Text segment */
-       reloc_start = entry->textrel,
-       reloc_size = entry->header.a_trsize  / sizeof (struct relocation_info);
-       start_of_segment = entry->text_start_address;
-       state_pointer = init_debug_scan (0, entry);
-       break;
-     case 1:
-       /* Data segment */
-       reloc_start = entry->datarel;
-       reloc_size = entry->header.a_drsize / sizeof (struct relocation_info);
-       start_of_segment = entry->data_start_address;
-       state_pointer = init_debug_scan (1, entry);
-       break;
-     case 2:
-       /* Perprocess segment */
-       reloc_start = entry->perprocessrel,
-       reloc_size = entry->header.a_prsize / sizeof (struct relocation_info);
-       start_of_segment = entry->perprocess_start_address;
-       state_pointer = init_debug_scan (2, entry);
-       break;
-     default:
-       abort();
-       break;
-     }
- 
-     current = state_pointer;
-     next = state_pointer + 1;
-     source = state_pointer + 2;
- #else
    struct relocation_info
      *reloc_start = data_segment ? entry->datarel : entry->textrel,
      *reloc;
--- 2702,2707 ----
***************
*** 3335,3342 ****
    char *errmsg;
    int invalidate_line_number;
  
- #endif WITH_PERPROCESS_VARIABLES
- 
    /* We need to sort the relocation info here.  Sheesh, so much effort
       for one lousy error optimization. */
  
--- 2724,2729 ----
***************
*** 3402,3426 ****
  	}
        
        errmsg = (char *) alloca (strlen (errfmt) + strlen (g->name) + 1);
- #ifdef WITH_PERPROCESS_VARIABLES
-       switch (data_segment)
- 	{
- 	case 0:
- 	  sprintf (errmsg, errfmt, g->name, "text");
- 	  break;
- 	case 1:
- 	  sprintf (errmsg, errfmt, g->name, "data");
- 	  break;
- 	case 2:
- 	  sprintf (errmsg, errfmt, g->name, "perprocess");
- 	  break;
- 	default:
- 	  abort();
- 	}
- #else
        sprintf (errmsg, errfmt, g->name, data_segment ? "data" : "text");
- #endif WITH_PERPROCESS_VARIABLES
- 
        address_to_line (RELOC_ADDRESS (reloc) + start_of_segment,
  		       state_pointer);
  
--- 2789,2795 ----
***************
*** 3449,3458 ****
    unsigned char *nlist_bitvector =
      (unsigned char *) alloca ((number_of_syms >> 3) + 1);
    struct line_debug_entry *text_scan, *data_scan;
- #ifdef WITH_PERPROCESS_VARIABLES
-   struct line_debug_entry *perprocess_scan;
- #endif WITH_PERPROCESS_VARIABLES
- 
    int i;
    char *errfmt, *file_name;
    int line_number;
--- 2818,2823 ----
***************
*** 3477,3497 ****
    /* Do data warnings based on a scan through the relocation info.  */
    do_relocation_warnings (entry, 1, outfile, nlist_bitvector);
  
- #ifdef WITH_PERPROCESS_VARIABLES
-   /* Do data warnings based on a scan through the relocation info.  */
-   do_relocation_warnings (entry, 2, outfile, nlist_bitvector);
- #endif WITH_PERPROCESS_VARIABLES
- 
    /* Scan through all of the nlist entries in this file and pick up
       anything that the scan through the relocation stuff didn't.  */
  
    text_scan = init_debug_scan (0, entry);
    data_scan = init_debug_scan (1, entry);
- #ifdef WITH_PERPROCESS_VARIABLES
-   data_scan = init_debug_scan (2, entry);
- #endif WITH_PERPROCESS_VARIABLES
  
- 
    for (i = 0; i < number_of_syms; i++)
      {
        struct nlist *s;
--- 2842,2853 ----
***************
*** 3517,3537 ****
  	      line_number = address_to_line (s->n_value, data_scan);
  	      file_name = data_scan[0].filename;
  	      break;
- #ifdef WITH_PERPROCESS_VARIABLES
- 	    case N_PERPROCESS | N_EXT:
- 	      line_number = address_to_line (s->n_value, perprocess_scan);
- 	      file_name = perprocess_scan[0].filename;
- 	      break;
- #endif WITH_PERPROCESS_VARIABLES
- 
  	    case N_SETA | N_EXT:
  	    case N_SETT | N_EXT:
  	    case N_SETD | N_EXT:
  	    case N_SETB | N_EXT:
- #ifdef WITH_PERPROCESS_VARIABLES
- 	    case N_SETP | N_EXT:
- 	    case N_SETPB | N_EXT:
- #endif WITH_PERPROCESS_VARIABLES
  	      if (g->multiply_defined == 2)
  		continue;
  	      errfmt = "First set element definition of symbol %s (multiply defined)";
--- 2873,2882 ----
***************
*** 3573,3582 ****
      }
    free (text_scan);
    free (data_scan);
- #ifdef WITH_PERPROCESS_VARIABLES
-   free (perprocess_scan);
- #endif WITH_PERPROCESS_VARIABLES
- 
    entry->strings = 0;		/* Since it will dissapear anyway.  */
  }
  
--- 2918,2923 ----
***************
*** 3698,3707 ****
    /* Output the text and data segments, relocating as we go.  */
    write_text ();
    write_data ();
- #ifdef WITH_PERPROCESS_VARIABLES
-   /* and perprocess segment. */
-   write_perprocess ();
- #endif WITH_PERPROCESS_VARIABLES
  
    /* Output the merged relocation info, if requested with `-r'.  */
    if (relocatable_output)
--- 3039,3044 ----
***************
*** 3719,3727 ****
  }
  
  void modify_location (), perform_relocation (), copy_text (), copy_data ();
- #ifdef WITH_PERPROCESS_VARIABLES
- void copy_perprocess();
- #endif WITH_PERPROCESS_VARIABLES
  
  void
  write_header ()
--- 3056,3061 ----
***************
*** 3730,3740 ****
    outheader.a_text = text_size;
    outheader.a_data = data_size;
    outheader.a_bss = bss_size;
- #ifdef WITH_PERPROCESS_VARIABLES
-   outheader.a_perprocess = perprocess_size;
-   outheader.a_perprocess_bss = perprocess_bss_size;
- #endif WITH_PERPROCESS_VARIABLES
- 
    outheader.a_entry = (entry_symbol ? entry_symbol->value
  		       : text_start + entry_offset);
  #ifdef COFF_ENCAPSULATE
--- 3064,3069 ----
***************
*** 3828,3845 ****
      {
        outheader.a_trsize = text_reloc_size;
        outheader.a_drsize = data_reloc_size;
- #ifdef WITH_PERPROCESS_VARIABLES
-       outheader.a_prsize = perprocess_reloc_size;
- #endif WITH_PERPROCESS_VARIABLES
      }
    else
      {
        outheader.a_trsize = 0;
        outheader.a_drsize = 0;
- #ifdef WITH_PERPROCESS_VARIABLES
-       outheader.a_prsize = 0;
- #endif WITH_PERPROCESS_VARIABLES
- 
      }
  
  #ifdef COFF_ENCAPSULATE
--- 3157,3167 ----
***************
*** 3846,3854 ****
    if (need_coff_header)
      mywrite (&coffheader, sizeof coffheader, 1, outdesc);
  #endif
-   WHEN_BYTE_SWAPPING(byte_swap_exec(&outheader);)
    mywrite (&outheader, sizeof (struct exec), 1, outdesc);
-   WHEN_BYTE_SWAPPING(byte_swap_exec(&outheader);)
  
    /* Output whatever padding is required in the executable file
       between the header and the start of the text.  */
--- 3168,3174 ----
***************
*** 3906,3927 ****
      {
        reloc = (struct relocation_info *) xmalloc (entry->header.a_trsize);
        desc = file_open (entry);
- #ifdef WITH_PERPROCESS_VARIABLES
-       lseek (desc, entry->starting_offset + N_TRELOFF(entry->header), L_SET);
- #else WITH_PERPROCESS_VARIABLES
        lseek (desc,
  	     text_offset (entry) + entry->header.a_text + entry->header.a_data,
  	     L_SET);
- #endif WITH_PERPROCESS_VARIABLES
        if (entry->header.a_trsize != (read_return = read (desc, reloc, entry->header.a_trsize)))
  	{
  	  fprintf (stderr, "Return from read: %d\n", read_return);
  	  fatal_with_file ("premature eof in text relocatino of ", entry);
  	}
!       WHEN_BYTE_SWAPPING(unbyte_swap_relocation_info(reloc, 
! 			     reloc + 
! 			     (entry->header.a_trsize / sizeof (struct relocation_info)));)
!      entry->textrel = reloc;
      }
  
    if (!entry->datarel)
--- 3226,3240 ----
      {
        reloc = (struct relocation_info *) xmalloc (entry->header.a_trsize);
        desc = file_open (entry);
        lseek (desc,
  	     text_offset (entry) + entry->header.a_text + entry->header.a_data,
  	     L_SET);
        if (entry->header.a_trsize != (read_return = read (desc, reloc, entry->header.a_trsize)))
  	{
  	  fprintf (stderr, "Return from read: %d\n", read_return);
  	  fatal_with_file ("premature eof in text relocatino of ", entry);
  	}
!       entry->textrel = reloc;
      }
  
    if (!entry->datarel)
***************
*** 3928,3970 ****
      {
        reloc = (struct relocation_info *) xmalloc (entry->header.a_drsize);
        if (desc == -1) desc = file_open (entry);
- #ifdef WITH_PERPROCESS_VARIABLES
-       lseek (desc, entry->starting_offset + N_DRELOFF(entry->header), L_SET);
- #else WITH_PERPROCESS_VARIABLES
        lseek (desc,
  	     text_offset (entry) + entry->header.a_text
  	     + entry->header.a_data + entry->header.a_trsize,
  	     L_SET);
- #endif WITH_PERPROCESS_VARIABLES
        if (entry->header.a_drsize != read (desc, reloc, entry->header.a_drsize))
- #ifdef WITH_PERPROCESS_VARIABLES
- 	fatal_with_file ("premature eof in data relocation of ", entry);
- #else WITH_PERPROCESS_VARIABLES
  	fatal_with_file ("premature eof in text relocation of ", entry);
- #endif WITH_PERPROCESS_VARIABLES
-       WHEN_BYTE_SWAPPING(unbyte_swap_relocation_info(reloc, 
- 			     reloc + 
- 			     (entry->header.a_drsize / sizeof (struct relocation_info)));)
- 
        entry->datarel = reloc;
      }
- 
- #ifdef WITH_PERPROCESS_VARIABLES
-   if (!entry->perprocessrel)
-     {
-       reloc = (struct relocation_info *) xmalloc (entry->header.a_prsize);
-       if (desc == -1) desc = file_open (entry);
-       lseek (desc, entry->starting_offset + N_PRELOFF(entry->header), L_SET);
-       if (entry->header.a_prsize != read (desc, reloc, entry->header.a_prsize))
- 	fatal_with_file ("premature eof in perprocess relocation of ", entry);
-       WHEN_BYTE_SWAPPING(unbyte_swap_relocation_info(reloc, 
- 			     reloc + 
- 			     (entry->header.a_prsize / sizeof (struct relocation_info)));)
- 
-       entry->perprocessrel = reloc;
-     }
- #endif WITH_PERPROCESS_VARIABLES
- 
  }
  
  /* Read the text segment contents of ENTRY, relocate them,
--- 3241,3254 ----
***************
*** 3999,4015 ****
    else
      {
        reloc = (struct relocation_info *) alloca (entry->header.a_trsize);
- #ifdef WITH_PERPROCESS_VARIABLES
-       lseek (desc, entry->starting_offset + N_TRELOFF(entry->header), 0);
- #else WITH_PERPROCESS_VARIABLES
        lseek (desc, text_offset (entry) + entry->header.a_text + entry->header.a_data, 0);
- #endif WITH_PERPROCESS_VARIABLES
- 
        if (entry->header.a_trsize != read (desc, reloc, entry->header.a_trsize))
  	fatal_with_file ("premature eof in text relocation of ", entry);
-       WHEN_BYTE_SWAPPING(unbyte_swap_relocation_info(reloc, 
- 			       reloc + 
- 			       (entry->header.a_trsize / sizeof (struct relocation_info)));)
      }
  
    /* Read the text section into core.  */
--- 3283,3291 ----
***************
*** 4054,4076 ****
    padfile (data_pad, outdesc);
  }
  
- #ifdef WITH_PERPROCESS_VARIABLES
- void
- write_perprocess ()
- {
-   if (trace_files)
-     fprintf (stderr, "Copying and relocating perprocess:\n\n");
- 
-   each_full_file (copy_perprocess);
-   file_close ();
- 
-   if (trace_files)
-     fprintf (stderr, "\n");
- 
-   padfile (perprocess_pad, outdesc);
- }
- #endif WITH_PERPROCESS_VARIABLES
- 
  /* Read the data segment contents of ENTRY, relocate them,
     and write the result to the output file.
     If `-r', save the data relocation for later reuse.
--- 3330,3335 ----
***************
*** 4100,4117 ****
    else
      {
        reloc = (struct relocation_info *) alloca (entry->header.a_drsize);
- #ifdef WITH_PERPROCESS_VARIABLES
-       lseek (desc, entry->starting_offset + N_DRELOFF(entry->header), 0);
- #else
        lseek (desc, text_offset (entry) + entry->header.a_text
  	     + entry->header.a_data + entry->header.a_trsize,
  	     0);
- #endif WITH_PERPROCESS_VARIABLES
        if (entry->header.a_drsize != read (desc, reloc, entry->header.a_drsize))
  	fatal_with_file ("premature eof in data relocation of ", entry);
-       WHEN_BYTE_SWAPPING(un_byte_swap_relocation_info(reloc, 
- 			       reloc + 
- 			       (entry->header.a_drsize / sizeof (struct relocation_info)));)
      }
  
    lseek (desc, text_offset (entry) + entry->header.a_text, 0);
--- 3359,3369 ----
***************
*** 4123,4178 ****
  
    mywrite (bytes, 1, entry->header.a_data, outdesc);
  }
- 
- #ifdef WITH_PERPROCESS_VARIABLES
- void
- copy_perprocess (entry)
-      struct file_entry *entry;
- {
-   register struct relocation_info *reloc;
-   register char *bytes;
-   register int desc;
- 
-   if (trace_files)
-     prline_file_name (entry, stderr);
- 
-   desc = file_open (entry);
- 
-   bytes = (char *) alloca (entry->header.a_perprocess);
- 
-   if (entry->perprocessrel) reloc = entry->perprocessrel;
-   else if (relocatable_output)	/* Will need this again */
-     {
-       read_file_relocation (entry);
-       reloc = entry->perprocessrel;
-     }
-   else
-     {
-       reloc = (struct relocation_info *) 
- 	alloca (entry->header.a_prsize);
-       lseek (desc, entry->starting_offset + N_PRELOFF(entry->header), 0);
-       if (entry->header.a_prsize != read (desc, reloc, entry->header.a_prsize))
- 	fatal_with_file ("premature eof in perprocess relocation of ", entry);
-     }
- 
-   lseek (desc, entry->starting_offset + N_PEROFF(entry->header), 0);
-   if (entry->header.a_perprocess != read (desc, bytes, entry->header.a_perprocess))
-     fatal_with_file ("premature eof in perprocess section of ", entry);
- 
- /*
- ** This call is confusing in the perprocess case.
- ** I hope that it's correct.
- */
-   perform_relocation (bytes, 
- 		      entry->perprocess_start_address - 
- 		      (entry->header.a_text + entry->header.a_data),
- 		       entry->header.a_perprocess, reloc, 
- 		       entry->header.a_prsize, entry);
- 
-   mywrite (bytes, 1, entry->header.a_perprocess, outdesc);
- }
- #endif WITH_PERPROCESS_VARIABLES
- 
  
  /* Relocate ENTRY's text or data section contents.
     DATA is the address of the contents, in core.
--- 3375,3380 ----
***************
*** 4199,4220 ****
    int data_relocation = entry->data_start_address - entry->header.a_text;
    int bss_relocation
      = entry->bss_start_address - entry->header.a_text - entry->header.a_data;
- #ifdef WITH_PERPROCESS_VARIABLES
- /*
- ** Since perprocess and perprocess bss data are accessed through the
- ** perprocess segment pointer with an offset, the relocation is the
- ** amount of perprocess data that comes before this segment where in the
- ** original object file the perprocess segment started here (ie. no 
- ** perprocess data came before this).
- */
-   int perprocess_relocation = entry->perprocess_start_address 
-     - perprocess_start;
-     
-   int perprocess_bss_relocation
-     = (entry->perprocess_bss_start_address 
-       - perprocess_start)
-       - entry->header.a_perprocess;
- #endif WITH_PERPROCESS_VARIABLES
  
    for (; p < end; p++)
      {
--- 3401,3406 ----
***************
*** 4269,4292 ****
  	     initially contains the length of text plus data of the file.  */
  	  relocation = bss_relocation;
  	  break;
- #ifdef WITH_PERPROCESS_VARIABLES
- 	case N_PERPROCESS:
- 	case N_PERPROCESS | N_EXT:
- 	  /* A word that points to beginning of the the perprocess section
- 	     initially contains 0.  Right now, I'm not sure how it should
- 	     be relocated.*/
- 	  relocation = perprocess_relocation;
- 	  break;
  
- 	case N_PERPROCESS_BSS:
- 	case N_PERPROCESS_BSS | N_EXT:
- 	  /* Similarly, an input word pointing to the beginning of the 
- 	     perprocess bss
- 	     initially contains the length of the perprocess segment. */
- 	  relocation = perprocess_bss_relocation;
- 	  break;
- #endif WITH_PERPROCESS_VARIABLES
- 
  	case N_ABS:
  	case N_ABS | N_EXT:
  	  /* Don't know why this code would occur, but apparently it does.  */
--- 3455,3461 ----
***************
*** 4317,4325 ****
        switch (RELOC_TARGET_SIZE(p))
  	{
  	case 0:
- 	  /*
- 	  ** A single byte does not need to be byte swapped.
- 	  */
  	  if (RELOC_MEMORY_ADD_P(p))
  	    relocation += mask & *(char *) (data + addr);
  	  *(char *) (data + addr) &= ~mask;
--- 3486,3491 ----
***************
*** 4327,4353 ****
  	  break;
  
  	case 1:
- 	  /*
- 	  ** A short DOES need to be byte swapped.
- 	  */
- 	  WHEN_BYTE_SWAPPING(byte_swap_short_in_place((short *) (data + addr), sizeof (short));)
  	  if (RELOC_MEMORY_ADD_P(p))
  	    relocation += mask & *(short *) (data + addr);
  	  *(short *) (data + addr) &= ~mask;
  	  *(short *) (data + addr) |= relocation;
- 	  WHEN_BYTE_SWAPPING(byte_swap_short_in_place((short *) (data + addr), sizeof (short));)
  	  break;
  
  	case 2:
- 	  /*
- 	  ** A long DOES need to be byte swapped.
- 	  */
- 	  WHEN_BYTE_SWAPPING(byte_swap_long_in_place((long *) (data + addr), sizeof (long));)
  	  if (RELOC_MEMORY_ADD_P(p))
  	    relocation += mask & *(long *) (data + addr);
  	  *(long *) (data + addr) &= ~mask;
  	  *(long *) (data + addr) |= relocation;
- 	  WHEN_BYTE_SWAPPING(byte_swap_long_in_place((long *) (data + addr), sizeof (long));)
  	  break;
  
  	default:
--- 3493,3509 ----
***************
*** 4360,4368 ****
     relocating the addresses-to-be-relocated.  */
  
  void coptxtrel (), copdatrel ();
- #ifdef WITH_PERPROCESS_VARIABLES
- void copperprocessrel();
- #endif WITH_PERPROCESS_VARIABLES
  
  void
  write_rel ()
--- 3516,3521 ----
***************
*** 4406,4419 ****
  
    each_full_file (copdatrel);
  
- #ifdef WITH_PERPROCESS_VARIABLES
    if (trace_files)
-     fprintf (stderr, "\nWriting perprocess relocation:\n\n");
- 
-   each_full_file (copperprocessrel);
- #endif WITH_PERPROCESS_VARIABLES
- 
-   if (trace_files)
      fprintf (stderr, "\n");
  }
  
--- 3559,3565 ----
***************
*** 4511,4525 ****
  	   symtype = symptr->defined & N_TYPE;
  
  	  if (force_common_definition
- #ifdef WITH_PERPROCESS_VARIABLES
- /*
- ** I don't even know if the perprocess case can 
- ** occur here.
- */
- 	     || symtype == N_PERPROCESS || symtype == N_DATA || symtype == N_TEXT || symtype == N_ABS)
- #else  WITH_PERPROCESS_VARIABLES
  	      || symtype == N_DATA || symtype == N_TEXT || symtype == N_ABS)
- #endif WITH_PERPROCESS_VARIABLES
  	    {
  	      RELOC_EXTERN_P(p) = 0;
  	      RELOC_SYMBOL(p) = symtype;
--- 3657,3663 ----
***************
*** 4541,4604 ****
      }
    mywrite (entry->datarel, 1, entry->header.a_drsize, outdesc);
  }
- #ifdef WITH_PERPROCESS_VARIABLES
- void
- copperprocessrel (entry)
-      struct file_entry *entry;
- {
-   register struct relocation_info *p, *end;
-   /* Relocate the address of the relocation.
-      Old address is relative to start of the input file's data section.
-      New address is relative to start of the output file's data section.  */
- /*
- ** This looks very wrong. What should go here?
- ** This could bear investigating.  How can this work?
- **
- */
-   register int reloc = entry->data_start_address - text_size;
- 
-   p = entry->perprocessrel;
-   end = (struct relocation_info *) 
-     (entry->header.a_prsize + (char *) p);
-   while (p < end)
-     {
-       RELOC_ADDRESS(p) += reloc;
-       if (RELOC_EXTERN_P(p))
- 	{
- 	  register int symindex = RELOC_SYMBOL(p) * sizeof (struct nlist);
- 	  symbol *symptr = ((symbol *)
- 			    (((struct nlist *)
- 			      (((char *)entry->symbols) + symindex))
- 			     ->n_un.n_name));
- 	  int symtype = symptr->defined & N_TYPE;
- 
- 	  if (symindex >= entry->header.a_syms)
- 	    fatal_with_file ("relocation symbolnum out of range in ", entry);
- 	  if (force_common_definition
- 	      || symtype == N_PERPROCESS 
- 	      || symtype == N_DATA || symtype == N_TEXT || symtype == N_ABS)
- 	    {
- 	      RELOC_EXTERN_P(p) = 0;
- 	      RELOC_SYMBOL(p) = symtype;
- 	    }
- 	  else
- 	    RELOC_SYMBOL(p)
- 	      = (((symbol *)
- 		  (((struct nlist *)
- 		    (((char *)entry->symbols) + symindex))
- 		   ->n_un.n_name))
- 		 ->def_count
- 		 + nsyms - defined_global_sym_count
- 		 - undefined_global_sym_count);
- 	}
-       p++;
-     }
-   mywrite (entry->perprocessrel, 1, 
- 	   entry->header.a_perprocess, outdesc);
- }
- 
- #endif WITH_PERPROCESS_VARIABLES
- 
  
  void write_file_syms ();
  void write_string_table ();
--- 3679,3684 ----
***************
*** 4804,4810 ****
    /* Output the buffer full of `struct nlist's.  */
  
    lseek (outdesc, symbol_table_offset + symbol_table_len, 0);
-   WHEN_BYTE_SWAPPING(byte_swap_nlist_array(buf, bufp - buf);)
    mywrite (buf, sizeof (struct nlist), bufp - buf, outdesc);
    symbol_table_len += sizeof (struct nlist) * (bufp - buf);
  
--- 3884,3889 ----
***************
*** 4817,4825 ****
    /* Now the total string table size is known, so write it.
       We are already positioned at the right place in the file.  */
  
-   WHEN_BYTE_SWAPPING(byte_swap_long_in_place(&strtab_size, sizeof strtab_size);)
    mywrite (&strtab_size, sizeof (int), 1, outdesc);  /* we're at right place */
-   WHEN_BYTE_SWAPPING(byte_swap_long_in_place(&strtab_size, sizeof strtab_size);)
  
    /* Write the strings for the global symbols.  */
  
--- 3896,3902 ----
***************
*** 4929,4935 ****
    /* All the symbols are now in BUF; write them.  */
  
    lseek (outdesc, symbol_table_offset + symbol_table_len, 0);
-   WHEN_BYTE_SWAPPING(byte_swap_nlist_array(buf, bufp - buf);)
    mywrite (buf, sizeof (struct nlist), bufp - buf, outdesc);
    symbol_table_len += sizeof (struct nlist) * (bufp - buf);
  
--- 4006,4011 ----
***************
*** 4952,4958 ****
    each_file (write_file_symseg, 0);
  }
  
- 
  void
  write_file_symseg (entry)
       struct file_entry *entry;
--- 4028,4033 ----
***************
*** 4979,5001 ****
    root.datarel = entry->data_start_address - entry->header.a_text;
    root.bssrel = entry->bss_start_address
      - entry->header.a_text - entry->header.a_data;
- #ifdef WITH_PERPROCESS_VARIABLES
- /*
- ** I don't think that this code has every be executed so far.
- ** I really don't have any idea of what it all is supposed to
- ** do.
- */
-    root.perprocessrel = entry->perprocess_start_address
-     - entry->header.a_text - entry->header.a_data 
-       - entry->header.a_bss;
- 
-   root.perprocessbssrel = entry->perprocess_bss_start_address
-     - entry->header.a_text 
-       - entry->header.a_data 
- 	- entry->header.a_bss
- 	  - entry->header.a_perprocess;
- #endif WITH_PERPROCESS_VARIABLES
- 
    root.databeg = entry->data_start_address - root.datarel;
    root.bssbeg = entry->bss_start_address - root.bssrel;
  
--- 4054,4059 ----
***************
*** 5038,5046 ****
  }
  
  /* Create the symbol table entries for `etext', `edata' and `end'.  */
- #ifdef WITH_PERPROCESS_VARIABLES
- /* and 'ebss' and 'eperprocess'. */
- #endif WITH_PERPROCESS_VARIABLES
  
  void
  symtab_init ()
--- 4096,4101 ----
***************
*** 5048,5085 ****
  #ifndef nounderscore
    edata_symbol = getsym ("_edata");
    etext_symbol = getsym ("_etext");
- #ifdef WITH_PERPROCESS_VARIABLES
-   ebss_symbol = getsym ("_ebss");
-   eperprocess_symbol = getsym ("_eperprocess");
- #endif WITH_PERPROCESS_VARIABLES
    end_symbol = getsym ("_end");
  #else
    edata_symbol = getsym ("edata");
    etext_symbol = getsym ("etext");
- #ifdef WITH_PERPROCESS_VARIABLES
-   ebss_symbol = getsym ("ebss");
-   eperprocess_symbol = getsym ("eperprocess");
- #endif WITH_PERPROCESS_VARIABLES
    end_symbol = getsym ("end");
  #endif
  
    edata_symbol->defined = N_DATA | N_EXT;
    etext_symbol->defined = N_TEXT | N_EXT;
- 
- #ifdef WITH_PERPROCESS_VARIABLES
-   ebss_symbol->defined = N_BSS | N_EXT;
-   eperprocess_symbol->defined = N_PERPROCESS | N_EXT;
-   end_symbol->defined = N_PERPROCESS_BSS | N_EXT;
- #else
    end_symbol->defined = N_BSS | N_EXT;
- #endif WITH_PERPROCESS_VARIABLES
  
    edata_symbol->referenced = 1;
    etext_symbol->referenced = 1;
- #ifdef WITH_PERPROCESS_VARIABLES
-   ebss_symbol->referenced = 1;
-   eperprocess_symbol->referenced = 1;
- #endif WITH_PERPROCESS_VARIABLES
    end_symbol->referenced = 1;
  }
  
--- 4103,4121 ----
***************
*** 5363,5367 ****
  }
  
  #endif
- 
- 
--- 4399,4401 ----
*** /xxV/cmds/gld/pgld/mi/symseg.h	Wed Sep 13 17:30:35 1989
--- /xxV/cmds/gld/dist/symseg.h	Tue Aug  8 14:42:05 1989
***************
*** 77,86 ****
    int textrel;			/* Relocation for text addresses */
    int datarel;			/* Relocation for data addresses */
    int bssrel;			/* Relocation for bss addresses */
- #ifdef WITH_PERPROCESS_VARIABLES
-   int perprocessrel;		/* Relocation for perprocess addresses */
-   int perprocessbssrel;         /* Relocation for perprocess bss addresses */
- #endif WITH_PERPROCESS_VARIABLES
    char *filename;		/* Name of main source file compiled */
    char *filedir;		/* Name of directory it was reached from */
    struct blockvector *blockvector; /* Vector of all symbol-naming blocks */
--- 77,82 ----
--
Peter Ham			PO Box 3430	(h)(415) 324-9645
MS Computer Science Student	Stanford, CA	ham@polya.stanford.edu
Stanford University 		94309		(o)(415) 723-2067