An object file is divided into sections containing different types of data. In the most common case, there are three sections: the text section, which holds instructions and read-only data; the data section, which holds initialized writable data; and the bss section, which holds uninitialized data. Some systems have other kinds of sections.
The compiler must tell the assembler when to switch sections. These macros control what commands to output to tell the assembler this. You can also define additional sections.
TEXT_SECTION_ASM_OP
"\t.text"
is right.
TEXT_SECTION
TEXT_SECTION_ASM_OP
is enough. The MIPS port uses this to sort all functions after all data
declarations.
HOT_TEXT_SECTION_NAME
UNLIKELY_EXECUTED_TEXT_SECTION_NAME
DATA_SECTION_ASM_OP
"\t.data"
is right.
READONLY_DATA_SECTION_ASM_OP
READONLY_DATA_SECTION
READONLY_DATA_SECTION_ASM_OP
if defined, else fall back to text_section
.
The most common definition will be data_section
, if the target
does not have a special read-only data section, and does not put data
in the text section.
SHARED_SECTION_ASM_OP
DATA_SECTION_ASM_OP
will be used.
BSS_SECTION_ASM_OP
ASM_OUTPUT_BSS
nor ASM_OUTPUT_ALIGNED_BSS
are defined,
uninitialized global data will be output in the data section if
-fno-common
is passed, otherwise ASM_OUTPUT_COMMON
will be
used.
SHARED_BSS_SECTION_ASM_OP
BSS_SECTION_ASM_OP
is, the latter will be used.
INIT_SECTION_ASM_OP
FINI_SECTION_ASM_OP
CRT_CALL_STATIC_FUNCTION (
section_op,
function)
crtstuff.c
if
INIT_SECTION_ASM_OP
or FINI_SECTION_ASM_OP
to calls
to initialization and finalization functions from the init and fini
sections. By default, this macro uses a simple function call. Some
ports need hand-crafted assembly code to avoid dependencies on
registers initialized in the function prologue or to ensure that
constant pools don't end up too far way in the text section.
FORCE_CODE_SECTION_ALIGN
.init
and .fini
sections to have to same alignment
and thus prevent the linker from having to add any padding.
EXTRA_SECTIONS
in_text
and in_data
. You need not define this macro
on a system with no other sections (that GCC needs to use).
EXTRA_SECTION_FUNCTIONS
varasm.c
. These
functions should do jobs analogous to those of text_section
and
data_section
, for your additional sections. Do not define this
macro if you do not define EXTRA_SECTIONS
.
JUMP_TABLES_IN_TEXT_SECTION
tablejump
insns) should be output in the text
section, along with the assembler instructions. Otherwise, the
readonly data section is used.
This macro is irrelevant if there is no separate readonly data section.
void TARGET_ASM_SELECT_SECTION (tree exp, int reloc, unsigned HOST_WIDE_INT align) | Target Hook |
Switches to the appropriate section for output of exp. You can
assume that exp is either a VAR_DECL node or a constant of
some sort. reloc indicates whether the initial value of exp
requires link-time relocations. Bit 0 is set when variable contains
local relocations only, while bit 1 is set for global relocations.
Select the section by calling data_section or one of the
alternatives for other sections. align is the constant alignment
in bits.
The default version of this function takes care of putting read-only
variables in |
void TARGET_ASM_UNIQUE_SECTION (tree decl, int reloc) | Target Hook |
Build up a unique section name, expressed as a STRING_CST node,
and assign it to DECL_SECTION_NAME ( decl) .
As with TARGET_ASM_SELECT_SECTION , reloc indicates whether
the initial value of exp requires link-time relocations.
The default version of this function appends the symbol name to the
ELF section name that would normally be used for the symbol. For
example, the function |
void TARGET_ASM_SELECT_RTX_SECTION (enum machine_mode mode, rtx x, unsigned HOST_WIDE_INT align) | Target Hook |
Switches to the appropriate section for output of constant pool entry
x in mode. You can assume that x is some kind of
constant in RTL. The argument mode is redundant except in the
case of a const_int rtx. Select the section by calling
readonly_data_section or one of the alternatives for other
sections. align is the constant alignment in bits.
The default version of this function takes care of putting symbolic
constants in |
void TARGET_ENCODE_SECTION_INFO (tree decl, int new_decl_p) | Target Hook |
Define this hook 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 hook is executed under two circumstances. One is immediately after
the rtl for decl that represents a variable or a function has been
created and stored in The new_decl_p argument will be true if this is the first time
that The usual thing for this hook to do is to record a flag in the
|
const char *TARGET_STRIP_NAME_ENCODING (const char *name) | Target Hook |
Decode name and return the real name part, sans
the characters that TARGET_ENCODE_SECTION_INFO
may have added.
|
bool TARGET_IN_SMALL_DATA_P (tree exp) | Target Hook |
Returns true if exp should be placed into a "small data" section. The default version of this hook always returns false. |
Target Hook bool TARGET_HAVE_SRODATA_SECTION | Variable |
Contains the value true if the target places read-only "small data" into a separate section. The default value is false. |
bool TARGET_BINDS_LOCAL_P (tree exp) | Target Hook |
Returns true if exp names an object for which name resolution
rules must resolve to the current "module" (dynamic shared library
or executable image).
The default version of this hook implements the name resolution rules for ELF, which has a looser model of global name binding than other currently supported object file formats. |
Target Hook bool TARGET_HAVE_TLS | Variable |
Contains the value true if the target supports thread-local storage. The default value is false. |