This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
3.4 PATCH: Test HAVE_GAS_SHF_MERGE at runtime
- From: Rainer Orth <ro at TechFak dot Uni-Bielefeld dot DE>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 22 Sep 2003 22:38:09 +0200 (MEST)
- Subject: 3.4 PATCH: Test HAVE_GAS_SHF_MERGE at runtime
Testing my IRIX 6 O32 integration patch with GNU as revealed an additional
problem: while gas supports SHF_MERGE, the O32 libgcc_s.so.1 fails to link
with the native ld:
ld: WARNING 86 : Section .rodata.cst4 of input file libgcc/mabi=32/_fixunssfsi.o not included as output.
ld: WARNING 86 : Section .rodata.cst4 of input file libgcc/mabi=32/_si_to_sf.o not included as output.
ld: WARNING 86 : Section .rodata.cst8 of input file libgcc/mabi=32/_floatdidf.o not included as output.
ld: WARNING 86 : Section .rodata.cst8 of input file libgcc/mabi=32/_floatdisf.o not included as output.
ld: WARNING 86 : Section .rodata.cst8 of input file libgcc/mabi=32/_fixunsdfsi.o not included as output.
ld: WARNING 86 : Section .rodata.cst8 of input file libgcc/mabi=32/_fixunsdfdi.o not included as output.
ld: WARNING 86 : Section .rodata.cst8 of input file libgcc/mabi=32/_fixunssfdi.o not included as output.
ld: WARNING 86 : Section .rodata.cst8 of input file libgcc/mabi=32/_si_to_df.o not included as output.
ld: FATAL 87 : Input sections have not been specified for inclusion in a.out. This is typically due to omissions in the -elspec file. See error messages above.
collect2: ld returned 4 exit status
make[3]: *** [mabi=32/libgcc_s_mabi=32.so] Error 1
I had the same problem with the mips-sgi-irix6o32 configuration, where I
disabled HAVE_GAS_SHF_MERGE in iris5gas.h. A similar change needs to go
into a (new, to be submitted with the rest of the IRIX 6 cleanup/O32
integration patch) iris6gas.h, only disabling this for O32 where the linker
cannot support it:
/* Disable SHF_MERGE support. Even if gas supports it, the IRIX 6 O32 ld
does not without a special elspec(5) file.
FIXME: Only do this it not using GNU ld. */
#if HAVE_GAS_SHF_MERGE
#undef HAVE_GAS_SHF_MERGE
#define HAVE_GAS_SHF_MERGE (mips_abi == ABI_32 ? 0 : 1)
#endif /* HAVE_GAS_SHF_MERGE */
So the current compile-time tests for HAVE_GAS_SHF_MERGE need to be
performed at runtime, and the configure test must result in the macro being
defined as either 0 or 1 one instead leaving it undefined in the former
case. The following patch allows this. The ability will be used as soon
as I submit the mips-specific parts of the integration patch.
Bootstrapped without regressions on mips-sgi-irix6.5 (with the complete
patch set above).
Ok for mainline?
Rainer
-----------------------------------------------------------------------------
Rainer Orth, Faculty of Technology, Bielefeld University
Thu Sep 18 00:25:52 2003 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE>
* configure.in (HAVE_GAS_SHF_MERGE): Always define to test result.
Update description.
* configure: Regenerate.
* config.in: Likewise.
* dwarf2out.c (DEBUG_STR_SECTION_FLAGS): Test for
HAVE_GAS_SHF_MERGE value.
* varasm.c (mergeable_string_section): Likewise.
(mergeable_constant_section): Likewise.
Index: gcc/configure.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/configure.in,v
retrieving revision 1.726
diff -u -p -b -r1.726 configure.in
--- gcc/configure.in 10 Sep 2003 00:13:00 -0000 1.726
+++ gcc/configure.in 22 Sep 2003 19:55:37 -0000
@@ -1966,9 +1966,10 @@ fi
gcc_GAS_CHECK_FEATURE(section merging support, gcc_cv_as_shf_merge,
[elf,2,12,0], [--fatal-warnings],
- [.section .rodata.str, "aMS", @progbits, 1],,
- [AC_DEFINE(HAVE_GAS_SHF_MERGE, 1,
-[Define if your assembler supports marking sections with SHF_MERGE flag.])])
+ [.section .rodata.str, "aMS", @progbits, 1])
+AC_DEFINE_UNQUOTED(HAVE_GAS_SHF_MERGE,
+ [`if test $gcc_cv_as_shf_merge = yes; then echo 1; else echo 0; fi`],
+[Define 0/1 if your assembler supports marking sections with SHF_MERGE flag.])
# Thread-local storage - the check is heavily parametrized.
conftest_s=
Index: gcc/dwarf2out.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/dwarf2out.c,v
retrieving revision 1.450
diff -u -p -b -r1.450 dwarf2out.c
--- gcc/dwarf2out.c 11 Sep 2003 13:41:56 -0000 1.450
+++ gcc/dwarf2out.c 22 Sep 2003 19:55:38 -0000
@@ -3812,14 +3826,10 @@ static int maybe_emit_file (int);
#endif
/* Section flags for .debug_str section. */
-#ifdef HAVE_GAS_SHF_MERGE
#define DEBUG_STR_SECTION_FLAGS \
- (flag_merge_constants \
+ (HAVE_GAS_SHF_MERGE && flag_merge_constants \
? SECTION_DEBUG | SECTION_MERGE | SECTION_STRINGS | 1 \
: SECTION_DEBUG)
-#else
-#define DEBUG_STR_SECTION_FLAGS SECTION_DEBUG
-#endif
/* Labels we insert at beginning sections we can reference instead of
the section names themselves. */
Index: gcc/varasm.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/varasm.c,v
retrieving revision 1.383
diff -u -p -b -r1.383 varasm.c
--- gcc/varasm.c 9 Sep 2003 13:37:17 -0000 1.383
+++ gcc/varasm.c 22 Sep 2003 19:55:41 -0000
@@ -562,8 +562,7 @@ mergeable_string_section (tree decl ATTR
unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED,
unsigned int flags ATTRIBUTE_UNUSED)
{
-#ifdef HAVE_GAS_SHF_MERGE
- if (flag_merge_constants
+ if (HAVE_GAS_SHF_MERGE && flag_merge_constants
&& TREE_CODE (decl) == STRING_CST
&& TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE
&& align <= 256
@@ -625,7 +624,7 @@ mergeable_string_section (tree decl ATTR
}
}
}
-#endif
+
readonly_data_section ();
}
@@ -636,10 +635,9 @@ mergeable_constant_section (enum machine
unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED,
unsigned int flags ATTRIBUTE_UNUSED)
{
-#ifdef HAVE_GAS_SHF_MERGE
unsigned int modesize = GET_MODE_BITSIZE (mode);
- if (flag_merge_constants
+ if (HAVE_GAS_SHF_MERGE && flag_merge_constants
&& mode != VOIDmode
&& mode != BLKmode
&& modesize <= align
@@ -654,7 +652,7 @@ mergeable_constant_section (enum machine
named_section_flags (name, flags);
return;
}
-#endif
+
readonly_data_section ();
}