Movatterモバイル変換


[0]ホーム

URL:


Next:, Up:Defining the Output Assembler Language   [Contents][Index]


17.22.1 The Overall Framework of an Assembler File

This describes the overall framework of an assembly file.

Target Hook:voidTARGET_ASM_FILE_START(void)

Output toasm_out_file any text which the assembler expects tofind at the beginning of a file. The default behavior is controlledby two flags, documented below. Unless your target’s assembler isquite unusual, if you override the default, you should calldefault_file_start at some point in your target hook. Thislets other target files rely on these variables.

Target Hook:boolTARGET_ASM_FILE_START_APP_OFF

If this flag is true, the text of the macroASM_APP_OFF will beprinted as the very first line in the assembly file, unless-fverbose-asm is in effect. (If that macro has been definedto the empty string, this variable has no effect.) With the normaldefinition ofASM_APP_OFF, the effect is to notify the GNUassembler that it need not bother stripping comments or extrawhitespace from its input. This allows it to work a bit faster.

The default is false. You should not set it to true unless you haveverified that your port does not generate any extra whitespace orcomments that will cause GAS to issue errors in NO_APP mode.

Target Hook:boolTARGET_ASM_FILE_START_FILE_DIRECTIVE

If this flag is true,output_file_directive will be calledfor the primary source file, immediately after printingASM_APP_OFF (if that is enabled). Most ELF assemblers expectthis to be done. The default is false.

Target Hook:voidTARGET_ASM_FILE_END(void)

Output toasm_out_file any text which the assembler expectsto find at the end of a file. The default is to output nothing.

Function:voidfile_end_indicate_exec_stack()

Some systems use a common convention, the ‘.note.GNU-stack’special section, to indicate whether or not an object file relies onthe stack being executable. If your system uses this convention, youshould defineTARGET_ASM_FILE_END to this function. If youneed to do other things in that hook, have your hook function callthis function.

Target Hook:voidTARGET_ASM_LTO_START(void)

Output toasm_out_file any text which the assembler expectsto find at the start of an LTO section. The default is to outputnothing.

Target Hook:voidTARGET_ASM_LTO_END(void)

Output toasm_out_file any text which the assembler expectsto find at the end of an LTO section. The default is to outputnothing.

Target Hook:voidTARGET_ASM_CODE_END(void)

Output toasm_out_file any text which is needed before emittingunwind info and debug info at the end of a file. Some targets emithere PIC setup thunks that cannot be emitted at the end of file,because they couldn’t have unwind info then. The default is to outputnothing.

Macro:ASM_COMMENT_START

A C string constant describing how to begin a comment in the targetassembler language. The compiler assumes that the comment will end atthe end of the line.

Macro:ASM_APP_ON

A C string constant for text to be output before eachasmstatement or group of consecutive ones. Normally this is"#APP", which is a comment that has no effect on mostassemblers but tells the GNU assembler that it must check the linesthat follow for all valid assembler constructs.

Macro:ASM_APP_OFF

A C string constant for text to be output after eachasmstatement or group of consecutive ones. Normally this is"#NO_APP", which tells the GNU assembler to resume making thetime-saving assumptions that are valid for ordinary compiler output.

Macro:ASM_OUTPUT_SOURCE_FILENAME(stream,name)

A C statement to output COFF information or DWARF debugging informationwhich indicates that filenamename is the current source file tothe stdio streamstream.

This macro need not be defined if the standard form of outputfor the file format in use is appropriate.

Target Hook:voidTARGET_ASM_OUTPUT_SOURCE_FILENAME(FILE *file, const char *name)

Output DWARF debugging information which indicates that filenamename is the current source file to the stdio streamfile.

This target hook need not be defined if the standard form of outputfor the file format in use is appropriate.

Target Hook:voidTARGET_ASM_OUTPUT_IDENT(const char *name)

