Next:Position Independent Code, Previous:Adjusting the Instruction Scheduler, Up:Target Description Macros and Functions [Contents][Index]
An object file is divided into sections containing different types ofdata. In the most common case, there are three sections: thetextsection, which holds instructions and read-only data; thedatasection, which holds initialized writable data; and thebsssection, which holds uninitialized data. Some systems have other kindsof sections.
varasm.cc provides several well-known sections, such astext_section,data_section andbss_section.The normal way of controlling afoo_section variableis to define the associatedFOO_SECTION_ASM_OP macro,as described below. The macros are only read once, whenvarasm.ccinitializes itself, so their values must be run-time constants.They may however depend on command-line flags.
Note: Some run-time files, suchcrtstuff.c, also makeuse of theFOO_SECTION_ASM_OP macros, and expect themto be string literals.
Some assemblers require a different string to be written every time asection is selected. If your assembler falls into this category, youshould define theTARGET_ASM_INIT_SECTIONS hook and useget_unnamed_section to set up the sections.
You must always create atext_section, either by definingTEXT_SECTION_ASM_OP or by initializingtext_sectioninTARGET_ASM_INIT_SECTIONS. The same is true ofdata_section andDATA_SECTION_ASM_OP. If you do notcreate a distinctreadonly_data_section, the default is toreusetext_section.
All the othervarasm.cc sections are optional, and are nullif the target does not provide them.
A C expression whose value is a string, including spacing, containing theassembler operation that should precede instructions and read-only data.Normally"\t.text" is right.
If defined, a C string constant for the name of the section containing mostfrequently executed functions of the program. If not defined, GCC will providea default definition if the target supports named sections.
If defined, a C string constant for the name of the section containing unlikelyexecuted functions in the program.
A C expression whose value is a string, including spacing, containing theassembler operation to identify the following data as writable initializeddata. Normally"\t.data" is right.
If defined, a C expression whose value is a string, including spacing,containing the assembler operation to identify the following data asinitialized, writable small data.
A C expression whose value is a string, including spacing, containing theassembler operation to identify the following data as read-only initializeddata.
If defined, a C expression whose value is a string, including spacing,containing the assembler operation to identify the following data asuninitialized global data. If not defined, andASM_OUTPUT_ALIGNED_BSS not defined,uninitialized global data will be output in the data section if-fno-common is passed, otherwiseASM_OUTPUT_COMMON will beused.
If defined, a C expression whose value is a string, including spacing,containing the assembler operation to identify the following data asuninitialized, writable small data.
If defined, a C expression whose value is a string containing theassembler operation to identify the following data as thread-localcommon data. The default is".tls_common".
If defined, a C expression whose value is a character constantcontaining the flag used to mark a section as a TLS section. Thedefault is'T'.
If defined, a C expression whose value is a string, including spacing,containing the assembler operation to identify the following data asinitialization code. If not defined, GCC will assume such a section doesnot exist. This section has no correspondinginit_sectionvariable; it is used entirely in runtime code.
If defined, a C expression whose value is a string, including spacing,containing the assembler operation to identify the following data asfinalization code. If not defined, GCC will assume such a section doesnot exist. This section has no correspondingfini_sectionvariable; it is used entirely in runtime code.
If defined, a C expression whose value is a string, including spacing,containing the assembler operation to identify the following data aspart of the.init_array (or equivalent) section. If notdefined, GCC will assume such a section does not exist. Do not defineboth this macro andINIT_SECTION_ASM_OP.
If defined, a C expression whose value is a string, including spacing,containing the assembler operation to identify the following data aspart of the.fini_array (or equivalent) section. If notdefined, GCC will assume such a section does not exist. Do not defineboth this macro andFINI_SECTION_ASM_OP.
If defined, a C expression whose value is a character constantcontaining the flag used to mark a machine-dependent section. Thiscorresponds to theSECTION_MACH_DEP section flag.
If defined, an ASM statement that switches to a different sectionviasection_op, callsfunction, and switches back tothe text section. This is used incrtstuff.c ifINIT_SECTION_ASM_OP orFINI_SECTION_ASM_OP to callsto initialization and finalization functions from the init and finisections. By default, this macro uses a simple function call. Someports need hand-crafted assembly code to avoid dependencies onregisters initialized in the function prologue or to ensure thatconstant pools don’t end up too far way in the text section.
If defined, a string which names the section into which smallvariables defined in crtstuff and libgcc should go. This is usefulwhen the target has options for optimizing access to small data, andyou want the crtstuff and libgcc routines to be conservative in whatthey expect of your application yet liberal in what your applicationexpects. For example, for targets with a.sdata section (likeMIPS), you could compile crtstuff with-G 0 so that it doesn’trequire small data support from your application, but use this macroto put small data into.sdata so that your application canaccess these variables whether it uses small data or not.
If defined, an ASM statement that aligns a code section to somearbitrary boundary. This is used to force all fragments of the.init and.fini sections to have to same alignmentand thus prevent the linker from having to add any padding.
Define this macro to be an expression with a nonzero value if jumptables (fortablejump insns) should be output in the textsection, along with the assembler instructions. Otherwise, thereadonly data section is used.
This macro is irrelevant if there is no separate readonly data section.
voidTARGET_ASM_INIT_SECTIONS(void) ¶Define this hook if you need to do something special to set up thevarasm.cc sections, or if your target has some special sectionsof its own that you need to create.
GCC calls this hook after processing the command line, but before writingany assembly code, and before calling any of the section-returning hooksdescribed below.
intTARGET_ASM_RELOC_RW_MASK(void) ¶Return a mask describing how relocations should be treated whenselecting sections. Bit 1 should be set if global relocationsshould be placed in a read-write section; bit 0 should be set iflocal relocations should be placed in a read-write section.
The default version of this function returns 3 when-fpicis in effect, and 0 otherwise. The hook is typically redefinedwhen the target cannot support (some kinds of) dynamic relocationsin read-only sections even in executables.
boolTARGET_ASM_GENERATE_PIC_ADDR_DIFF_VEC(void) ¶Return true to generate ADDR_DIF_VEC tableor false to generate ADDR_VEC table for jumps in case of -fPIC.
The default version of this function returns true if flag_picequals true and false otherwise
section *TARGET_ASM_SELECT_SECTION(treeexp, intreloc, unsigned HOST_WIDE_INTalign) ¶Return the section into whichexp should be placed. You canassume thatexp is either aVAR_DECL node or a constant ofsome sort.reloc indicates whether the initial value ofexprequires link-time relocations. Bit 0 is set when variable containslocal relocations only, while bit 1 is set for global relocations.align is the constant alignment in bits.
The default version of this function takes care of putting read-onlyvariables inreadonly_data_section.
See alsoUSE_SELECT_SECTION_FOR_FUNCTIONS.
Define this macro if you wish TARGET_ASM_SELECT_SECTION to be calledforFUNCTION_DECLs as well as for variables and constants.
In the case of aFUNCTION_DECL,reloc will be zero if thefunction has been determined to be likely to be called, and nonzero ifit is unlikely to be called.
voidTARGET_ASM_UNIQUE_SECTION(treedecl, intreloc) ¶Build up a unique section name, expressed as aSTRING_CST node,and assign it to ‘DECL_SECTION_NAME (decl)’.As withTARGET_ASM_SELECT_SECTION,reloc indicates whetherthe initial value ofexp requires link-time relocations.
The default version of this function appends the symbol name to theELF section name that would normally be used for the symbol. Forexample, the functionfoo would be placed in.text.foo.Whatever the actual target object format, this is often good enough.
section *TARGET_ASM_FUNCTION_RODATA_SECTION(treedecl, boolrelocatable) ¶Return the readonly data or reloc readonly data section associated with‘DECL_SECTION_NAME (decl)’.relocatable selects the latterover the former.The default version of this function selects.gnu.linkonce.r.name ifthe function’s section is.gnu.linkonce.t.name,.rodata.nameor.data.rel.ro.name if function is in.text.name, andthe normal readonly-data or reloc readonly data section otherwise.
const char *TARGET_ASM_MERGEABLE_RODATA_PREFIX ¶Usually, the compiler uses the prefix".rodata" to constructsection names for mergeable constant data. Define this macro to overridethe string if a different section name should be used.
section *TARGET_ASM_TM_CLONE_TABLE_SECTION(void) ¶Return the section that should be used for transactional memory clonetables.
section *TARGET_ASM_SELECT_RTX_SECTION(machine_modemode, rtxx, unsigned HOST_WIDE_INTalign) ¶Return the section into which a constantx, of modemode,should be placed. You can assume thatx is some kind ofconstant in RTL. The argumentmode is redundant except in thecase of aconst_int rtx.align is the constant alignmentin bits.
The default version of this function takes care of putting symbolicconstants inflag_pic mode indata_section and everythingelse inreadonly_data_section.
treeTARGET_MANGLE_DECL_ASSEMBLER_NAME(treedecl, treeid) ¶Define this hook if you need to postprocess the assembler name generatedby target-independent code. Theid provided to this hook will bethe computed name (e.g., the macroDECL_NAME of thedecl in C,or the mangled name of thedecl in C++). The return value of thehook is anIDENTIFIER_NODE for the appropriate mangled name onyour target system. The default implementation of this hook justreturns theid provided.
voidTARGET_ENCODE_SECTION_INFO(treedecl, rtxrtl, intnew_decl_p) ¶Define this hook if references to a symbol or a constant must betreated differently depending on something about the variable orfunction named by the symbol (such as what section it is in).
The hook is executed immediately after rtl has been created fordecl, which may be a variable or function declaration oran entry in the constant pool. In either case,rtl is thertl in question. Donot useDECL_RTL (decl)in this hook; that field may not have been initialized yet.
In the case of a constant, it is safe to assume that the rtl isamem whose address is asymbol_ref. Most declswill also have this form, but that is not guaranteed. Globalregister variables, for instance, will have areg for theirrtl. (Normally the right thing to do with such unusual rtl isleave it alone.)
Thenew_decl_p argument will be true if this is the first timethatTARGET_ENCODE_SECTION_INFO has been invoked on this decl. It willbe false for subsequent invocations, which will happen for duplicatedeclarations. Whether or not anything must be done for the duplicatedeclaration depends on whether the hook examinesDECL_ATTRIBUTES.new_decl_p is always true when the hook is called for a constant.
The usual thing for this hook to do is to record flags in thesymbol_ref, usingSYMBOL_REF_FLAG orSYMBOL_REF_FLAGS.Historically, the name string was modified if it was necessary toencode more than one bit of information, but this practice is nowdiscouraged; useSYMBOL_REF_FLAGS.
The default definition of this hook,default_encode_section_infoinvarasm.cc, sets a number of commonly-useful bits inSYMBOL_REF_FLAGS. Check whether the default does what you needbefore overriding it.
const char *TARGET_STRIP_NAME_ENCODING(const char *name) ¶Decodename and return the real name part, sansthe characters thatTARGET_ENCODE_SECTION_INFOmay have added.
boolTARGET_IN_SMALL_DATA_P(const_treeexp) ¶Returns true ifexp should be placed into a “small data” section.The default version of this hook always returns false.
boolTARGET_HAVE_SRODATA_SECTION ¶Contains the value true if the target places read-only“small data” into a separate section. The default value is false.
boolTARGET_PROFILE_BEFORE_PROLOGUE(void) ¶It returns true if target wants profile code emitted before prologue.
The default version of this hook use the target macroPROFILE_BEFORE_PROLOGUE.
boolTARGET_BINDS_LOCAL_P(const_treeexp) ¶Returns true ifexp names an object for which name resolutionrules must resolve to the current “module” (dynamic shared libraryor executable image).
The default version of this hook implements the name resolution rulesfor ELF, which has a looser model of global name binding than othercurrently supported object file formats.
boolTARGET_HAVE_TLS ¶Contains the value true if the target supports thread-local storage.The default value is false.
Next:Position Independent Code, Previous:Adjusting the Instruction Scheduler, Up:Target Description Macros and Functions [Contents][Index]