This is the mail archive of the
mailing list for the GCC project.
[committed] Fix mips-sgi-irix6.5 --without-gnu-ld bootstrap
- From: Richard Sandiford <rsandifo at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 07 Oct 2004 21:13:19 +0100
- Subject: [committed] Fix mips-sgi-irix6.5 --without-gnu-ld bootstrap
A bootstrap of mips-sgi-irix6.5 currently fails when using the MIPSpro
linker, which segfaults when trying to build the n64 version of the
libstdc++ shared library.
The immediate problem seems to have something do with the section names
that we're using for switch tables. As such, I think it was indirect
fallout from (but _not_ a bug in!) Jakub's function_rodata_section patch.
We're now putting the switch tables for one-only functions in sections
with names like:
and the segfault seems to depend on the length of such names.
Remove X characters from the name and it still fails. Remove X+1
and it works. It also works for plain .rdata, which is what we
used before Jakub's patch.
However, the underlying problem seems to be that we're putting absolute
addressees into a read-only section. Now we "have"[*] to use absolute
addresses for IRIX n64 because MIPSpro doesn't handle .gpdword (meaning that
the assembler doesn't provide the directive and that the linker mishandles
the relocations that gas generates for it). And while a segfault is hardly
helpful, I think this really is a bug in gcc. The patch below puts absolute
tables into the data section instead.
[ For n32, the gas/MIPSpro combination can handle .gpword quite happily,
so we don't need absolute addresses there. Even so, the same segfault
can be seen with the n32 linker if the .gpwords are changed to .words. ]
[*] I guess there are two points to make here:
(1) Using .gpdword (as we do on GNU/Linux) is overkill anyway.
The text section must be within 2GB of _gp, so it ought to be
possible to use .gpword instead. That's something we could do
for both GNU/Linux and IRIX (and hence clean up a bit of code).
Unfortunately, gas 2.15 mishandles .gpword/.8byte combinations
for n64, and such combinations are quite common when dwarf
output is enabled. Trying to use .gpword with 2.15 causes
a build failure for unwind-dw2.o.
I've just committed a fix for the binutils bug, but until
the next version of binutils is released, we should probably
stick to the existing scheme.
(2) Putting absolute addresses in a read-only section should be OK
if !flag_shlib. Unfortunately, libtool never passes -fpic or
-fPIC for IRIX, saying:
beos* | irix5* | irix6* | osf3* | osf4* | osf5*)
# PIC is the default for these OSes.
The comment is right in the flag_pic sense, but not in the
flag_shlib sense. That should be fixed (I'll deal with it
separately), but in the meantime, this patch doesn't check
Tested on mips-sgi-irix6.5. Applied to head.
* config/mips/mips.c (mips_function_rodata_section): New function.
(TARGET_ASM_FUNCTION_RODATA_SECTION): Use it.
RCS file: /cvs/gcc/gcc/gcc/config/mips/mips.c,v
retrieving revision 1.471
diff -c -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.471 mips.c
*** config/mips/mips.c 25 Sep 2004 07:42:38 -0000 1.471
--- config/mips/mips.c 7 Oct 2004 20:05:48 -0000
*************** static void mips_output_mi_thunk (FILE *
*** 292,297 ****
--- 292,298 ----
static int symbolic_expression_p (rtx);
static void mips_select_rtx_section (enum machine_mode, rtx,
+ static void mips_function_rodata_section (tree);
static bool mips_in_small_data_p (tree);
static int mips_fpr_return_fields (tree, tree *);
static bool mips_return_in_msb (tree);
*************** #define TARGET_ASM_FUNCTION_PROLOGUE mip
*** 722,727 ****
--- 723,730 ----
#define TARGET_ASM_FUNCTION_EPILOGUE mips_output_function_epilogue
#define TARGET_ASM_SELECT_RTX_SECTION mips_select_rtx_section
+ #undef TARGET_ASM_FUNCTION_RODATA_SECTION
+ #define TARGET_ASM_FUNCTION_RODATA_SECTION mips_function_rodata_section
#define TARGET_SCHED_REORDER mips_sched_reorder
*************** mips_select_rtx_section (enum machine_mo
*** 6574,6579 ****
--- 6577,6618 ----
+ /* Implement TARGET_ASM_FUNCTION_RODATA_SECTION.
+ The complication here is that, with the combination TARGET_ABICALLS
+ && !TARGET_GPWORD, jump tables will use absolute addresses, and should
+ therefore not be included in the read-only part of a DSO. Handle such
+ cases by selecting a normal data section instead of a read-only one.
+ The logic apes that in default_function_rodata_section. */
+ static void
+ mips_function_rodata_section (tree decl)
+ if (!TARGET_ABICALLS || TARGET_GPWORD)
+ default_function_rodata_section (decl);
+ else if (decl && DECL_SECTION_NAME (decl))
+ const char *name = TREE_STRING_POINTER (DECL_SECTION_NAME (decl));
+ if (DECL_ONE_ONLY (decl) && strncmp (name, ".gnu.linkonce.t.", 16) == 0)
+ char *rname = ASTRDUP (name);
+ rname = 'd';
+ named_section_real (rname, SECTION_LINKONCE | SECTION_WRITE, decl);
+ else if (flag_function_sections && flag_data_sections
+ && strncmp (name, ".text.", 6) == 0)
+ char *rname = ASTRDUP (name);
+ memcpy (rname + 1, "data", 4);
+ named_section_flags (rname, SECTION_WRITE);
+ data_section ();
+ data_section ();
/* Implement TARGET_IN_SMALL_DATA_P. Return true if it would be safe to
access DECL using %gp_rel(...)($gp). */