This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
RFC: Adding VxWorks PIC support to various backends
- From: Richard Sandiford <richard at codesourcery dot com>
- To: gcc at gcc dot gnu dot org
- Date: Fri, 02 Mar 2007 14:12:30 +0000
- Subject: RFC: Adding VxWorks PIC support to various backends
CodeSourcery is gearing up to submit support for the VxWorks RTP PIC
model. Six targets are affected: arm, i386, mips, rs6000, sh and sparc.
All this code is conditional on TARGET_VXWORKS_RTP being true and refers
to two other macros: VXWORKS_GOTT_BASE and VXWORKS_GOTT_INDEX.
Before submitting patches, I just wanted to ask how this code should
be integrated into the surrounding non-VxWorks code. Some obvious
alternatives are:
1) Wrap it in #ifdef TARGET_VXWORKS_RTP.
2) Provide an always-false definition of TARGET_VXWORKS_RTP in
arm.h, i386.h, etc. Also provide dummy definitions of the
VXWORKS_GOTT_* macros.
3) Provide an always-false definition of TARGET_VXWORKS_RTP in
defaults.h. Also provide dummy definitions of the VXWORKS_GOTT_*
macros.
4) Like (3), but provide the real VxWorks default values of the
VXWORKS_GOTT_* macros (rather than dummy ones).
but I'm open to others.
FWIW, I've attached a proto-patch for (4) below. One good thing about
(4) is that it seems to be the least redundant option. One bad thing
is that it leaks OS-specific stuff into the main part of the compiler.
I suppose we do have some precedent for that with the ELF-related code,
but I can see that it's not something we want to encourage.
Richard
gcc/
* defaults.h (TARGET_VXWORKS_RTP, VXWORKS_GOTT_BASE)
(VXWORKS_GOTT_INDEX): Define.
* config/vxworks.h (VXWORKS_GOTT_BASE, VXWORKS_GOTT_INDEX): Delete.
* doc/tm.texi (TARGET_VXWORKS_RTP, VXWORKS_GOTT_BASE
(VXWORKS_GOTT_INDEX): Document.
Index: gcc/defaults.h
===================================================================
--- gcc/defaults.h (revision 122476)
+++ gcc/defaults.h (working copy)
@@ -906,4 +906,14 @@ #define HARD_REGNO_NREGS_HAS_PADDING(REG
#define HARD_REGNO_NREGS_WITH_PADDING(REGNO, MODE) -1
#endif
+#ifndef TARGET_VXWORKS_RTP
+#define TARGET_VXWORKS_RTP false
+#endif
+#ifndef VXWORKS_GOTT_BASE
+#define VXWORKS_GOTT_BASE "__GOTT_BASE__"
+#endif
+#ifndef VXWORKS_GOTT_INDEX
+#define VXWORKS_GOTT_INDEX "__GOTT_INDEX__"
+#endif
+
#endif /* ! GCC_DEFAULTS_H */
Index: gcc/config/vxworks.h
===================================================================
--- gcc/config/vxworks.h (revision 122473)
+++ gcc/config/vxworks.h (working copy)
@@ -97,11 +97,4 @@ #define TARGET_ASM_DESTRUCTOR vxworks_as
extern void vxworks_asm_out_constructor (rtx symbol, int priority);
extern void vxworks_asm_out_destructor (rtx symbol, int priority);
-/* The name of the symbol for the table of GOTs in a particular
- RTP. */
-#define VXWORKS_GOTT_BASE "__GOTT_BASE__"
-/* The name of the symbol for the index into the table of GOTs for the
- GOT associated with the current shared library. */
-#define VXWORKS_GOTT_INDEX "__GOTT_INDEX__"
-
#define VXWORKS_KIND VXWORKS_KIND_NORMAL
Index: gcc/doc/tm.texi
===================================================================
--- gcc/doc/tm.texi (revision 122473)
+++ gcc/doc/tm.texi (working copy)
@@ -53,6 +53,7 @@ through the macros defined in the @file{
* MIPS Coprocessors:: MIPS coprocessor support and how to customize it.
* PCH Target:: Validity checking for precompiled headers.
* C++ ABI:: Controlling C++ ABI changes.
+* VxWorks:: VxWorks-specific macros.
* Misc:: Everything else.
@end menu
@@ -9176,6 +9177,29 @@ defined. Use this hook to make adjustme
visibility or perform any other required target modifications).
@end deftypefn
+@node VxWorks
+@section VxWorks-specific Parameters
+@cindex VxWorks
+
+Several backends have code to support the VxWorks PIC model.
+Rather than hide this code in preprocessor conditions, it is
+convenient to ensure that certain cross-target macros are always
+defined.
+
+@defmac TARGET_VXWORKS_RTP
+True if generating code for a VxWorks RTP.
+@end defmac
+
+@defmac VXWORKS_GOTT_BASE
+A symbol that points to the table of GOTs used in RTP PIC.
+The default is @code{__GOTT_BASE__}.
+@end defmac
+
+@defmac VXWORKS_GOTT_INDEX
+A symbol that gives the index of the current module's GOT in
+@code{VXWORKS_GOTT_BASE}. The default is @code{__GOTT_INDEX__}.
+@end defmac
+
@node Misc
@section Miscellaneous Parameters
@cindex parameters, miscellaneous