From: cph@martigny.ai.mit.edu (Chris Hanson)
Subject: gas compile bug? under hp-ux
Organization: GNUs Not Usenet
Distribution: gnu
Date: Thu, 20 Aug 1992 09:14:33 GMT

   Date: Thu, 13 Aug 1992 16:00:00 +0000 
   From: "Jeff (J.) Hayes" <jjhayes@x400gate.bnr.ca>

   I have sent this to Chris Hanson as he appeared to be the author
   of the hpux mods, and twice as he is given 2 diff addr's in the
   ChangeLog file.

   hope you don't mind chris.

   on to the bug report:
   A description of exactly what went wrong.

   [...]

   /*  the issue here is that EXEC_MACHINE_TYPE exposes   the_exec.a_machtype
   to the compiler which is also undefined.
   I was able to follow the "struct exec" typedef in a.out.gnu.h but got lost
   in the macros.  is there a macro resolving .a_machtyp to one of the 
   defined fields?

   i also noted that EXEC_VERSION on the lines following is only def'd in the
   Makefile for Sequent machines - this leads my to believe there should have
   been some kind of -DHP9000S200_ID=??? switch to define its value.
   */

   so can you help me out?

   jeff hayes                (416) 452-3894         ESN 333-3894
			     Northern Telecom, Public Switching Division 
   jjhayes@400gate.bnr.ca    Product Technology, Bramalea Ont Can

Fortunately, this bug has occurred before.  Here's what's wrong: HP-UX
needs a special a.out.h file, called "a.out.hpux.h", and
"struc-symbol.h" needs to be modified to use it.  This code was
mistakenly removed from GAS for the 1.38 release.  Here it is:


*** struc-symbol.h.~1~	Fri Jul  6 14:43:12 1990
--- struc-symbol.h	Thu Sep  5 19:29:55 1991
***************
*** 17,26 ****
  along with GAS; see the file COPYING.  If not, write to
  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  
! #ifndef		VMS
! #include "a.out.gnu.h"		/* Needed to define struct nlist. Sigh. */
  #else
  #include "a_out.h"
  #endif
  
  struct symbol			/* our version of an nlist node */
--- 17,31 ----
  along with GAS; see the file COPYING.  If not, write to
  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  
! /* Needed to define struct nlist. Sigh. */
! #ifdef hpux
! #include "a.out.hpux.h"
  #else
+ #ifndef VMS
+ #include "a.out.gnu.h"
+ #else
  #include "a_out.h"
+ #endif
  #endif
  
  struct symbol			/* our version of an nlist node */


----------------------- a.out.hpux.h ---------------------------
/* Special version of <a.out.h> for use under hp-ux.
   Copyright (C) 1988 Free Software Foundation, Inc.

   This file is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 1, or (at your option)
   any later version.

   This file is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this file; if not, write to the Free Software
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */

/* The `exec' structure and overall layout must be close to HP's when
   we are running on an HP system, otherwise we will not be able to
   execute the resulting file. */

/* Allow this file to be included twice. */
#ifndef __GNU_EXEC_MACROS__

struct exec
{
  unsigned short a_machtype;	/* machine type */
  unsigned short a_info;	/* magic number */
  unsigned long a_spare1;
  unsigned long a_spare2;
  unsigned long a_text;		/* length of text, in bytes */
  unsigned long a_data;		/* length of data, in bytes */
  unsigned long a_bss;		/* length of uninitialized data area for file, in bytes */
  unsigned long a_trsize;	/* length of relocation info for text, in bytes */
  unsigned long a_drsize;	/* length of relocation info for data, in bytes */
  unsigned long a_spare3;	/* HP = pascal interface size */
  unsigned long a_spare4;	/* HP = symbol table size */
  unsigned long a_spare5;	/* HP = debug name table size */
  unsigned long a_entry;	/* start address */
  unsigned long a_spare6;	/* HP = source line table size */
  unsigned long a_spare7;	/* HP = value table size */
  unsigned long a_syms;		/* length of symbol table data in file, in bytes */
  unsigned long a_spare8;
};

/* Tell a.out.gnu.h not to define `struct exec'.  */
#define __STRUCT_EXEC_OVERRIDE__

#include "a.out.gnu.h"

#undef N_MAGIC
#undef N_MACHTYPE
#undef N_FLAGS
#undef N_SET_INFO
#undef N_SET_MAGIC
#undef N_SET_MACHTYPE
#undef N_SET_FLAGS

#define N_MAGIC(exec) ((exec) . a_magic)
#define N_MACHTYPE(exec) ((exec) . a_machtype)
#define N_SET_MAGIC(exec, magic) (((exec) . a_magic) = (magic))
#define N_SET_MACHTYPE(exec, machtype) (((exec) . a_machtype) = (machtype))

#undef N_BADMAG
#define N_BADMAG(x) ((_N_BADMAG (x)) || (_N_BADMACH (x)))

#define _N_BADMACH(x)							\
(((N_MACHTYPE (x)) != HP9000S200_ID) &&					\
 ((N_MACHTYPE (x)) != HP98x6_ID))

#define HP98x6_ID 0x20A
#define HP9000S200_ID 0x20C

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

#define SEGMENT_SIZE 0x1000

#endif /* __GNU_EXEC_MACROS__ */

Newsgroups: gnu.utils.bug