This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Reinstate MIPS ELF ABI assembler flag
- From: Richard Sandiford <rsandifo at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: echristo at redhat dot com
- Date: 16 Oct 2002 12:03:59 +0100
- Subject: Reinstate MIPS ELF ABI assembler flag
One of the announced changes in 3.3 is that MIPS ELF configs
will always pass an ABI flag to the assembler. The code to
do that has bitrotted, since it relied on OBJECT_ELF_FORMAT
being defined by the time mips.h was included.
I've tried to fix it in the patch below. The patch is hardly
pretty, but I don't want to try anything more invasive at this
stage. Tested on mips64vr-elf.
The patch also adds a test case, since this is something that
could easily break again in future. Seems a very convoluted
test for such a simple thing...
I haven't been able to test the irix change yet (the box
I normally use is unavailable). If the patch is approved,
I'll hold off committing that part until I get a successful
bootstrap.
Otherwise, OK for mainline?
Richard
* config.gcc (mips*-*-*): Add OBJECT_FORMAT_ELF to $tm_defines
if using mips/elf.h or mips/elf64.h.
* config/mips/elf.h (OBJECT_FORMAT_ELF): Remove.
* config/mips/elf64.h (OBJECT_FORMAT_ELF): Remove.
* config/mips/iris5.h (OBJECT_FORMAT_ELF): Move definition before
inclusion of mips.h.
testsuite/
* gcc.dg/special/mips-abi.exp: New test.
* gcc.dg/special/mips-abi.s: Empty file used by the above.
Index: config.gcc
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config.gcc,v
retrieving revision 1.253
diff -c -d -p -r1.253 config.gcc
*** config.gcc 10 Oct 2002 18:29:32 -0000 1.253
--- config.gcc 16 Oct 2002 10:53:37 -0000
*************** mips*-*-*)
*** 2840,2845 ****
--- 2840,2850 ----
tm_defines="TARGET_ENDIAN_DEFAULT=0 $tm_defines"
;;
esac
+ case $tm_file in
+ *mips/elf.h* | *mips/elf64.h*)
+ tm_defines="OBJECT_FORMAT_ELF $tm_defines"
+ ;;
+ esac
if test "x$enable_gofast" = xyes
then
tm_defines="INIT_SUBTARGET_OPTABS=INIT_GOFAST_OPTABS $tm_defines"
Index: config/mips/elf.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/mips/elf.h,v
retrieving revision 1.46
diff -c -d -p -r1.46 elf.h
*** config/mips/elf.h 26 Sep 2002 21:42:52 -0000 1.46
--- config/mips/elf.h 16 Oct 2002 10:53:37 -0000
*************** Boston, MA 02111-1307, USA. */
*** 22,28 ****
/* Use ELF. */
#undef OBJECT_FORMAT_COFF
#undef EXTENDED_COFF
- #define OBJECT_FORMAT_ELF
/* ??? Move all SDB stuff into separate header file. */
#undef SDB_DEBUGGING_INFO
--- 22,27 ----
Index: config/mips/elf64.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/mips/elf64.h,v
retrieving revision 1.52
diff -c -d -p -r1.52 elf64.h
*** config/mips/elf64.h 26 Sep 2002 21:42:52 -0000 1.52
--- config/mips/elf64.h 16 Oct 2002 10:53:37 -0000
*************** Boston, MA 02111-1307, USA. */
*** 22,28 ****
#undef OBJECT_FORMAT_COFF
#undef EXTENDED_COFF
- #define OBJECT_FORMAT_ELF
#undef SDB_DEBUGGING_INFO
#define DBX_DEBUGGING_INFO 1
--- 22,27 ----
Index: config/mips/iris5.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/mips/iris5.h,v
retrieving revision 1.16
diff -c -d -p -r1.16 iris5.h
*** config/mips/iris5.h 21 Aug 2002 02:41:49 -0000 1.16
--- config/mips/iris5.h 16 Oct 2002 10:53:37 -0000
*************** Boston, MA 02111-1307, USA. */
*** 26,31 ****
--- 26,33 ----
#endif
#define ABICALLS_ASM_OP "\t.option pic2"
+ #define OBJECT_FORMAT_ELF
+
#include "mips/iris3.h"
#include "mips/mips.h"
#include "mips/iris4.h"
*************** Boston, MA 02111-1307, USA. */
*** 41,47 ****
use collect. The linker can create these sections via -init and -fini
options, but using this would require modifying how crtstuff works, and
I will leave that for another time (or someone else). */
- #define OBJECT_FORMAT_ELF
#define HAS_INIT_SECTION
#define LD_INIT_SWITCH "-init"
#define LD_FINI_SWITCH "-fini"
--- 43,48 ----
*** /dev/null Tue Nov 14 21:44:43 2000
--- testsuite/gcc.dg/special/mips-abi.exp Wed Oct 16 11:52:42 2002
***************
*** 0 ****
--- 1,125 ----
+ # Copyright (C) 2002 Free Software Foundation, Inc.
+
+ # This program is free software; you can redistribute it and/or modify
+ # it under the terms of the GNU General Public License as published by
+ # the Free Software Foundation; either version 2 of the License, or
+ # (at your option) any later version.
+ #
+ # This program is distributed in the hope that it will be useful,
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ # GNU General Public License for more details.
+ #
+ # You should have received a copy of the GNU General Public License
+ # along with this program; if not, write to the Free Software
+ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ # This test checks whether MIPS ELF configurations pass the right
+ # ABI flags to the assembler. An ABI flag should always be passed
+ # unless MEABI is selected.
+
+ load_lib gcc-dg.exp
+
+ # Only run this test on MIPS ELF targets
+ if {![istarget mips*-*-*] || [gcc_target_object_format] != "elf"} {
+ return
+ }
+
+ # A list of all assembler ABI flags. We should use SGI-compatible
+ # flags where possible.
+ set asm_abi_flags {-32 -n32 -64 -mabi=o64 -mabi=eabi}
+
+ # Return true if the configuration uses MEABI by default.
+ proc is_meabi_config {} {
+ return [expr {[istarget mipsisa32*-*-elf*]
+ || [istarget mipsisa32el-*-elf*]
+ || [istarget mipsisa64-*-elf*]
+ || [istarget mipsisa64el-*-elf*]
+ || [istarget mipsisa64sr71k-*-elf*]}]
+ }
+
+ # Try to assemble mips-abi.s (an empty file), passing -v in order to
+ # get the assembler command line. Check whether an appropriate ABI
+ # flag is passed.
+ #
+ # NAME is a name for the pass/fail line.
+ # ABIS is a list of acceptable assembler ABI flags, or "" if no
+ # ABI flag is expected.
+ # FLAGS is a list of options for gcc.
+ proc check_mips_abi {name abis flags} {
+ global srcdir subdir asm_abi_flags
+
+ lappend flags "-v"
+ set lines [gcc_target_compile "$srcdir/$subdir/mips-abi.s" \
+ "mips-abi.o" object \
+ [list "additional_flags=$flags"]]
+ set good 0
+ set bad 0
+ foreach line [split $lines "\n"] {
+ # Find the assembler command line.
+ if {[string first "$srcdir/$subdir/mips-abi.s" $line] >= 0} {
+ foreach arg [split $line " "] {
+ # Count the number of matching and non-matching
+ # ABI options.
+ if {[lsearch -exact $abis $arg] >= 0} {
+ incr good
+ } elseif {[lsearch -exact $asm_abi_flags $arg] >= 0} {
+ incr bad
+ }
+ }
+ }
+ }
+ if {$good == ($abis != "") && $bad == 0} {
+ pass "mips-abi $name"
+ } else {
+ fail "mips-abi $name"
+ }
+ }
+
+ # Collect the default target flags.
+ set default_flags ""
+ set target [target_info name]
+ if {[info exists CFLAGS_FOR_TARGET]} {
+ append default_flags " $CFLAGS_FOR_TARGET"
+ }
+ if {[board_info $target exists cflags]} {
+ append default_flags " [board_info $target cflags]"
+ }
+ if {[board_info $target exists multilib_flags]} {
+ append default_flags " [board_info $target multilib_flags]"
+ }
+
+ # See whether the default command line specifies an ABI.
+ set default_abi ""
+ foreach flag $default_flags {
+ if {[string first "-mabi" $flag] == 0} {
+ set default_abi $flag
+ }
+ }
+
+ # If the command line does specify an ABI, just check for the
+ # appropriate assembler flag.
+ switch -- $default_abi {
+ -mabi=meabi { check_mips_abi "MEABI" "" "" }
+ -mabi=eabi { check_mips_abi "EABI" "-mabi=eabi" "" }
+ -mabi=32 { check_mips_abi "o32" "-32" "" }
+ -mabi=n32 { check_mips_abi "n32" "-n32" "" }
+ -mabi=o64 { check_mips_abi "o64" "-mabi=o64" "" }
+ -mabi=64 { check_mips_abi "n64" "-64" "" }
+ "" {
+ # MEABI configs shouldn't pass an ABI flag by default
+ # but the others should. It doesn't seem worthwhile
+ # duplicating the configuration to ABI logic here,
+ # so just accept any ABI.
+ if {[is_meabi_config]} {
+ check_mips_abi "default" "" ""
+ } else {
+ check_mips_abi "default" $asm_abi_flags ""
+ }
+ # See whether passing a -mabi flag does the right thing.
+ # Only try ABIs that the SGI assembler also understands.
+ check_mips_abi "o32" "-32" "-mabi=32"
+ check_mips_abi "n32" "-n32" "-mabi=n32"
+ check_mips_abi "64" "-64" "-mabi=64"
+ }
+ }