Output a string based onname, suitable for the ‘#ident’directive, or the equivalent directive or pragma in non-C-family languages.If this hook is not defined, nothing is output for the ‘#ident’directive.

Macro:OUTPUT_QUOTED_STRING(stream,string)

A C statement to output the stringstring to the stdio streamstream. If you do not call the functionoutput_quoted_stringin your config files, GCC will only call it to output filenames tothe assembler source. So you can use it to canonicalize the formatof the filename using this macro.

Target Hook:voidTARGET_ASM_NAMED_SECTION(const char *name, unsigned intflags, treedecl)

Output assembly directives to switch to sectionname. The sectionshould have attributes as specified byflags, which is a bit maskof theSECTION_* flags defined inoutput.h. Ifdeclis non-NULL, it is theVAR_DECL orFUNCTION_DECL with whichthis section is associated.

Target Hook:boolTARGET_ASM_ELF_FLAGS_NUMERIC(unsigned intflags, unsigned int *num)

This hook can be used to encode ELF section flags for which no lettercode has been defined in the assembler. It is called bydefault_asm_named_section whenever the section flags need to beemitted in the assembler output. If the hook returns true, then thenumerical value for ELF section flags should be calculated fromflags and saved in*num; the value is printed out instead of thenormal sequence of letter codes. If the hook is not defined, or if itreturns false, thennum is ignored and the traditional letter sequenceis emitted.

Target Hook:section *TARGET_ASM_FUNCTION_SECTION(treedecl, enum node_frequencyfreq, boolstartup, boolexit)

Return preferred text (sub)section for functiondecl.Main purpose of this function is to separate cold, normal and hotfunctions.startup is true when function is known to be used onlyat startup (from static constructors or it ismain()).exit is true when function is known to be used only at exit(from static destructors).Return NULL if function should go to default text section.

Target Hook:voidTARGET_ASM_FUNCTION_SWITCHED_TEXT_SECTIONS(FILE *file, treedecl, boolnew_is_cold)

Used by the target to emit any assembler directives or additionallabels needed when a function is partitioned between differentsections. Output should be written tofile. The functiondecl is available asdecl and the new section is ‘cold’ ifnew_is_cold istrue.

Common Target Hook:boolTARGET_HAVE_NAMED_SECTIONS

This flag is true if the target supportsTARGET_ASM_NAMED_SECTION.It must not be modified by command-line option processing.

Target Hook:boolTARGET_HAVE_SWITCHABLE_BSS_SECTIONS

This flag is true if we can create zeroed data by switching to a BSSsection and then usingASM_OUTPUT_SKIP to allocate the space.This is true on most ELF targets.

Target Hook:unsigned intTARGET_SECTION_TYPE_FLAGS(treedecl, const char *name, intreloc)

Choose a set of section attributes for use byTARGET_ASM_NAMED_SECTIONbased on a variable or function decl, a section name, and whether or not thedeclaration’s initializer may contain runtime relocations.decl may benull, in which case read-write data should be assumed.

The default version of this function handles choosing code vs data,read-only vs read-write data, andflag_pic. You should onlyneed to override this if your target has special flags that might beset via__attribute__.

Target Hook:voidTARGET_ASM_RECORD_GCC_SWITCHES(const char *)

Provides the target with the ability to record the gcc command lineswitches provided as argument.

By default this hook is set to NULL, but an example implementation isprovided for ELF based targets. Calledelf_record_gcc_switches,it records the switches as ASCII text inside a new, string mergeablesection in the assembler output file. The name of the new section isprovided by theTARGET_ASM_RECORD_GCC_SWITCHES_SECTION targethook.

Target Hook:const char *TARGET_ASM_RECORD_GCC_SWITCHES_SECTION

This is the name of the section that will be created by the exampleELF implementation of theTARGET_ASM_RECORD_GCC_SWITCHES targethook.


Next:Output of Data, Up:Defining the Output Assembler Language   [Contents][Index]


[8]ページ先頭

©2009-2026 Movatter.jp