This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Patch for PIC mode on IA64 (fixes libgomp failures on HP-UX)
- From: Steve Ellcey <sje at cup dot hp dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: wilson at tuliptree dot org
- Date: Tue, 29 Jul 2008 13:22:54 -0700 (PDT)
- Subject: Patch for PIC mode on IA64 (fixes libgomp failures on HP-UX)
- Reply-to: sje at cup dot hp dot com
This patch is to set flag_pic by default on IA64. We claim to generate
pic code by default on IA64 but we don't actually set flag_pic like
other platforms do. Normally this doesn't matter, but flag_pic is used
to set flag_shlib and flag_shlib is used to set the default thread
local storage model.
On IA64 HP-UX the shared libgomp was getting built with the static
TLS model and causing test failures when used. The static TLS model was
being used because libtool thought GCC on IA64 HP-UX was generating
PIC code by default and thus didn't specify the -fpic flag when building
objects for shared libraries. For some reason libtool does use -fpic
when generating IA64 Linux objects for shared libraries.
Anyway, I think setting the pic flag (and shlib flag) by default
on IA64 is the best solution for this issue since are supposed to be
generating PIC code by default anyway. On Linux this will generate some
slower code for TLS data because it will use the dynamic model instead of
the static model by default and because it will put all relocations in
read-write segments instead of putting relocations for local data into
shared read-only segments. HP-UX was already putting the relocations
into read-write segments.
Tested on IA64 HP-UX and Linux. OK for checkin?
Steve Ellcey
sje@cup.hp.com
2008-07-29 Steve Ellcey <sje@cup.hp.com>
* config/ia64/hpux.h (TARGET_ASM_RELOC_RW_MASK): Remove.
* config/ia64/ia64.h (LEGITIMIZE_PIC_OPERAND_P): Remove.
* config/ia64/ia64.c (ia64_hpux_reloc_rw_mask): Remove.
(ia64_override_options): Set flag_pic and flag_shlib.
(ia64_reloc_rw_mask): Put all relocs in read-write segments.
Index: config/ia64/hpux.h
===================================================================
--- config/ia64/hpux.h (revision 138226)
+++ config/ia64/hpux.h (working copy)
@@ -171,11 +171,6 @@ do { \
#undef TEXT_SECTION_ASM_OP
#define TEXT_SECTION_ASM_OP "\t.section\t.text,\t\"ax\",\t\"progbits\""
-/* It is illegal to have relocations in shared segments on HPUX.
- Pretend flag_pic is always set. */
-#undef TARGET_ASM_RELOC_RW_MASK
-#define TARGET_ASM_RELOC_RW_MASK ia64_hpux_reloc_rw_mask
-
/* ia64 HPUX has the float and long double forms of math functions. */
#undef TARGET_C99_FUNCTIONS
#define TARGET_C99_FUNCTIONS 1
Index: config/ia64/ia64.h
===================================================================
--- config/ia64/ia64.h (revision 138226)
+++ config/ia64/ia64.h (working copy)
@@ -1415,9 +1415,6 @@ do { \
/* ??? Should modify ia64.md to use pic_offset_table_rtx instead of
gen_rtx_REG (DImode, 1). */
-/* ??? Should we set flag_pic? Probably need to define
- LEGITIMIZE_PIC_OPERAND_P to make that work. */
-
#define PIC_OFFSET_TABLE_REGNUM GR_REG (1)
/* Define this macro if the register defined by `PIC_OFFSET_TABLE_REGNUM' is
Index: config/ia64/ia64.c
===================================================================
--- config/ia64/ia64.c (revision 138226)
+++ config/ia64/ia64.c (working copy)
@@ -255,7 +255,6 @@ static void ia64_output_mi_thunk (FILE *
static void ia64_file_start (void);
static void ia64_globalize_decl_name (FILE *, tree);
-static int ia64_hpux_reloc_rw_mask (void) ATTRIBUTE_UNUSED;
static int ia64_reloc_rw_mask (void) ATTRIBUTE_UNUSED;
static section *ia64_select_rtx_section (enum machine_mode, rtx,
unsigned HOST_WIDE_INT);
@@ -5232,6 +5231,11 @@ ia64_override_options (void)
if (TARGET_AUTO_PIC)
target_flags |= MASK_CONST_GP;
+ flag_pic = 2;
+ if (!flag_pie)
+ flag_shlib = 1;
+
+
if (TARGET_INLINE_SQRT == INL_MIN_LAT)
{
warning (0, "not yet implemented: latency-optimized inline square root");
@@ -9486,22 +9490,14 @@ ia64_sysv4_init_libfuncs (void)
glibc doesn't have them. */
}
-/* For HPUX, it is illegal to have relocations in shared segments. */
-
-static int
-ia64_hpux_reloc_rw_mask (void)
-{
- return 3;
-}
-
-/* For others, relax this so that relocations to local data goes in
- read-only segments, but we still cannot allow global relocations
- in read-only segments. */
+/* For HPUX, it is illegal to have relocations in shared segments,
+ for others, it is allowed by we don't do it because we set flag_pic
+ to 2 by default anyway. */
static int
ia64_reloc_rw_mask (void)
{
- return flag_pic ? 3 : 2;
+ return 3;
}
/* Return the section to use for X. The only special thing we do here