This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

AIX/g++ const structs containing function addresses fail.


Description:

	const structs containing function pointers generate a csect
	with the [RO] attribute which wind up in the .text section.
	This puts relocatable info in the .text section and the
	linker complains because that won't work in a shared object
	environment.

	The fix shown below is REALLY gross.  The constant (138)
was
	determined in a debugging session and the matching symbol
	determined later.  I didn't know how to use the symbol in
	varasm.c since it was defined in the g++ stuff in the 'cp'
	subdirectory.


Compiler command line/version:
	bash$ g++ -v -S RObug.cc 
	Reading specs from
/usr/local/lib/gcc-lib/powerpc-ibm-aix4.3.2.0/2.95/specs
	gcc version 2.95 19990728 (release)
	 /usr/local/lib/gcc-lib/powerpc-ibm-aix4.3.2.0/2.95/cpp
-lang-c++ -v -D__GNUC__=
	2 -D__GNUG__=2 -D__GNUC_MINOR__=95 -D__cplusplus -D_IBMR2
-D_POWER -D_AIX -D_AIX
	32 -D_AIX41 -D_AIX43 -D_LONG_LONG -D_IBMR2 -D_POWER -D_AIX
-D_AIX32 -D_AIX41 -D_
	AIX43 -D_LONG_LONG -Asystem(unix) -Asystem(aix)
-D__EXCEPTIONS -D__CHAR_UNSIGNED
	__ -D_ARCH_COM RObug.cc /tmp/cciI4kzb.ii
	GNU CPP version 2.95 19990728 (release)
	#include "..." search starts here:
	#include <...> search starts here:
	
/usr/local/lib/gcc-lib/powerpc-ibm-aix4.3.2.0/2.95/../../../../include/g++-3
	 /usr/local/include
	
/usr/local/lib/gcc-lib/powerpc-ibm-aix4.3.2.0/2.95/../../../../powerpc-ibm-aix4
	.3.2.0/include
	 /usr/local/lib/gcc-lib/powerpc-ibm-aix4.3.2.0/2.95/include
	 /usr/include
	End of search list.
	The following default directories have been omitted from
the search path:
	End of omitted list.
	 /usr/local/lib/gcc-lib/powerpc-ibm-aix4.3.2.0/2.95/cc1plus
/tmp/cciI4kzb.ii -qu
	iet -dumpbase RObug.cc -version -o RObug.s
	GNU C++ version 2.95 19990728 (release)
(powerpc-ibm-aix4.3.2.0) compiled by GNU
	 C version 2.95 19990728 (release).


System/OS:

	IBM/PowerSeries850  AIX 4.3.3

Testcase: (this has been pre-processed and reduced)

	begin 644 RObug.cc.gz

M'XL(".I]N#<"`U)/8G5G+F-C`&6,00J`(``$[[UB3U'1"Y3>(F8>I-1(#4+Z

M>VD%17N=G1$3=PY,&JDWQ#GTDQ($6*T:D*?M*EDON:YJBIT6SB]!>&2!C<H,
	HB->[NB*$-$FI<?\S>]`K%O="6.,^I430G<'R)[2I=0!@\?GBK0```&2!
	`
	end

	Unencoded RObug.cc:
	class _enemy {public:  void      move_beam(); };
	struct enemy_kind { void (_enemy::*move) (); };
	void _enemy::move_beam(){}
	const enemy_kind beam = { &_enemy::move_beam, };

Failure:

	...
	.csect _RObug.ro_cc[RO],3        <<< This is the bad line
	        .align 2
	beam:
	        .short 0
	        .short -1
	        .long move_beam__6_enemy <<< This is relocated
	...

My fix:

	diff -r -c5 -p gcc-2.95/gcc/varasm.c
my-gcc-2.95/gcc/varasm.c
	*** gcc-2.95/gcc/varasm.c       Wed Jun  9 07:13:49 1999
	--- my-gcc-2.95/gcc/varasm.c    Tue Aug 17 16:47:23 1999
	*************** output_addressed_constants (exp)
	*** 3869,3878 ****
	--- 3869,3882 ----
	          if (TREE_VALUE (link) != 0)
	            reloc |= output_addressed_constants (TREE_VALUE
(link));
	        }
	        break;
	  
	+     case 138: /* PTRMEM_CST (cp/cp-tree.def) */
	+       reloc = 1; 
	+       break;
	+ 
	      default:
	        break;
	      }
	    return reloc;
	  }



<


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]