[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The CPU backend files are the heart of the assembler. They are the only parts of the assembler which actually know anything about the instruction set of the processor.
You must define a reasonably small list of macros and functions in the CPU backend files. You may define a large number of additional macros in the CPU backend files, not all of which are documented here. You must, of course, define macros in the `.h' file, which is included by every assembler source file. You may define the functions as macros in the `.h' file, or as functions in the `.c' file.
TC_CPU
TC_M68K
. You might have to use this
if it is necessary to add CPU specific code to the object format file.
TARGET_FORMAT
OBJ_FMT
macro.
TARGET_ARCH
bfd_set_arch_mach
.
TARGET_MACH
bfd_set_arch_mach
. If
it is not defined, GAS will use 0.
TARGET_BYTES_BIG_ENDIAN
md_shortopts
md_longopts
md_longopts_size
md_parse_option
md_show_usage
md_after_parse_args
md_shortopts
is a const char *
which GAS adds to the machine
independent string passed to getopt
. md_longopts
is a
struct option []
which GAS adds to the machine independent long options
passed to getopt
; you may use OPTION_MD_BASE
, defined in
`as.h', as the start of a set of long option indices, if necessary.
md_longopts_size
is a size_t
holding the size md_longopts
.
GAS will call md_parse_option
whenever getopt
returns an
unrecognized code, presumably indicating a special code value which appears in
md_longopts
. GAS will call md_show_usage
when a usage message is
printed; it should print a description of the machine specific options.
md_after_pase_args
, if defined, is called after all options are
processed, to let the backend override settings done by the generic option
parsing.
md_begin
md_cleanup
md_assemble
md_assemble
will do this by calling frag_more
and writing out
some bytes (see section 2.4 Frags). md_assemble
will call fix_new
to
create fixups as needed (see section 2.3 Fixups). Targets which need to do special
purpose relaxation will call frag_var
.
md_pseudo_table
pseudo_typeS
. It is a mapping from
pseudo-op names to functions. You should use this table to implement
pseudo-ops which are specific to the CPU.
tc_conditional_pseudoop
pseudo_typeS
argument.
It should return non-zero if the pseudo-op is a conditional which controls
whether code is assembled, such as `.if'. GAS knows about the normal
conditional pseudo-ops, and you should normally not have to define this macro.
comment_chars
const char
array of characters which start a
comment.
tc_comment_chars
comment_chars
.
tc_symbol_chars
line_comment_chars
const char
array of characters which start a
comment when they appear at the start of a line.
line_separator_chars
const char
array of characters which separate
lines (null and newline are such characters by default, and need not be
listed in this array). Note that line_separator_chars do not separate lines
if found in a comment, such as after a character in line_comment_chars or
comment_chars.
EXP_CHARS
const char
array of characters which may be
used as the exponent character in a floating point number. This is normally
"eE"
.
FLT_CHARS
const char
array of characters which may be
used to indicate a floating point constant. A zero followed by one of these
characters is assumed to be followed by a floating point number; thus they
operate the way that 0x
is used to indicate a hexadecimal constant.
Usually this includes `r' and `f'.
LEX_AT
Lexical types are a combination of LEX_NAME
and LEX_BEGIN_NAME
,
both defined in `read.h'. LEX_NAME
indicates that the character
may appear in a name. LEX_BEGIN_NAME
indicates that the character may
appear at the beginning of a name.
LEX_BR
LEX_PCT
LEX_QM
LEX_DOLLAR
LEX_NAME | LEX_BEGIN_NAME
.
NUMBERS_WITH_SUFFIX
SINGLE_QUOTE_STRINGS
NO_STRING_ESCAPES
ONLY_STANDARD_ESCAPES
md_start_line_hook
LABELS_WITHOUT_COLONS
TC_START_LABEL
TC_START_LABEL_WITHOUT_COLON
TC_START_LABEL_WITHOUT_COLON
NO_PSEUDO_DOT
TC_EQUAL_IN_INSN
input_line_pointer
at that point. GAS uses this macro to decide if a
= is an assignment or an instruction.
TC_EOL_IN_INSN
TC_CASE_SENSITIVE
md_parse_name
reg_section
.
md_undefined_symbol
md_begin
is called. One argument is passed, a char *
for the symbol.
md_operand
expressionS
pointer, for any expression that can not be recognized. When the function
is called, input_line_pointer
will point to the start of the
expression.
tc_unrecognized_line
md_do_align
HANDLE_ALIGN
TC_IMPLICIT_LCOMM_ALIGNMENT (size, p2var)
.lcomm
directive with no explicit alignment parameter will use this
macro to set p2var to the alignment that a request for size bytes
will have. The alignment is expressed as a power of two. If no alignment
should take place, the macro definition should do nothing. Some targets define
a .bss
directive that is also affected by this macro. The default
definition will set p2var to the truncated power of two of sizes up to
eight bytes.
md_flush_pending_output
TC_PARSE_CONS_EXPRESSION
.word
. You can use this to recognize relocation
directives that may appear in such directives.
BITFIELD_CONS_EXPRESSION
REPEAT_CONS_EXPRESSION
md_cons_align
TC_CONS_FIX_NEW
TC_INIT_FIX_DATA (fixp)
TC_FIX_TYPE
macro.
TC_FIX_DATA_PRINT (stream, fixp)
print_fixup
.
TC_FRAG_INIT (fragp)
TC_FRAG_TYPE
macro.
md_number_to_chars
number_to_chars_bigendian
or
number_to_chars_littleendian
, whichever is appropriate. On targets like
the MIPS which support options to change the endianness, which function to call
is a runtime decision. On other targets, md_number_to_chars
can be a
simple macro.
md_atof (type,litP,sizeP)
The second parameter is litP which is a pointer to a byte array where the converted value should be stored. The third argument is sizeP, which is a pointer to a integer that should be filled in with the number of LITTLENUMs emitted into the byte array. (LITTLENUM is defined in gas/bignum.h). The function should return NULL upon success or an error string upon failure.
TC_LARGEST_EXPONENT_IS_NORMAL
The macro has a default definition which returns 0 for all cases.
md_reloc_size
BFD_ASSEMBLER
and not MANY_SEGMENTS
). It holds the size of a
relocation entry.
WORKING_DOT_WORD
md_short_jump_size
md_long_jump_size
md_create_short_jump
md_create_long_jump
TC_CHECK_ADJUSTED_BROKEN_DOT_WORD
WORKING_DOT_WORD
is defined, GAS will not do broken word processing
(see section 6. Broken words). Otherwise, you should set md_short_jump_size
to
the size of a short jump (a jump that is just long enough to jump around a
number of long jumps) and md_long_jump_size
to the size of a long jump
(a jump that can go anywhere in the function). You should define
md_create_short_jump
to create a short jump around a number of long
jumps, and define md_create_long_jump
to create a long jump.
If defined, the macro TC_CHECK_ADJUSTED_BROKEN_DOT_WORD will be called for each
adjusted word just before the word is output. The macro takes two arguments,
an addressT
with the adjusted word and a pointer to the current
struct broken_word
.
md_estimate_size_before_relax
rs_machine_dependent
frag before any relaxing is done. It may also create any necessary
relocations.
md_relax_frag
md_relax_frag
should return the change in size of the frag.
See section 5. Relaxation.
TC_GENERIC_RELAX_TABLE
md_relax_frag
, you may define
TC_GENERIC_RELAX_TABLE
as a table of relax_typeS
structures. The
machine independent code knows how to use such a table to relax PC relative
references. See `tc-m68k.c' for an example. See section 5. Relaxation.
md_prepare_relax_scan
LINKER_RELAXING_SHRINKS_ONLY
md_begin
), a
`.align' directive will cause extra space to be allocated. The linker can
then discard this space when relaxing the section.
TC_LINKRELAX_FIXUP (segT)
md_convert_frag
TC_FINALIZE_SYMS_BEFORE_SIZE_SEG
finalize_syms
before the function
size_segs
is called. Since size_segs
calls cvt_frag_to_fill
which can call md_convert_frag
, this constant governs whether the symbols
accessed in md_convert_frag
will be fully resolved. In particular it
governs whether local symbols will have been resolved, and had their frag
information removed. Depending upon the processing performed by
md_convert_frag
the frag information may or may not be necessary, as may
the resolved values of the symbols. The default value is 1.
TC_VALIDATE_FIX (fixP, seg, skip)
struct fix *fixP
before
the generic code sees it, or to fully process the fixup. In the latter case,
a goto skip
will bypass the generic code.
md_apply_fix3 (fixP, valP, seg)
TC_VALIDATE_FIX
test
when linkrelax is not set. It should store the correct value in the
object file. struct fix *fixP
is the fixup md_apply_fix3
is operating on. valueT *valP
is the value to store into the
object files, or at least is the generic code's best guess. Specifically,
*valP is the value of the fixup symbol, perhaps modified by
MD_APPLY_SYM_VALUE
, plus fixP->fx_offset
(symbol addend),
less MD_PCREL_FROM_SECTION
for pc-relative fixups.
segT seg
is the section the fix is in.
fixup_segment
performs a generic overflow check on *valP after
md_apply_fix3
returns. If the overflow check is relevant for the target
machine, then md_apply_fix3
should modify *valP, typically to the
value stored in the object file.
TC_FORCE_RELOCATION (fix)
fixup_segment
tries to
reduce the number of relocations emitted. For example, a fixup expression
against an absolute symbol will normally not require a reloc. If undefined,
a default of (S_FORCE_RELOC ((fix)->fx_addsy))
is used.
TC_FORCE_RELOCATION_ABS (fix)
TC_FORCE_RELOCATION
, but used only for fixup expressions against an
absolute symbol. If undefined, TC_FORCE_RELOCATION
will be used.
TC_FORCE_RELOCATION_LOCAL (fix)
TC_FORCE_RELOCATION
, but used only for fixup expressions against a
symbol in the current section. If undefined, fixups that are not
fx_pcrel
or fx_plt
or for which TC_FORCE_RELOCATION
returns non-zero, will emit relocs.
TC_FORCE_RELOCATION_SUB_SAME (fix, seg)
fx_subsy
set to NULL
for
md_apply_fix3
. If undefined, the default of
! SEG_NORMAL (seg) || TC_FORCE_RELOCATION (fix)
will
be used.
TC_FORCE_RELOCATION_SUB_ABS (fix)
TC_FORCE_RELOCATION_SUB_SAME
, but used when the subtrahend is an
absolute symbol. If the macro is undefined a default of 0
is used.
TC_FORCE_RELOCATION_SUB_LOCAL (fix)
TC_FORCE_RELOCATION_SUB_ABS
, but the subtrahend is a symbol in the
same section as the fixup.
TC_VALIDATE_FIX_SUB (fix)
fx_subsy
that
fixup_segment
cannot reduce to a number. If the macro returns
false
an error will be reported.
MD_APPLY_SYM_VALUE (fix)
md_apply_fix3
. If the macro is undefined, or returns non-zero, the
symbol value will be included. For ELF, a suitable definition might simply be
0
, because ELF relocations don't include the symbol value in the addend.
S_FORCE_RELOC (sym, strict)
BFD_ASSEMBLER
gas) returns true for symbols
that should not be reduced to section symbols or eliminated from expressions,
because they may be overridden by the linker. ie. for symbols that are
undefined or common, and when strict is set, weak, or global (for ELF
assemblers that support ELF shared library linking semantics).
EXTERN_FORCE_RELOC
S_FORCE_RELOC
returns true for global
symbols. If undefined, the default is true
for ELF assemblers, and
false
for non-ELF.
tc_gen_reloc
BFD_ASSEMBLER
GAS will call this to generate a reloc. GAS will pass
the resulting reloc to bfd_install_relocation
. This currently works
poorly, as bfd_install_relocation
often does the wrong thing, and
instances of tc_gen_reloc
have been written to work around the problems,
which in turns makes it difficult to fix bfd_install_relocation
.
RELOC_EXPANSION_POSSIBLE
tc_gen_reloc
may return multiple
relocation entries for a single fixup. In this case, the return value of
tc_gen_reloc
is a pointer to a null terminated array.
MAX_RELOC_EXPANSION
RELOC_EXPANSION_POSSIBLE
is defined; it
indicates the largest number of relocs which tc_gen_reloc
may return for
a single fixup.
tc_fix_adjustable
MD_PCREL_FROM_SECTION (fixp, section)
md_pcrel_from
MD_PCREL_FROM_SECTION
. The difference is
that md_pcrel_from
does not take a section argument.
tc_frob_label
md_section_align
segT
for the section and a valueT
for the size of the section, and return a valueT
for the rounded
size.
md_macro_start
macro_nest
indicates the current macro nesting level, which
includes the one being expanded.
md_macro_info
md_macro_end
DOUBLEBAR_PARALLEL
KEEP_WHITE_AROUND_COLON
tc_frob_section
BFD_ASSEMBLER
GAS will call it for each
section at the end of the assembly.
tc_frob_file_before_adjust
tc_frob_symbol
tc_frob_file
tc_frob_file_after_relocs
md_post_relax_hook
LISTING_HEADER
"GAS LISTING"
.
LISTING_WORD_SIZE
LISTING_LHS_WIDTH
LISTING_WORD_SIZE
bytes. The
default value is 1.
LISTING_LHS_WIDTH_SECOND
LISTING_LHS_WIDTH
, but applying to the second and subsequent line
of the data printed for a particular source line. The default value is 1.
LISTING_LHS_CONT_LINES
LISTING_RHS_WIDTH
TC_COFF_SECTION_DEFAULT_ATTRIBUTES
.section
directive will use the value of this macro to set
a new section's attributes when a directive has no valid flags or when the
flag is w
. The default value of the macro is SEC_LOAD | SEC_DATA
.
DWARF2_FORMAT ()
dwarf2_format_32bit
,
dwarf2_format_64bit
, or dwarf2_format_64bit_irix
to indicate
the size of internal DWARF section offsets and the format of the DWARF initial
length fields. When dwarf2_format_32bit
is returned, the initial
length field will be 4 bytes long and section offsets are 32 bits in size.
For dwarf2_format_64bit
and dwarf2_format_64bit_irix
, section
offsets are 64 bits in size, but the initial length field differs. An 8 byte
initial length is indicated by dwarf2_format_64bit_irix
and
dwarf2_format_64bit
indicates a 12 byte initial length field in
which the first four bytes are 0xffffffff and the next 8 bytes are
the section's length.
If you don't define this, dwarf2_format_32bit
will be used as
the default.
This define only affects .debug_info
and .debug_line
sections generated by the assembler. DWARF 2 sections generated by
other tools will be unaffected by this setting.
DWARF2_ADDR_SIZE (bfd)
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |