aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSa Liu <saliu@de.ibm.com>2006-12-11 00:53:42 +0000
committerBen Elliston <bje@gcc.gnu.org>2006-12-11 11:53:42 +1100
commitcc8d70cd9dd4719e408ab89a1648668a54ac31af (patch)
treec33fcffc2506173c3323aa787571eeea10689c11
parentea6f5c57de65853ab17c8db9bc594c06817b97b7 (diff)
downloadgcc-cc8d70cd9dd4719e408ab89a1648668a54ac31af.zip
gcc-cc8d70cd9dd4719e408ab89a1648668a54ac31af.tar.gz
gcc-cc8d70cd9dd4719e408ab89a1648668a54ac31af.tar.bz2
spu-elf.h (STARTFILE_SPEC): Update.
* config/spu/spu-elf.h (STARTFILE_SPEC): Update. (ENDFILE_SPEC): Likewise. * config/spu/spu.opt (mstdmain): New option. * config/spu/crti.asm: Remove. * config/spu/crtn.asm: Likewise. * config/spu/crt0.c: Likewise. * config/spu/crtend.c: Likewise. * config/spu/t-spu-elf (EXTRA_MULTILIB_PARTS): Remove crt0 files listed above. ($(T)crti.o, $(T)crtn.o, $(T)crt1.o, $(T)crtend1.o): Remove. * doc/invoke.texi (SPU Options): Document -mstdmain. Co-Authored-By: Ben Elliston <bje@au.ibm.com> From-SVN: r119727
-rw-r--r--gcc/ChangeLog15
-rw-r--r--gcc/config/spu/crt0.c131
-rw-r--r--gcc/config/spu/crtend.c32
-rw-r--r--gcc/config/spu/crti.asm53
-rw-r--r--gcc/config/spu/crtn.asm54
-rw-r--r--gcc/config/spu/spu-elf.h13
-rw-r--r--gcc/config/spu/spu.opt4
-rw-r--r--gcc/config/spu/t-spu-elf22
-rw-r--r--gcc/doc/invoke.texi11
9 files changed, 40 insertions, 295 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index b069e0f..23dfc07 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,18 @@
+2006-12-11 Sa Liu <saliu@de.ibm.com>
+ Ben Elliston <bje@au.ibm.com>
+
+ * config/spu/spu-elf.h (STARTFILE_SPEC): Update.
+ (ENDFILE_SPEC): Likewise.
+ * config/spu/spu.opt (mstdmain): New option.
+ * config/spu/crti.asm: Remove.
+ * config/spu/crtn.asm: Likewise.
+ * config/spu/crt0.c: Likewise.
+ * config/spu/crtend.c: Likewise.
+ * config/spu/t-spu-elf (EXTRA_MULTILIB_PARTS): Remove crt0 files
+ listed above.
+ ($(T)crti.o, $(T)crtn.o, $(T)crt1.o, $(T)crtend1.o): Remove.
+ * doc/invoke.texi (SPU Options): Document -mstdmain.
+
2006-12-10 Zdenek Dvorak <dvorakz@suse.cz>
* doc/loop.texi: Document number_of_latch_executions and
diff --git a/gcc/config/spu/crt0.c b/gcc/config/spu/crt0.c
deleted file mode 100644
index eee1592..0000000
--- a/gcc/config/spu/crt0.c
+++ /dev/null
@@ -1,131 +0,0 @@
-/* Copyright (C) 2006 Free Software Foundation, Inc.
-
- This file 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 file 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 file; see the file COPYING. If not, write to the Free
- Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA. */
-
-/* As a special exception, if you link this library with files compiled with
- GCC to produce an executable, this does not cause the resulting executable
- to be covered by the GNU General Public License. The exception does not
- however invalidate any other reasons why the executable file might be covered
- by the GNU General Public License. */
-
-extern int main(int, unsigned long long, unsigned long long);
-void _start(int, unsigned long long, unsigned long long) __attribute__((__naked__));
-
-extern void exit(int);
-
-void _exit(int) __attribute__((__naked__));
-
-typedef void (*func_ptr) (void);
-typedef __attribute__ ((__vector_size__(16))) unsigned int vec_uint4;
-
-extern vec_uint4 __stack[];
-register vec_uint4 si_sp __asm__("$sp");
-register unsigned int si_r2 __asm__("$2");
-
-extern char _end[];
-
-/* If we want these aligned we need to do it in the linker script. */
-func_ptr __CTOR_LIST__[1]
- __attribute__ ((__section__(".ctors"), __aligned__(4)))
- = { (func_ptr) (-1) };
-
-static func_ptr __DTOR_LIST__[1]
- __attribute__((__section__(".dtors"), __aligned__(4)))
- = { (func_ptr) (-1) };
-
-void *__dso_handle = 0;
-
-/* According to the BE Linux ABI an SPU module is called with these
- * parameters. Also, $2 is set to the Available Stack Size. */
-void
-_start(int spu_id,
- unsigned long long param,
- unsigned long long env)
-{
- unsigned int stack_size;
- unsigned int sp = (unsigned int)(__stack - 2);
-
- /* Initialize the stack. __stack has been set to point to the top
- quadword of the stack. The ABI requires at least a NULL terminated
- back chain and lr save area. For example:
- +----------------+
- | 0 |
- +----------------+ <- __stack (e.g., 0x3fff0)
- | space for $lr |
- +----------------+
- | back chain |
- +----------------+ <- $sp (e.g., __stack - 32, 0x3ffd0)
- */
- __stack[0] = (vec_uint4){0, 0, 0, 0};
- __stack[-1] = (vec_uint4){0, 0, 0, 0};
-
- /* Initialize the Available Stack Size word of the Stack Pointer
- * information register. The BE Linux ABI passes the stack size in
- * $2, or use everything up to _end if $2 == 0. */
- stack_size = si_r2 == 0 ? sp - (unsigned int)_end : si_r2;
-
- __stack[-2] = (vec_uint4){(unsigned int)__stack, stack_size, 0, 0};
-
- si_sp = (vec_uint4){sp, stack_size, 0, 0};
-
-
- {
- extern func_ptr __CTOR_END__[];
- func_ptr *p;
-
- /* The compiler assumes all symbols are 16 byte aligned, which is
- * not the case for __CTOR_END__. This inline assembly makes sure
- * the address is loaded into a register for which the compiler does
- * not assume anything about alignment. */
- __asm__ ("\n" : "=r" (p) : "0" (__CTOR_END__ - 1));
-
- for (; *p != (func_ptr) -1; p--)
- (*p) ();
- }
-
- exit(main(spu_id, param, env));
- __asm__ volatile ( " stop 0x20ff");
-}
-
-/* C99 requires _Exit */
-void _Exit(int) __attribute__((__weak__, __alias__("_exit")));
-
-void
-_exit(int rc)
-{
- {
- static func_ptr *p = 0;
- if (!p)
- {
- /* See comment for __CTOR_END__ above. */
- __asm__ ("" : "=r" (p) : "0" (__DTOR_LIST__ + 1));
- for (; *p; p++)
- (*p) ();
- }
- }
- /* Some self modifying code to return 'rc' in the 'stop' insn. */
- __asm__ volatile (
- " ori $3, %0,0\n"
- " lqr $4, 1f\n"
- " cbd $5, 1f+3($sp)\n"
- " shufb $0, %0, $4, $5\n"
- " stqr $0, 1f\n"
- " sync\n"
- "1:\n"
- " stop 0x2000\n"
- : : "r" (rc) );
-}
-
diff --git a/gcc/config/spu/crtend.c b/gcc/config/spu/crtend.c
deleted file mode 100644
index 694a7ee..0000000
--- a/gcc/config/spu/crtend.c
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Copyright (C) 2006 Free Software Foundation, Inc.
-
- This file 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 file 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 file; see the file COPYING. If not, write to the Free
- Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA. */
-
-/* As a special exception, if you link this library with files compiled with
- GCC to produce an executable, this does not cause the resulting executable
- to be covered by the GNU General Public License. The exception does not
- however invalidate any other reasons why the executable file might be covered
- by the GNU General Public License. */
-
-typedef void (*func_ptr) (void);
-
-func_ptr __CTOR_END__[1]
- __attribute__ ((section(".ctors"), aligned(sizeof(func_ptr))))
- = { (func_ptr) (0) };
-
-func_ptr __DTOR_END__[1]
- __attribute__((section(".dtors"), aligned(sizeof(func_ptr))))
- = { (func_ptr) (0) };
diff --git a/gcc/config/spu/crti.asm b/gcc/config/spu/crti.asm
deleted file mode 100644
index dd0aa3d..0000000
--- a/gcc/config/spu/crti.asm
+++ /dev/null
@@ -1,53 +0,0 @@
-# Copyright (C) 2006 Free Software Foundation, Inc.
-#
-# This file 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 file 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 file; see the file COPYING. If not, write to the Free
-# Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
-# 02110-1301, USA. */
-#
-# As a special exception, if you link this library with files
-# compiled with GCC to produce an executable, this does not cause
-# the resulting executable to be covered by the GNU General Public License.
-# This exception does not however invalidate any other reasons why
-# the executable file might be covered by the GNU General Public License.
-#
-
-# This file just make a stack frame for the contents of the .fini and
-# .init sections. Users may put any desired instructions in those
-# sections.
-
- # Note - this macro is complimented by the FUNC_END macro
- # in crtn.asm. If you change this macro you must also change
- # that macro match.
-.macro FUNC_START
- # Create a stack frame and save any call-preserved registers
- ai $sp, $sp, -16
- stqd $lr, 0($sp)
-.endm
-
- .file "crti.asm"
-
- .section ".init"
- .align 2
- .global _init
-_init:
- FUNC_START
-
-
- .section ".fini"
- .align 2
- .global _fini
-_fini:
- FUNC_START
-
-# end of crti.asm
diff --git a/gcc/config/spu/crtn.asm b/gcc/config/spu/crtn.asm
deleted file mode 100644
index 27b5276..0000000
--- a/gcc/config/spu/crtn.asm
+++ /dev/null
@@ -1,54 +0,0 @@
-# Copyright (C) 2006 Free Software Foundation, Inc.
-#
-# This file 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 file 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 file; see the file COPYING. If not, write to the Free
-# Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
-# 02110-1301, USA. */
-#
-# As a special exception, if you link this library with files
-# compiled with GCC to produce an executable, this does not cause
-# the resulting executable to be covered by the GNU General Public License.
-# This exception does not however invalidate any other reasons why
-# the executable file might be covered by the GNU General Public License.
-#
-
-# This file just makes sure that the .fini and .init sections do in
-# fact return. Users may put any desired instructions in those sections.
-# This file is the last thing linked into any executable.
-
- # Note - this macro is complimented by the FUNC_START macro
- # in crti.asm. If you change this macro you must also change
- # that macro match.
- #
- # Note - we do not try any fancy optimisations of the return
- # sequences here, it is just not worth it. Instead keep things
- # simple. Restore all the save resgisters, including the link
- # register and then perform the correct function return instruction.
-.macro FUNC_END
- lqd $lr, 0($sp)
- ai $sp, $sp, 16
- bi $lr
-.endm
-
-
- .file "crtn.asm"
-
- .section ".init"
- ;;
- FUNC_END
-
- .section ".fini"
- ;;
- FUNC_END
-
-# end of crtn.asm
diff --git a/gcc/config/spu/spu-elf.h b/gcc/config/spu/spu-elf.h
index ee5e015..acdd467 100644
--- a/gcc/config/spu/spu-elf.h
+++ b/gcc/config/spu/spu-elf.h
@@ -25,11 +25,18 @@
asm_output_aligned_bss (FILE, DECL, NAME, SIZE, ALIGN)
-#undef STARTFILE_SPEC
-#define STARTFILE_SPEC "crt1%O%s"
+
+/* Provide a STARTFILE_SPEC appropriate for GNU/Linux. Here we add
+ the GNU/Linux magical crtbegin.o file (see crtstuff.c) which
+ provides part of the support for getting C++ file-scope static
+ object constructed before entering `main'. */
+
+#undef STARTFILE_SPEC
+#define STARTFILE_SPEC "%{mstdmain: crt2.o%s} %{!mstdmain: crt1.o%s} \
+ crti.o%s crtbegin.o%s"
#undef ENDFILE_SPEC
-#define ENDFILE_SPEC "crtend1%O%s"
+#define ENDFILE_SPEC "crtend.o%s crtn.o%s"
#define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG
diff --git a/gcc/config/spu/spu.opt b/gcc/config/spu/spu.opt
index d234dcd..5df242e 100644
--- a/gcc/config/spu/spu.opt
+++ b/gcc/config/spu/spu.opt
@@ -36,6 +36,10 @@ munsafe-dma
Target Report RejectNegative InverseMask(SAFE_DMA)
volatile must be specified on any memory that is effected by DMA
+mstdmain
+Target Report Mask(STD_MAIN)
+Use standard main function as entry for startup
+
mbranch-hints
Target Report Mask(BRANCH_HINTS)
Generate branch hints for branches
diff --git a/gcc/config/spu/t-spu-elf b/gcc/config/spu/t-spu-elf
index c05b245..b02cbd4b 100644
--- a/gcc/config/spu/t-spu-elf
+++ b/gcc/config/spu/t-spu-elf
@@ -54,31 +54,11 @@ CRTSTUFF_T_CFLAGS =
# Neither gcc or newlib seem to have a standard way to generate multiple
# crt*.o files. So we don't use the standard crt0.o name anymore.
-EXTRA_MULTILIB_PARTS = crtbegin.o crtend.o crti.o crtn.o crt1.o crtend1.o
+EXTRA_MULTILIB_PARTS = crtbegin.o crtend.o
LIBGCC = stmp-multilib
INSTALL_LIBGCC = install-multilib
-# Assemble startup files.
-$(T)crti.o: $(srcdir)/config/spu/crti.asm $(GCC_PASSES)
- $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(MULTILIB_CFLAGS) $(INCLUDES) \
- -c -o $(T)crti.o -x assembler-with-cpp $(srcdir)/config/spu/crti.asm
-
-$(T)crtn.o: $(srcdir)/config/spu/crtn.asm $(GCC_PASSES)
- $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(MULTILIB_CFLAGS) $(INCLUDES) \
- -c -o $(T)crtn.o -x assembler-with-cpp $(srcdir)/config/spu/crtn.asm
-
-$(T)crt1.o: $(srcdir)/config/spu/crt0.c $(GCC_PASSES)
- $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(MULTILIB_CFLAGS) $(INCLUDES) \
- -O2 \
- -c -o $(T)crt1.o $(srcdir)/config/spu/crt0.c
-
-$(T)crtend1.o: $(srcdir)/config/spu/crtend.c $(GCC_PASSES)
- $(GCC_FOR_TARGET) $(GCC_CFLAGS) $(MULTILIB_CFLAGS) $(INCLUDES) \
- -O2 \
- -c -o $(T)crtend1.o $(srcdir)/config/spu/crtend.c
-
-
spu.o: $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
$(RTL_H) $(REGS_H) hard-reg-set.h \
real.h insn-config.h conditions.h insn-attr.h flags.h $(RECOG_H) \
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 2baf3c3..942ee90 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -733,7 +733,7 @@ See RS/6000 and PowerPC Options.
@gccoptlist{-mwarn-reloc -merror-reloc @gol
-msafe-dma -munsafe-dma @gol
-mbranch-hints @gol
--msmall-mem -mlarge-mem}
+-msmall-mem -mlarge-mem -mstdmain}
@emph{System V Options}
@gccoptlist{-Qy -Qn -YP,@var{paths} -Ym,@var{dir}}
@@ -12920,6 +12920,15 @@ By default, GCC generates code assuming that addresses are never larger
than 18 bits. With @option{-mlarge-mem} code is generated that assumes
a full 32 bit address.
+@item -mstdmain
+@opindex mstdmain
+
+By default, GCC links against startup code that assumes the SPU-style
+main function interface (which has an unconventional parameter list).
+With @option{-mstdmain}, GCC will link your program against startup
+code that assumes a C99-style interface to @code{main}, including a
+local copy of @code{argv} strings.
+
@end table
@node System V Options