patch for binutils include/ansidecl.h.

Nathan Tallent eraxxon@alumni.rice.edu
Fri Sep 20 14:29:00 GMT 2002


What follows is a patch for binutils include/ansidecl.h.
-Nathan Tallent

Description:
------------

After a few miserable hours, I finally figured out why including <bfd.h> 
in my C++ code caused a whole slew of inexplicable and mysterious errors 
-- but only on the Compaq compiler.  It was the macro magic of 
ansidecl.h. (Live by the sword, die by the sword.)  I think this patch 
is reasonably general and I consulted the documentation for compiler 
versions 5.7, 6.2, 6.3, 6.5.

Testing and testcases:
----------------------
I have run the binutils regression tests with and without my changes and
the results are the same.

Our tests: We are using bintuils as the binary reader for a program
that performs source code structure recovery on binaries from a number 
of different platforms.  (We esp. focus on loop recovery for scientific
programs.) This program is also a cross-tool and we have successfully
tested these changes (and a number of others to follow eventually) on a
number of different binaries (from GNU and non-GNU compilers) and
platforms.

hosts (all of which are enabled on each platform)
   mips64-sgi-irix6
   alpha-*-linux-gnu, alpha-*-osf
   sparc32-*-elf, sparc64-*-solaris2
   i386-*-linux-gnu
   ia64-*-linux-gnu

ChangeLog:
----------

2002-09-20  Nathan Tallent  <eraxxon@alumni.rice.edu>

	* ansidecl.h [__STDC__]: The Compaq C++ compiler, unlike many
	other C++ compilers, does not define __STDC__, though it acts as
	if this was so.  Add (__alpha && __cplusplus) to the list of
	platform compilers that may look, smell and act like __STDC__
	but that may not define it.

Patch: include/ansidecl.h
(created with 'cvs diff -c3p' against cvs repository on 9/20/02)
------

Index: ansidecl.h
===================================================================
RCS file: /cvs/src/src/include/ansidecl.h,v
retrieving revision 1.10
diff -c -3 -p -r1.10 ansidecl.h
*** ansidecl.h	29 Aug 2001 20:03:08 -0000	1.10
--- ansidecl.h	20 Sep 2002 18:16:10 -0000
*************** So instead we use the macro below and te
*** 136,145 ****
   #define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__)
   #endif /* GCC_VERSION */

! #if defined (__STDC__) || defined (_AIX) || (defined (__mips) && 
defined (_SYSTYPE_SVR4)) || defined(_WIN32)
   /* All known AIX compilers implement these things (but don't always
      define __STDC__).  The RISC/OS MIPS compiler defines these things
      in SVR4 mode, but does not define __STDC__.  */

   #define ANSI_PROTOTYPES	1
   #define PTR		void *
--- 136,148 ----
   #define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__)
   #endif /* GCC_VERSION */

! #if defined (__STDC__) || defined (_AIX) || (defined (__mips) && 
defined (_SYSTYPE_SVR4)) || defined(_WIN32) || (defined(__alpha) && 
defined(__cplusplus))
   /* All known AIX compilers implement these things (but don't always
      define __STDC__).  The RISC/OS MIPS compiler defines these things
      in SVR4 mode, but does not define __STDC__.  */
+ /* eraxxon@alumni.rice.edu: The Compaq C++ compiler, unlike many other
+    C++ compilers, does not define __STDC__, though it acts as if this
+    was so. (Verified versions: 5.7, 6.2, 6.3, 6.5) */

   #define ANSI_PROTOTYPES	1
   #define PTR		void *



More information about the Binutils mailing list