Commit b55e3aad by Nick Clifton

config.gcc: Add sh-*-symbianelf target.

* config.gcc: Add sh-*-symbianelf target.
* config/sh/sh.c: Add new target macros:
  TARGET_ENCODE_SECTION_INFO, TARGET_STRIP_NAME_ENCODING,
  TARGET_CXX_IMPORT_EXPORT_CLASS.
  (sh_file_start): Create a definition of the .directive section.
  (sh_attribute): Add dllimport and dllexport attributes.
* config/sh/symbian-pre.h: New file.
* config/sh/symbian-post.h: New file.
* config/sh/symbian.c: New file. Contains Symbian specific functions.
* config/sh/sh-protos.h: Add prototypes for new functions provided by symbian.c.
* config/sh/t-symbian: New file.
* doc/extend.texi: Document support for dllimport and dllexport	attributes by
  the sh-symbianelf target.

From-SVN: r84551
parent 55e99d52
......@@ -1671,6 +1671,7 @@ s390x-ibm-tpf*)
tmake_file="t-slibgcc-elf-ver s390/t-crtstuff s390/t-tpf"
;;
sh-*-elf* | sh[12346l]*-*-elf* | sh*-*-kaos* | \
sh-*-symbianelf* | sh[12346l]*-*-symbianelf* | \
sh-*-linux* | sh[346lbe]*-*-linux* | \
sh-*-netbsdelf* | shl*-*-netbsdelf* | sh5-*-netbsd* | sh5l*-*-netbsd* | \
sh64-*-netbsd* | sh64l*-*-netbsd*)
......@@ -1730,6 +1731,12 @@ sh-*-elf* | sh[12346l]*-*-elf* | sh*-*-kaos* | \
tm_file="${tm_file} sh/sh64.h"
extra_headers="shmedia.h ushmedia.h sshmedia.h"
;;
*-*-symbianelf*)
tmake_file="sh/t-symbian"
tm_file="sh/symbian-pre.h sh/little.h ${tm_file} sh/symbian-post.h"
extra_objs="symbian.o"
extra_parts="crt1.o crti.o crtn.o crtbegin.o crtend.o crtbeginS.o crtendS.o"
;;
esac
# sed el/eb endian suffixes away to avoid confusion with sh[23]e
case `echo ${target} | sed 's/e[lb]-/-/'` in
......
......@@ -143,3 +143,17 @@ extern const char *sh_pch_valid_p (const void *data_p, size_t sz);
extern bool sh_promote_prototypes (tree);
#endif /* ! GCC_SH_PROTOS_H */
#ifdef SYMBIAN
extern bool sh_symbian_dllimport_name_p (const char *);
extern const char * sh_symbian_strip_name_encoding (const char *);
extern bool sh_symbian_dllexport_name_p (const char *);
extern int symbian_import_export_class (tree, int);
#ifdef TREE_CODE
extern bool sh_symbian_dllexport_p (tree);
extern tree sh_symbian_handle_dll_attribute (tree *, tree, tree, int, bool *);
#ifdef RTX_CODE
extern void sh_symbian_encode_section_info (tree, rtx, int);
#endif
#endif
#endif /* SYMBIAN */
......@@ -451,6 +451,17 @@ static tree sh_gimplify_va_arg_expr (tree, tree, tree *, tree *);
/* Return current register pressure for regmode. */
#define CURR_REGMODE_PRESSURE(MODE) curr_regmode_pressure[((MODE) == SImode) ? 0 : 1]
#ifdef SYMBIAN
#undef TARGET_ENCODE_SECTION_INFO
#define TARGET_ENCODE_SECTION_INFO sh_symbian_encode_section_info
#undef TARGET_STRIP_NAME_ENCODING
#define TARGET_STRIP_NAME_ENCODING sh_symbian_strip_name_encoding
#undef TARGET_CXX_IMPORT_EXPORT_CLASS
#define TARGET_CXX_IMPORT_EXPORT_CLASS symbian_import_export_class
#endif /* SYMBIAN */
struct gcc_target targetm = TARGET_INITIALIZER;
/* Print the operand address in x to the stream. */
......@@ -1431,6 +1442,12 @@ sh_file_start (void)
{
default_file_start ();
#ifdef SYMBIAN
/* Declare the .directive section before it is used. */
fputs ("\t.section .directive, \"SM\", @progbits, 1\n", asm_out_file);
fputs ("\t.asciz \"#<SYMEDIT>#\\n\"\n", asm_out_file);
#endif
if (TARGET_ELF)
/* We need to show the text section with the proper
attributes as in TEXT_SECTION_ASM_OP, before dwarf2out
......@@ -6950,6 +6967,17 @@ const struct attribute_spec sh_attribute_table[] =
{ "sp_switch", 1, 1, true, false, false, sh_handle_sp_switch_attribute },
{ "trap_exit", 1, 1, true, false, false, sh_handle_trap_exit_attribute },
{ "renesas", 0, 0, false, true, false, sh_handle_renesas_attribute },
#ifdef SYMBIAN
/* Symbian support adds three new attributes:
dllexport - for exporting a function/variable that will live in a dll
dllimport - for importing a function/variable from a dll
Microsoft allows multiple declspecs in one __declspec, separating
them with spaces. We do NOT support this. Instead, use __declspec
multiple times. */
{ "dllimport", 0, 0, true, false, false, sh_symbian_handle_dll_attribute },
{ "dllexport", 0, 0, true, false, false, sh_symbian_handle_dll_attribute },
#endif
{ NULL, 0, 0, false, false, false, NULL }
};
......
/* Definitions for the Symbian OS running on an SH part.
This file is included after all the other target specific headers.
Copyright (C) 2004 Free Software Foundation, Inc.
Contributed by Red Hat.
This file is part of GCC.
GCC 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, or (at your
option) any later version.
GCC 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 GCC; see the file COPYING. If not, write to the
Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#undef TARGET_VERSION
#define TARGET_VERSION \
fputs (" (Renesas SH for Symbian OS)", stderr);
#undef LINK_EMUL_PREFIX
#define LINK_EMUL_PREFIX "shlsymbian"
#define SYMBIAN_EXPORT_NAME(NAME,FILE,DECL) \
do \
{ \
if ((DECL && sh_symbian_dllexport_p (DECL)) \
|| sh_symbian_dllexport_name_p (NAME)) \
{ \
fprintf ((FILE), "\t.pushsection .directive\n"); \
fprintf ((FILE), "\t.asciz \"EXPORT %s\\n\"\n", \
sh_symbian_strip_name_encoding (NAME)); \
fprintf ((FILE), "\t.popsection\n"); \
} \
} \
while (0)
/* Output a function definition label. */
#undef ASM_DECLARE_FUNCTION_NAME
#define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
do \
{ \
SYMBIAN_EXPORT_NAME ((NAME), (FILE), (DECL)); \
ASM_OUTPUT_TYPE_DIRECTIVE ((FILE), (NAME), "function"); \
ASM_DECLARE_RESULT ((FILE), DECL_RESULT (DECL)); \
ASM_OUTPUT_LABEL ((FILE), (NAME)); \
} \
while (0)
/* Output the label for an initialized variable. */
#undef ASM_DECLARE_OBJECT_NAME
#define ASM_DECLARE_OBJECT_NAME(FILE, NAME, DECL) \
do \
{ \
HOST_WIDE_INT size; \
\
SYMBIAN_EXPORT_NAME ((NAME), (FILE), (DECL)); \
ASM_OUTPUT_TYPE_DIRECTIVE ((FILE), (NAME), "object"); \
\
size_directive_output = 0; \
if (!flag_inhibit_size_directive \
&& (DECL) \
&& DECL_SIZE (DECL)) \
{ \
size_directive_output = 1; \
size = int_size_in_bytes (TREE_TYPE (DECL)); \
ASM_OUTPUT_SIZE_DIRECTIVE ((FILE), (NAME), size); \
} \
\
ASM_OUTPUT_LABEL ((FILE), (NAME)); \
} \
while (0)
#undef ASM_OUTPUT_LABELREF
#define ASM_OUTPUT_LABELREF(FILE, NAME) \
do \
{ \
asm_fprintf ((FILE), "%U%s", \
sh_symbian_strip_name_encoding (NAME)); \
} \
while (0)
/* Definitions for the Symbian OS running on an SH part.
This file is included before any other target specific headers.
Copyright (C) 2004 Free Software Foundation, Inc.
Contributed by Red Hat.
This file is part of GCC.
GCC 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, or (at your
option) any later version.
GCC 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 GCC; see the file COPYING. If not, write to the
Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
/* Enable Symbian specific code. */
#define SYMBIAN 1
/* Default to using the Renesas ABI. */
#define TARGET_ABI_DEFAULT RENESAS_BIT
/* Support the __declspec keyword by turning them into attributes.
We currently only support: naked, dllimport, and dllexport.
Note that the current way we do this may result in a collision with
predefined attributes later on. This can be solved by using one attribute,
say __declspec__, and passing args to it. The problem with that approach
is that args are not accumulated: each new appearance would clobber any
existing args. */
#define SUBTARGET_CPP_SPEC "-D__declspec(x)=__attribute__((x))"
/* Get tree.c to declare merge_dllimport_decl_attributes(). */
#define TARGET_DLLIMPORT_DECL_ATTRIBUTES
/* The Symbian OS currently does not support exception handling. */
#define SUBTARGET_CC1PLUS_SPEC "-fno-exceptions"
/* Create constructor/destructor sections without the writable flag.
Symbian puts them into the text segment and munges them later on. */
#define CTORS_SECTION_ASM_OP "\t.section\t.ctors,\"ax\",@progbits"
#define DTORS_SECTION_ASM_OP "\t.section\t.dtors,\"ax\",@progbits"
LIB1ASMSRC = sh/lib1funcs.asm
LIB1ASMFUNCS = _ashiftrt _ashiftrt_n _ashiftlt _lshiftrt _movstr \
_movstr_i4 _mulsi3 _sdivsi3 _sdivsi3_i4 _udivsi3 _udivsi3_i4 _set_fpscr \
$(LIB1ASMFUNCS_CACHE)
# We want fine grained libraries, so use the new code to build the
# floating point emulation libraries.
FPBIT = fp-bit.c
DPBIT = dp-bit.c
dp-bit.c: $(srcdir)/config/fp-bit.c
cat $(srcdir)/config/fp-bit.c >> dp-bit.c
fp-bit.c: $(srcdir)/config/fp-bit.c
echo '#define FLOAT' > fp-bit.c
cat $(srcdir)/config/fp-bit.c >> fp-bit.c
$(T)crt1.o: $(srcdir)/config/sh/crt1.asm $(GCC_PASSES)
$(GCC_FOR_TARGET) $(MULTILIB_CFLAGS) -c -o $(T)crt1.o -x assembler-with-cpp $(srcdir)/config/sh/crt1.asm
$(T)crti.o: $(srcdir)/config/sh/crti.asm $(GCC_PASSES)
$(GCC_FOR_TARGET) $(MULTILIB_CFLAGS) -c -o $(T)crti.o -x assembler-with-cpp $(srcdir)/config/sh/crti.asm
$(T)crtn.o: $(srcdir)/config/sh/crtn.asm $(GCC_PASSES)
$(GCC_FOR_TARGET) $(MULTILIB_CFLAGS) -c -o $(T)crtn.o -x assembler-with-cpp $(srcdir)/config/sh/crtn.asm
$(out_object_file): gt-sh.h
gt-sh.h : s-gtype ; @true
symbian.o: $(srcdir)/config/sh/symbian.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
$(RTL_H) output.h flags.h $(TREE_H) expr.h toplev.h $(TM_P_H)
$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $(srcdir)/config/sh/symbian.c
# Local Variables:
# mode: Makefile
# End:
......@@ -2009,10 +2009,11 @@ types (@pxref{Variable Attributes}, @pxref{Type Attributes}.)
@item dllexport
@cindex @code{__declspec(dllexport)}
On Microsoft Windows targets the @code{dllexport} attribute causes the
compiler to provide a global pointer to a pointer in a dll, so that it
can be referenced with the @code{dllimport} attribute. The pointer name
is formed by combining @code{_imp__} and the function or variable name.
On Microsoft Windows targets and Symbian targets the @code{dllexport}
attribute causes the compiler to provide a global pointer to a pointer
in a dll, so that it can be referenced with the @code{dllimport}
attribute. The pointer name is formed by combining @code{_imp__} and
the function or variable name.
Currently, the @code{dllexport}attribute is ignored for inlined
functions, but export can be forced by using the
......@@ -2024,21 +2025,24 @@ member functions and static data members as exports. Static consts
initialized in-class are not marked unless they are also defined
out-of-class.
On cygwin, mingw and arm-pe targets, @code{__declspec(dllexport)} is
recognized as a synonym for @code{__attribute__ ((dllexport))} for
compatibility with other Microsoft Windows compilers.
On cygwin, mingw, arm-pe and sh-symbianelf targets,
@code{__declspec(dllexport)} is recognized as a synonym for
@code{__attribute__ ((dllexport))} for compatibility with other
Microsoft Windows and Symbian compilers.
Alternative methods for including the symbol in the dll's export table
are to use a .def file with an @code{EXPORTS} section or, with GNU ld,
using the @option{--export-all} linker flag.
For Microsoft Windows targets there are alternative methods for
including the symbol in the dll's export table such as using a
@file{.def} file with an @code{EXPORTS} section or, with GNU ld, using
the @option{--export-all} linker flag.
@item dllimport
@cindex @code{__declspec(dllimport)}
On Microsoft Windows targets, the @code{dllimport} attribute causes the
compiler to reference a function or variable via a global pointer to a
pointer that is set up by the Microsoft Windows dll library. The pointer
name is formed by combining @code{_imp__} and the function or variable
name. The attribute implies @code{extern} storage.
On Microsoft Windows and Symbian targets, the @code{dllimport}
attribute causes the compiler to reference a function or variable via
a global pointer to a pointer that is set up by the Microsoft Windows
dll library. The pointer name is formed by combining @code{_imp__} and
the function or variable name. The attribute implies @code{extern}
storage.
Currently, the attribute is ignored for inlined functions. If the
attribute is applied to a symbol @emph{definition}, an error is reported.
......@@ -2052,15 +2056,25 @@ member functions and static data members as imports. However, the
attribute is ignored for virtual methods to allow creation of vtables
using thunks.
On cygwin, mingw and arm-pe targets, @code{__declspec(dllimport)} is
recognized as a synonym for @code{__attribute__ ((dllimport))} for
compatibility with other Microsoft Windows compilers.
For Symbian targets the @code{dllimport} attribute also has another
affect - it can cause the vtable and run-time type information for a
class to be exported. This happens when the class has a dllimport'ed
constructor or a non-inline, non-pure virtual function and, for either
of those two conditions, the class also has a inline constructor or
destructor and has a key function that is defined in the current
translation unit.
The use of the @code{dllimport} attribute on functions is not necessary,
but provides a small performance benefit by eliminating a thunk in the
dll. The use of the @code{dllimport} attribute on imported variables was
required on older versions of GNU ld, but can now be avoided by passing
the @option{--enable-auto-import} switch to ld. As with functions, using
On cygwin, mingw, arm-pe sh-symbianelf targets,
@code{__declspec(dllimport)} is recognized as a synonym for
@code{__attribute__ ((dllimport))} for compatibility with other
Microsoft Windows and Symbian compilers.
For Microsoft Windows based targets the use of the @code{dllimport}
attribute on functions is not necessary, but provides a small
performance benefit by eliminating a thunk in the dll. The use of the
@code{dllimport} attribute on imported variables was required on older
versions of GNU ld, but can now be avoided by passing the
@option{--enable-auto-import} switch to ld. As with functions, using
the attribute for a variable eliminates a thunk in the dll.
One drawback to using this attribute is that a pointer to a function or
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment