OSDN Git Service

* config/rs6000/xcoff.h (EH_FRAME_IN_DATA_SECTION): New.
[pf3gnuchains/gcc-fork.git] / gcc / doc / tm.texi
index ee621ae..538888b 100644 (file)
@@ -396,7 +396,7 @@ the effect you need.
 
 @findex LINK_ELIMINATE_DUPLICATE_LDIRECTORIES
 @item LINK_ELIMINATE_DUPLICATE_LDIRECTORIES
-A nonzero value causes collect2 to remove duplicate @option{-L@var{directory}} search
+A nonzero value causes @command{collect2} to remove duplicate @option{-L@var{directory}} search
 directories from linking commands.  Do not give it a nonzero value if
 removing duplicate search directories changes the linker's semantics.
 
@@ -1015,18 +1015,25 @@ size of an integer.
 
 @findex STACK_BOUNDARY
 @item STACK_BOUNDARY
-Define this macro if there is a guaranteed alignment for the stack
-pointer on this machine.  The definition is a C expression
-for the desired alignment (measured in bits).  This value is used as a
-default if @code{PREFERRED_STACK_BOUNDARY} is not defined.
+Define this macro to the minimum alignment enforced by hardware for the
+stack pointer on this machine.  The definition is a C expression for the
+desired alignment (measured in bits).  This value is used as a default
+if @code{PREFERRED_STACK_BOUNDARY} is not defined.  On most machines,
+this should be the same as @code{PARM_BOUNDARY}.
 
 @findex PREFERRED_STACK_BOUNDARY
 @item PREFERRED_STACK_BOUNDARY
-Define this macro if you wish to preserve a certain alignment for
-the stack pointer.  The definition is a C expression
-for the desired alignment (measured in bits).  If @code{STACK_BOUNDARY} is
-also defined, this macro must evaluate to a value equal to or larger
-than @code{STACK_BOUNDARY}.
+Define this macro if you wish to preserve a certain alignment for the
+stack pointer, greater than what the hardware enforces.  The definition
+is a C expression for the desired alignment (measured in bits).  This
+macro must evaluate to a value equal to or larger than
+@code{STACK_BOUNDARY}.
+
+@findex FORCE_PREFERRED_STACK_BOUNDARY_IN_MAIN
+@item FORCE_PREFERRED_STACK_BOUNDARY_IN_MAIN
+A C expression that evaluates true if @code{PREFERRED_STACK_BOUNDARY} is
+not guaranteed by the runtime and we should emit code to align the stack
+at the beginning of @code{main}.
 
 @cindex @code{PUSH_ROUNDING}, interaction with @code{PREFERRED_STACK_BOUNDARY}
 If @code{PUSH_ROUNDING} is not defined, the stack will always be aligned
@@ -1304,7 +1311,7 @@ need to define this macro when the format is IEEE@.
 
 @findex VAX_FLOAT_FORMAT
 @item VAX_FLOAT_FORMAT
-This code indicates the peculiar format used on the Vax.
+This code indicates the peculiar format used on the VAX.
 
 @findex IBM_FLOAT_FORMAT
 @item IBM_FLOAT_FORMAT
@@ -1700,6 +1707,17 @@ If a register has 0 in @code{CALL_USED_REGISTERS}, the compiler
 automatically saves it on function entry and restores it on function
 exit, if the register is used within the function.
 
+@findex CALL_REALLY_USED_REGISTERS
+@item CALL_REALLY_USED_REGISTERS
+@cindex call-used register
+@cindex call-clobbered register
+@cindex call-saved register
+Like @code{CALL_USED_REGISTERS} except this macro doesn't require 
+that the entire set of @code{FIXED_REGISTERS} be included.  
+(@code{CALL_USED_REGISTERS} must be a superset of @code{FIXED_REGISTERS}).
+This macro is optional.  If not specified, it defaults to the value 
+of @code{CALL_USED_REGISTERS}.
+
 @findex HARD_REGNO_CALL_PART_CLOBBERED
 @item HARD_REGNO_CALL_PART_CLOBBERED (@var{regno}, @var{mode})
 @cindex call-used register
@@ -3224,7 +3242,7 @@ in the compiler and was not mentioned in the C code being compiled.
 stack.  If a variable number of bytes is passed, it is zero, and
 argument popping will always be the responsibility of the calling function.
 
-On the Vax, all functions always pop their arguments, so the definition
+On the VAX, all functions always pop their arguments, so the definition
 of this macro is @var{stack-size}.  On the 68000, using the standard
 calling convention, no functions pop their arguments, so the value of
 the macro is always 0 in this case.  But an alternative calling
@@ -3263,7 +3281,7 @@ The value of the expression is usually either a @code{reg} RTX for the
 hard register in which to pass the argument, or zero to pass the
 argument on the stack.
 
-For machines like the Vax and 68000, where normally all arguments are
+For machines like the VAX and 68000, where normally all arguments are
 pushed, zero suffices as a definition.
 
 The value of the expression can also be a @code{parallel} RTX@.  This is
@@ -5582,14 +5600,18 @@ This macro is irrelevant if there is no separate readonly data section.
 
 @findex ENCODE_SECTION_INFO
 @item ENCODE_SECTION_INFO (@var{decl})
-Define this macro if references to a symbol must be treated differently
-depending on something about the variable or function named by the
-symbol (such as what section it is in).
-
-The macro definition, if any, is executed immediately after the rtl for
-@var{decl} has been created and stored in @code{DECL_RTL (@var{decl})}.
-The value of the rtl will be a @code{mem} whose address is a
-@code{symbol_ref}.
+Define this macro if references to a symbol or a constant must be
+treated differently depending on something about the variable or
+function named by the symbol (such as what section it is in).
+
+The macro definition, if any, is executed under two circumstances.  One
+is immediately after the rtl for @var{decl} that represents a variable
+or a function has been created and stored in @code{DECL_RTL
+(@var{decl})}.  The value of the rtl will be a @code{mem} whose address
+is a @code{symbol_ref}.  The other is immediately after the rtl for
+@var{decl} that represents a constant has been created and stored in
+@code{TREE_CST_RTL (@var{decl})}.  The macro is called once for each
+distinct constant in a source file.
 
 @cindex @code{SYMBOL_REF_FLAG}, in @code{ENCODE_SECTION_INFO}
 The usual thing for this macro to do is to record a flag in the
@@ -5603,14 +5625,6 @@ Decode @var{sym_name} and store the real name part in @var{var}, sans
 the characters that encode section info.  Define this macro if
 @code{ENCODE_SECTION_INFO} alters the symbol's name string.
 
-@findex UNIQUE_SECTION_P
-@item UNIQUE_SECTION_P (@var{decl})
-A C expression which evaluates to true if @var{decl} should be placed
-into a unique section for some target-specific reason.  If you do not
-define this macro, the default is @samp{0}.  Note that the flag
-@option{-ffunction-sections} will also cause functions to be placed into
-unique sections.
-
 @findex UNIQUE_SECTION
 @item UNIQUE_SECTION (@var{decl}, @var{reloc})
 A C statement to build up a unique section name, expressed as a
