This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
ia64 patch for C++ gprel link errors
- To: gcc at gcc dot gnu dot org
- Subject: ia64 patch for C++ gprel link errors
- From: Jim Wilson <wilson at cygnus dot com>
- Date: Thu, 16 Nov 2000 12:12:41 -0800
This fixes a problem where some C++ programs gave gprel relocation errors at
link time. The problem was that we were sometimes treating class local static
variables as own-data (i.e. putting them in sdata) when it was not safe to do
so. If a file defines a class local static variable, but does not initialize
it, then both TREE_STATIC and DECL_EXTERNAL are set. This is a situation
that doesn't happen in the C front end. In this case, we can't put a decl
in sdata because there is no guarantee that the file that defines and
initalizes the variable will put it in sdata.
2000-11-16 Jim Wilson <wilson@redhat.com>
* config/ia64/ia64.c (ia64_encode_section_info): Disallow decls with
DECL_EXTERNAL set.
Index: ia64.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/config/ia64/ia64.c,v
retrieving revision 1.71.2.15
diff -p -r1.71.2.15 ia64.c
*** ia64.c 2000/10/23 23:45:00 1.71.2.15
--- ia64.c 2000/11/16 06:00:01
*************** ia64_encode_section_info (decl)
*** 4418,4425 ****
/* ??? Actually, we can put globals in sdata, as long as we don't use gprel
to access them. The linker may then be able to do linker relaxation to
optimize references to them. Currently sdata implies use of gprel. */
if (! TARGET_NO_SDATA
! && TREE_STATIC (decl)
&& ! (DECL_ONE_ONLY (decl) || DECL_WEAK (decl))
&& ! (TREE_PUBLIC (decl)
&& (flag_pic
--- 4418,4429 ----
/* ??? Actually, we can put globals in sdata, as long as we don't use gprel
to access them. The linker may then be able to do linker relaxation to
optimize references to them. Currently sdata implies use of gprel. */
+ /* We need the DECL_EXTERNAL check for C++. static class data members get
+ both TREE_STATIC and DECL_EXTERNAL set, to indicate that they are
+ statically allocated, but the space is allocated somewhere else. Such
+ decls can not be own data. */
if (! TARGET_NO_SDATA
! && TREE_STATIC (decl) && ! DECL_EXTERNAL (decl)
&& ! (DECL_ONE_ONLY (decl) || DECL_WEAK (decl))
&& ! (TREE_PUBLIC (decl)
&& (flag_pic