@@ -5792,21 +5806,6 @@ A C statement to output something to the assembler file to handle a
 @samp{#ident} directive containing the text @var{string}.  If this
 macro is not defined, nothing is output for a @samp{#ident} directive.
 
-@findex ASM_OUTPUT_SECTION_NAME
-@item ASM_OUTPUT_SECTION_NAME (@var{stream}, @var{decl}, @var{name}, @var{reloc})
-A C statement to output something to the assembler file to switch to section
-@var{name} for object @var{decl} which is either a @code{FUNCTION_DECL}, a
-@code{VAR_DECL} or @code{NULL_TREE}.  @var{reloc}
-indicates whether the initial value of @var{exp} requires link-time
-relocations.  The string given by @var{name} will always be the
-canonical version stored in the global stringpool.
-
-Some target formats do not support arbitrary sections.  Do not define
-this macro in such cases.
-
-At present this macro is only used to support section attributes.
-When this macro is undefined, section attributes are disabled.
-
 @findex OBJC_PROLOGUE
 @item OBJC_PROLOGUE
 A C statement to output any assembler statements which are required to
@@ -5814,6 +5813,32 @@ precede any Objective-C object definitions or message sending.  The
 statement is executed only when compiling an Objective-C program.
 @end table
 
+@deftypefn {Target Hook} void TARGET_ASM_NAMED_SECTION (const char *@var{name}, unsigned int @var{flags}, unsigned int @var{align})
+Output assembly directives to switch to section @var{name}.  The section
+should have attributes as specified by @var{flags}, which is a bit mask
+of the @code{SECTION_*} flags defined in @file{output.h}.  If @var{align}
+is non-zero, it contains an alignment in bytes to be used for the section,
+otherwise some target default should be used.  Only targets that must 
+specify an alignment within the section directive need pay attention to
+@var{align} -- we will still use @code{ASM_OUTPUT_ALIGN}.
+@end deftypefn
+
+@deftypefn {Target Hook} bool TARGET_HAVE_NAMED_SECTIONS
+This flag is true if the target supports @code{TARGET_ASM_NAMED_SECTION}.
+@end deftypefn
+
+@deftypefn {Target Hook} {unsigned int} TARGET_SECTION_TYPE_FLAGS (tree @var{decl}, const char *@var{name}, int @var{reloc})
+Choose a set of section attributes for use by @code{TARGET_ASM_NAMED_SECTION}
+based on a variable or function decl, a section name, and whether or not the
+declaration's initializer may contain runtime relocations.  @var{decl} may be
+ null, in which case read-write data should be assumed.
+
+The default version if this function handles choosing code vs data,
+read-only vs read-write data, and @code{flag_pic}.  You should only
+need to override this if your target has special flags that might be
+set via @code{__attribute__}.
+@end deftypefn
+
 @need 2000
 @node Data Output
 @subsection Output of Data
@@ -6298,7 +6323,7 @@ systems.  This macro is used in @code{assemble_name}.
 @ignore @c Seems not to exist anymore.
 @findex ASM_OUTPUT_LABELREF_AS_INT
 @item ASM_OUTPUT_LABELREF_AS_INT (@var{file}, @var{label})
-Define this macro for systems that use the program @code{collect2}.
+Define this macro for systems that use the program @command{collect2}.
 The definition should be a C statement to output a word containing
 a reference to the label @var{label}.
 @end ignore
@@ -6526,49 +6551,56 @@ the constructor section to point to that function.  The linker
 accumulates all these words into one contiguous @samp{.ctors} section.
 Termination functions are handled similarly.
 
-To use this method, you need appropriate definitions of the macros
-@code{ASM_OUTPUT_CONSTRUCTOR} and @code{ASM_OUTPUT_DESTRUCTOR}.  Usually
-you can get them by including @file{svr4.h}.
+This method will be chosen as the default by @file{target-def.h} if
+@code{TARGET_ASM_NAMED_SECTION} is defined.  A target that does not
+support arbitrary sections, but does support special designated 
+constructor and destructor sections may define @code{CTORS_SECTION_ASM_OP}
+and @code{DTORS_SECTION_ASM_OP} to achieve the same effect.
 
 When arbitrary sections are available, there are two variants, depending
 upon how the code in @file{crtstuff.c} is called.  On systems that
-support an @dfn{init} section which is executed at program startup,
+support a @dfn{.init} section which is executed at program startup,
 parts of @file{crtstuff.c} are compiled into that section.  The
 program is linked by the @code{gcc} driver like this:
 
 @example
-ld -o @var{output_file} crtbegin.o @dots{} crtend.o -lgcc
+ld -o @var{output_file} crti.o crtbegin.o @dots{} -lgcc crtend.o crtn.o
 @end example
 
-The head of a function (@code{__do_global_ctors}) appears in the init
-section of @file{crtbegin.o}; the remainder of the function appears in
-the init section of @file{crtend.o}.  The linker will pull these two
-parts of the section together, making a whole function.  If any of the
-user's object files linked into the middle of it contribute code, then that
-code will be executed as part of the body of @code{__do_global_ctors}.
+The prologue of a function (@code{__init}) appears in the @code{.init}
+section of @file{crti.o}; the epilogue appears in @file{crtn.o}.  Likewise
+for the function @code{__fini} in the @dfn{.fini} section.  Normally these
+files are provided by the operating system or by the GNU C library, but
+are provided by GCC for a few targets.
+
+The objects @file{crtbegin.o} and @file{crtend.o} are (for most targets)
+compiled from @file{crtstuff.c}.  They contain, among other things, code
+fragments within the @code{.init} and @code{.fini} sections that branch
+to routines in the @code{.text} section.  The linker will pull all parts
+of a section together, which results in a complete @code{__init} function
+that invokes the routines we need at startup.
 
 To use this variant, you must define the @code{INIT_SECTION_ASM_OP}
 macro properly.
 
-If no init section is available, do not define
-@code{INIT_SECTION_ASM_OP}.  Then @code{__do_global_ctors} is built into
-the text section like all other functions, and resides in
-@file{libgcc.a}.  When GCC compiles any function called @code{main}, it
-inserts a procedure call to @code{__main} as the first executable code
-after the function prologue.  The @code{__main} function, also defined
-in @file{libgcc2.c}, simply calls @file{__do_global_ctors}.
+If no init section is available, when GCC compiles any function called
+@code{main} (or more accurately, any function designated as a program
+entry point by the language front end calling @code{expand_main_function}),
+it inserts a procedure call to @code{__main} as the first executable code
+after the function prologue.  The @code{__main} function is defined
+in @file{libgcc2.c} and runs the global constructors.
 
 In file formats that don't support arbitrary sections, there are again
 two variants.  In the simplest variant, the GNU linker (GNU @code{ld})
 and an `a.out' format must be used.  In this case,
-@code{ASM_OUTPUT_CONSTRUCTOR} is defined to produce a @code{.stabs}
+@code{TARGET_ASM_CONSTRUCTOR} is defined to produce a @code{.stabs}
 entry of type @samp{N_SETT}, referencing the name @code{__CTOR_LIST__},
 and with the address of the void function containing the initialization
 code as its value.  The GNU linker recognizes this as a request to add
-the value to a ``set''; the values are accumulated, and are eventually
+the value to a @dfn{set}; the values are accumulated, and are eventually
 placed in the executable as a vector in the format described above, with
 a leading (ignored) count and a trailing zero element.
-@code{ASM_OUTPUT_DESTRUCTOR} is handled similarly.  Since no init
+@code{TARGET_ASM_DESTRUCTOR} is handled similarly.  Since no init
 section is available, the absence of @code{INIT_SECTION_ASM_OP} causes
 the compilation of @code{main} to call @code{__main} as above, starting
 the initialization process.
@@ -6576,37 +6608,14 @@ the initialization process.
 The last variant uses neither arbitrary sections nor the GNU linker.
 This is preferable when you want to do dynamic linking and when using
 file formats which the GNU linker does not support, such as `ECOFF'@.  In
-this case, @code{ASM_OUTPUT_CONSTRUCTOR} does not produce an
-@code{N_SETT} symbol; initialization and termination functions are
-recognized simply by their names.  This requires an extra program in the
-linkage step, called @code{collect2}.  This program pretends to be the
-linker, for use with GCC; it does its job by running the ordinary
-linker, but also arranges to include the vectors of initialization and
-termination functions.  These functions are called via @code{__main} as
-described above.
-
-Choosing among these configuration options has been simplified by a set
-of operating-system-dependent files in the @file{config} subdirectory.
-These files define all of the relevant parameters.  Usually it is
-sufficient to include one into your specific machine-dependent
-configuration file.  These files are:
-
-@table @file
-@item aoutos.h
-For operating systems using the `a.out' format.
-
-@item next.h
-For operating systems using the `MachO' format.
-
-@item svr3.h
-For System V Release 3 and similar systems using `COFF' format.
-
-@item svr4.h
-For System V Release 4 and similar systems using `ELF' format.
-
-@item vms.h
-For the VMS operating system.
-@end table
+this case, @code{TARGET_HAVE_CTORS_DTORS} is false, initialization and
+termination functions are recognized simply by their names.  This requires
+an extra program in the linkage step, called @command{collect2}.  This program
+pretends to be the linker, for use with GCC; it does its job by running
+the ordinary linker, but also arranges to include the vectors of
+initialization and termination functions.  These functions are called
+via @code{__main} as described above.  In order to use this method,
+@code{use_collect2} must be defined in the target in @file{config.gcc}.
 
 @ifinfo
 The following section describes the specific macros that control and
@@ -6632,10 +6641,9 @@ run the initialization functions.
 @item HAS_INIT_SECTION
 @findex HAS_INIT_SECTION
 If defined, @code{main} will not call @code{__main} as described above.
-This macro should be defined for systems that control the contents of the
-init section on a symbol-by-symbol basis, such as OSF/1, and should not
-be defined explicitly for systems that support
-@code{INIT_SECTION_ASM_OP}.
+This macro should be defined for systems that control start-up code
+on a symbol-by-symbol basis, such as OSF/1, and should not
+be defined explicitly for systems that support @code{INIT_SECTION_ASM_OP}.
 
 @item LD_INIT_SWITCH
 @findex LD_INIT_SWITCH
@@ -6660,65 +6668,65 @@ If nonzero, the C++ @code{init_priority} attribute is supported and the
 compiler should emit instructions to control the order of initialization
 of objects.  If zero, the compiler will issue an error message upon
 encountering an @code{init_priority} attribute.
+@end table
+
+@deftypefn {Target Hook} bool TARGET_HAVE_CTORS_DTORS
+This value is true if the target supports some ``native'' method of
+collecting constructors and destructors to be run at startup and exit.
+It is false if we must use @command{collect2}.
+@end deftypefn
+
+@deftypefn {Target Hook} void TARGET_ASM_CONSTRUCTOR (rtx @var{symbol}, int @var{priority})
+If defined, a function that outputs assembler code to arrange to call
+the function referenced by @var{symbol} at initialization time.
+
+Assume that @var{symbol} is a @code{SYMBOL_REF} for a function taking
+no arguments and with no return value.  If the target supports initialization
+priorities, @var{priority} is a value between 0 and @code{MAX_INIT_PRIORITY};
+otherwise it must be @code{DEFAULT_INIT_PRIORITY}.
 
-@item ASM_OUTPUT_CONSTRUCTOR (@var{stream}, @var{name})
-@findex ASM_OUTPUT_CONSTRUCTOR
-Define this macro as a C statement to output on the stream @var{stream}
-the assembler code to arrange to call the function named @var{name} at
-initialization time.
-
-Assume that @var{name} is the name of a C function generated
-automatically by the compiler.  This function takes no arguments.  Use
-the function @code{assemble_name} to output the name @var{name}; this
-performs any system-specific syntactic transformations such as adding an
-underscore.
-
-If you don't define this macro, nothing special is output to arrange to
-call the function.  This is correct when the function will be called in
-some other manner---for example, by means of the @code{collect2} program,
-which looks through the symbol table to find these functions by their
-names.
-
-@item ASM_OUTPUT_DESTRUCTOR (@var{stream}, @var{name})
-@findex ASM_OUTPUT_DESTRUCTOR
-This is like @code{ASM_OUTPUT_CONSTRUCTOR} but used for termination
+If this macro is is not defined by the target, a suitable default will
+be chosen if (1) the target supports arbitrary section names, (2) the
+target defines @code{CTORS_SECTION_ASM_OP}, or (3) @code{USE_COLLECT2}
+is not defined.
+@end deftypefn
+
+@deftypefn {Target Hook} void TARGET_ASM_DESTRUCTOR (rtx @var{symbol}, int @var{priority})
+This is like @code{TARGET_ASM_CONSTRUCTOR} but used for termination
 functions rather than initialization functions.
+@end deftypefn
 
-When @code{ASM_OUTPUT_CONSTRUCTOR} and @code{ASM_OUTPUT_DESTRUCTOR} are
-defined, the initialization routine generated for the generated object
-file will have static linkage.
-@end table
+If @code{TARGET_HAVE_CTORS_DTORS} is true, the initialization routine
+generated for the generated object file will have static linkage.
 
-If your system uses @code{collect2} as the means of processing
-constructors, then that program normally uses @code{nm} to scan an
-object file for constructor functions to be called.  On such systems you
-must not define @code{ASM_OUTPUT_CONSTRUCTOR} and @code{ASM_OUTPUT_DESTRUCTOR}
-as the object file's initialization routine must have global scope.
+If your system uses @command{collect2} as the means of processing
+constructors, then that program normally uses @command{nm} to scan
+an object file for constructor functions to be called.
 
 On certain kinds of systems, you can define these macros to make
-@code{collect2} work faster (and, in some cases, make it work at all):
+@command{collect2} work faster (and, in some cases, make it work at all):
 
 @table @code
 @findex OBJECT_FORMAT_COFF
 @item OBJECT_FORMAT_COFF
 Define this macro if the system uses COFF (Common Object File Format)
-object files, so that @code{collect2} can assume this format and scan
+object files, so that @command{collect2} can assume this format and scan
 object files directly for dynamic constructor/destructor functions.
 
 @findex OBJECT_FORMAT_ROSE
 @item OBJECT_FORMAT_ROSE
 Define this macro if the system uses ROSE format object files, so that
-@code{collect2} can assume this format and scan object files directly
+@command{collect2} can assume this format and scan object files directly
 for dynamic constructor/destructor functions.
 
-These macros are effective only in a native compiler; @code{collect2} as
-part of a cross compiler always uses @code{nm} for the target machine.
+These macros are effective only in a native compiler; @command{collect2} as
+part of a cross compiler always uses @command{nm} for the target machine.
 
 @findex REAL_NM_FILE_NAME
 @item REAL_NM_FILE_NAME
 Define this macro as a C string constant containing the file name to use
-to execute @code{nm}.  The default is to search the path normally for
-@code{nm}.
+to execute @command{nm}.  The default is to search the path normally for
+@command{nm}.
 
 If your system supports shared libraries and has a program to list the
 dynamic dependencies of a given library or executable, you can define
@@ -6727,8 +6735,8 @@ termination functions in shared libraries:
 
 @findex LDD_SUFFIX
 @item LDD_SUFFIX
-Define this macro to a C string constant containing the name of the
-program which lists dynamic dependencies, like @code{"ldd"} under SunOS 4.
+Define this macro to a C string constant containing the name of the program
+which lists dynamic dependencies, like @command{"ldd"} under SunOS 4.
 
 @findex PARSE_LDD_OUTPUT
 @item PARSE_LDD_OUTPUT (@var{ptr})
@@ -6738,7 +6746,6 @@ of type @code{char *} that points to the beginning of a line of output
 from @code{LDD_SUFFIX}.  If the line lists a dynamic dependency, the
 code must advance @var{ptr} to the beginning of the filename on that
 line.  Otherwise, it must set @var{ptr} to @code{NULL}.
-
 @end table
 
 @node Instruction Output
@@ -7047,21 +7054,30 @@ This macro need not be defined on most platforms.
 A C expression to switch to the section in which the main
 exception table is to be placed (@pxref{Sections}).  The default is a
 section named @code{.gcc_except_table} on machines that support named
-sections via @code{ASM_OUTPUT_SECTION_NAME}, otherwise if @option{-fpic}
+sections via @code{TARGET_ASM_NAMED_SECTION}, otherwise if @option{-fpic}
 or @option{-fPIC} is in effect, the @code{data_section}, otherwise the
 @code{readonly_data_section}.
 
-@findex EH_FRAME_SECTION_ASM_OP
-@item EH_FRAME_SECTION_ASM_OP
-If defined, a C string constant, including spacing, for the assembler
-operation to switch to the section for exception handling frame unwind
-information.  If not defined, GCC will provide a default definition if the
-target supports named sections.  @file{crtstuff.c} uses this macro to
-switch to the appropriate section.
+@findex EH_FRAME_SECTION_NAME
+@item EH_FRAME_SECTION_NAME
+If defined, a C string constant for the name of the section containing
+exception handling frame unwind information.  If not defined, GCC will
+provide a default definition if the target supports named sections.
+@file{crtstuff.c} uses this macro to switch to the appropriate section.
 
 You should define this symbol if your target supports DWARF 2 frame
 unwind information and the default definition does not work.
 
+@findex EH_FRAME_IN_DATA_SECTION
+@item EH_FRAME_IN_DATA_SECTION
+If defined, DWARF 2 frame unwind information will be placed in the
+data section even though the target supports named sections.  This
+might be necessary, for instance, if the system linker does garbage
+collection and sections cannot be marked as not to be collected.
+
+Do not define this macro unless @code{TARGET_ASM_NAMED_SECTION} is
+also defined.
+
 @findex OMIT_EH_TABLE
 @item OMIT_EH_TABLE ()
 A C expression that is nonzero if the normal exception table output