全部博文(94)
分类: LINUX
2011-10-10 09:25:47
7.50 .macro
The commands .macro and .endm allow you to define macros that generate assembl
y output. For example, this definition specifies a macro sum that puts a seque
nce of numbers into memory:
.macro sum from=0, to=5
.long \from
.if \to-\from
sum "(\from+1)",\to
.endif
.endm
With that definition, ‘SUM 0,5’ is equivalent to this assembly input:
.long 0
.long 1
.long 2
.long 3
.long 4
.long 5
.macro macname
.macro macname macargs ...
Begin the definition of a macro called macname. If your macro definition requi
res arguments, specify their names after the macro name, separated by commas o
r spaces. You can supply a default value for any macro argument by following t
he name with ‘=deflt’. For example, these are all valid .macro statements:
.macro comm
Begin the definition of a macro called comm, which takes no arguments.
.macro plus1 p, p1
.macro plus1 p p1
Either statement begins the definition of a macro called plus1,which takes two
arguments; within the macro definition, write ‘\p’ or ‘\p1’ to evaluate t
he arguments.
.macro reserve_str p1=0 p2
Begin the definition of a macro called reserve_str, with two arguments. The fi
rst argument has a default value, but not the second. After the definition is
complete, you can call the macro either as ‘reserve_str a, b’ (with ‘\p1’
evaluating to a and ‘\p2’ evaluating to b), or as ‘reserve_str ,b’ (with ‘
\p1’ evaluating as the default, in this case ‘0’, and ‘\p2’ evaluating to
b).
When you call a macro, you can specify the argument values either by position,
or by keyword. For example, ‘sum 9,17’ is equivalent to ‘sum to=17, from=9
’.
.endm Mark the end of a macro definition.
.exitm Exit early from the current macro definition.
\@ as maintains a counter of how many macros it has executed in this pseudov-a
riable; you can copy that number to your output with ‘\@’, but only within a
macro definition.
7.50 .macro
本命令.macro和.endm命令允许您定义宏来生成汇编输出。例如,下面的语句定义了一个宏
sum,这个宏把一个数字序列放入内存。
.macro sum from=0, to=5
.long \from
.if \to-\from
sum "(\from+1)",\to
.endif
.endm
使用上述定义,'SUM 0,5'语句就等于输入下面的汇编语句:
.long 0
.long 1
.long 2
.long 3
.long 4
.long 5
.macro macname
.macro macname macargs ...
开始定义一个名为macname的宏。如果您的宏需要使用参数,则在宏的名字后指定他们的名
字,参数之间用逗号或空格分隔。您可以为任意的参数提供参数的缺省值,只需要在参数
后使用“=deflt”,。例如,下列都是合法的宏定义语句:
.macro comm
定义一个名为comm宏,不使用参数。
.macro plus1 p, p1
.macro plus1 p p1
两个语句都声明要定义一个名为plus1的宏,这个宏需要两个参数,在宏定义体内,使用'
\p'或'\p1'来引用参数的值。
.macro reserve_str p1=0 p2
声明要定义一个名为reserve_str的宏,使用两个参数。第一个参数有缺省值,第二个没有
缺省值。宏定义完成后,您可以通过‘reserve_str a, b’(宏体中‘\p1’引用a的值,‘
\p2’引用b值)或通过‘reserve_str ,b’(‘\p1’使用缺省值,在此为‘0’,‘\p2’引
用b的值)来调用这个宏。
当调用一个宏时,您既可以通过位置指定参数值,也可以通过关键字指定参数值。例如,
‘sum 9,17’和‘sum to=17, from=9’是等价的。
.endm 标志宏定义体的结束。
.exitm 提前从当前宏定义体中退出。
\@ 这个伪变量其实是as维护的一个计数器,用来统计执行了多少个宏。您可以通过使用\
@把这个数字复制到您的输出中,但仅限于在宏定义体中使用。
7.51 .nolist
Control (in conjunction with the .list directive) whether or not assembly list
ings are generated. These two directives maintain an internal counter (which i
s zero initially). .list increments the counter, and .nolist decrements it. As
sembly listings are generated whenever the counter is greater than zero.
7.51 .nolist
控制(和.list命令配合)是否生成汇编列表。这两个命令维护一个内部的计数器(计数器
初始值为0).list命令增加计数器的值,.nolist减少计数器的值。当计数器的值大与0时
将汇编列表。
7.52 .octa bignums
This directive expects zero or more bignums, separated by commas. For each big
num, it emits a 16-byte integer.
The term “octa” comes from contexts in which a “word” is two bytes; hence
octa-word for 16 bytes.
7.52 .octa bignums
本命令可以不带参数或多个由逗号分隔开的巨数bignum,针对每个巨数bignum,它生成一个
16个字节的整数。
术语"octa"来源:word为2个字节,故此octa-word为16个字节。
7.53 .org new-lc , fill
Advance the location counter of the current section to new-lc. new-lc is eithe
r an absolute expression or an expression with the same section as the current
subsection. That is, you can’t use .org to cross sections: if new-lc has the
wrong section, the .org directive is ignored. To be compatible with former as
semblers, if the section of new-lc is absolute, as issues a warning, then pret
ends the section of new-lc is the same as the current subsection.
.org may only increase the location counter, or leave it unchanged; you cannot
use .org to move the location counter backwards.
Because as tries to assemble programs in one pass, new-lc may not be undefined
. If you really detest this restriction we eagerly await a chance to share you
r improved assembler.
Beware that the origin is relative to the start of the section, not to the sta
rt of the subsection. This is compatible with other people’s assemblers.
When the location counter (of the current subsection) is advanced, the interve
ning bytes are filled with fill which should be an absolute expression. If the
comma and fill are omitted, fill defaults to zero.
7.53 .org new-lc , fill
向后移动当前段的位置计数器至new-lc。new-lc要么是一个纯粹的表达式,要么这个表达
式与当前子段在同一个段中。换句话说,就是您不能使用.org进行段超越。如果new-lc指
向错误的段,则忽略.org命令。为了兼容以前的汇编器,如果new-lc指向一个地址独立的
段,as发出一个警告,并假定new-lc指向当前子段。
.org 仅仅可以增大位置计数器,或者保持位置计数器不变;您不能使用.org命令把位置计
数器向回移动。
因为as尽量一次完成程序汇编,所以不能使用未定义的new-lc。如果您厌恶这个限制,我
们急切期待有机会分享经过您改进的汇编器。
注意起点相对于段的首地址,而不是子段的首地址。这与其他的汇编器相兼容。
当(当前语句块)位置计数器到达指定位置,用fill填充该字节,fill必须是纯粹的表达
式。如果没有给出逗号和fill,fill值缺省为0。
7.54 .p2align[wl] abs-expr, abs-expr, abs-expr
Pad the location counter (in the current subsection) to a particular storage b
oundary. The first expression (which must be absolute) is the number of low-or
der zero bits the location counter must have after advancement. For example ‘
.p2align 3’ advances the location counter until it a multiple of 8. If the lo
cation counter is already a multiple of 8, no change is needed.
The second expression (also absolute) gives the fill value to be stored in the
padding bytes. It (and the comma) may be omitted. If it is omitted, the paddi
ng bytes are normally zero. However, on some systems, if the section is marked
as containing code and the fill value is omitted, the space is filled with no
-op instructions.
The third expression is also absolute, and is also optional. If it is present,
it is the maximum number of bytes that should be skipped by this alignment di
rective. If doing the alignment would require skipping more bytes than the spe
cified maximum, then the alignment is not done at all. You can omit the fill v
alue (the second argument) entirely by simply using two commas after the requi
red alignment; this can be useful if you want the alignment to be filled with
no-op instructions when appropriate.
The .p2alignw and .p2alignl directives are variants of the .p2align directive.
The .p2alignw directive treats the fill pattern as a two byte word value. The
.p2alignl directives treats the fill pattern as a four byte longword value. F
or example, .p2alignw 2,0x368d will align to a multiple of 4. If it skips two
bytes, they will be filled in with the value 0x368d (the exact placement of th
e bytes depends upon the endianness of the processor). If it skips 1 or 3 byte
s, the fill value is undefined.
7.54 .p2align[wl] abs-expr, abs-expr, abs-expr
增加位置计数器(在当前的子段)使它指向规定的存储边界。第一个表达式参数(结果必须是
纯粹的数字) 代表位置计数器移动后,计数器中连续为0的低序位数量。例如‘.align 3’
向后移动位置指针直至8的倍数(指针的最低的3位为0)。如果地址已经是8倍数,则无需
移动。
第二个表达式参数(结果必须是纯粹的数字)给出填充字节的值。用这个值填充位置计数器
越过的地方。这个参数(和逗点)可以省略。如果省略它,填充字节的值通常默认为0。但在
某些系统上,如果本段标识为包含代码,而填充值被省略,则使用no-op指令填充填充区。
第3个参数表达式的结果也必须是纯粹的数字,这个参数是可选的。如果存在第3个参数,
它代表本对齐命令允许越过字节数的最大值。如果完成这个对齐需要跳过的字节比指定的
最大值还多,则根本无法完成对齐。您可以在边界基准后简单地使用两个逗号,以省略填充
值参数(第二参数);如果您想在适当的时候,对齐操作自动使用no-op指令填充,这个方法
将非常奏效。
.p2alignw和.p2alignl是.p2align命令的变化形式。.p2alignw 使用2个字节来填充填充区
。.p2alignl使用4字节来填充。例如,. .p2alignw 2,0x368d将地址对齐到4的倍数,如果
它跳过2个字节,GAS将使用0x368d填充这2个字节(字节的准确的位置视处理器的存储方式
而定)。如果它跳过1或3个字节,填充值则不明确。
7.55 .previous
This is one of the ELF section stack manipulation directives. The others are .
section (see Section 7.66 [Section], page 52), .subsection (see Section 7.79 [
SubSection], page 56), .pushsection (see Section 7.61 [PushSection], page 50),
and .popsection (see Section 7.56 [PopSection], page 50).
This directive swaps the current section (and subsection) with most recently r
eferenced section (and subsection) prior to this one. Multiple .previous direc
tives in a row will flip between two sections (and their subsections).
In terms of the section stack, this directive swaps the current section with t
he top section on the section stack.
7.55 .previous
这是一个ELF段堆栈操作命令。其他的段堆栈操作命令还有.section (见 7.66 [Section]
, 52页), .subsection (见 7.79 [SubSection], 56页),.pushsection (见 7.61 [PushS
ection], 50页), 和 .popsection (见 7.56 [PopSection], 50页)。
本命令交换当前段(及其子段)和最近访问过的段(及其子段)。多个连续的.previous命
令将使当前位置两个段(及其子段)之间反复切换。
用段堆栈的术语来说,本命令使当前段和堆顶段交换位置。
7.56 .popsection
This is one of the ELF section stack manipulation directives. The others are .
section (see Section 7.66 [Section], page 52), .subsection (see Section 7.79 [
SubSection], page 56), .pushsection (see Section 7.61 [PushSection], page 50),
and .previous (see Section 7.55 [Previous], page 49).
This directive replaces the current section (and subsection) with the top sect
ion (and subsection) on the section stack. This section is popped off the stac
k.
7.56 .popsection
这是一个ELF段堆栈操作命令。其他的段堆栈操作命令还有.section(见 7.66 [Section],
52页), .subsection (见 7.79 [SubSection], 56页),.pushsection (见 7.61 [PushSe
ction], 50页), 和 .previous (见 7.55 [Previous], 49页).
本命令用堆栈顶段(及其子段)替代当前段(及其子段)。堆栈顶段出栈。
7.57 .print string
as will print string on the standard output during assembly. You must put stri
ng in double quotes.
7.57 .print string
as会在标准输出上打印string字符串。String必须使用双引号。
7.58 .protected names
This one of the ELF visibility directives. The other two are .hidden (see Sect
ion 7.32 [Hidden], page 42) and .internal (see Section 7.39 [Internal], page 4
4).
This directive overrides the named symbols default visibility (which is set by
their binding: local, global or weak). The directive sets the visibility to p
rotected which means that any references to the symbols from within the compon
ents that defines them must be resolved to the definition in that component, e
ven if a definition in another component would normally preempt this.
7.58 .protected names
这是一条ELF可见度的相关命令。其它两条是.hidden (参见 7.32 [Hidden], 42页)和 .i
nternal (参见 7.39 [Internal], 44页)。
本命令将取消指定符号的可见度缺省值(可见度由其他命令捆绑设定:local, global, w
eak)本命令将可见度设置为protected,这个可见度意味着:在定义此符号的部件内对此符
号的任何访问,都必须解析到这个部件内的定义体。即使其他部件中存在一个正常情况下
比此优先的定义体。
7.59 .psize lines, columns
Use this directive to declare the number of lines—and, optionally, the number
of columns—to use for each page, when generating listings.
If you do not use .psize, listings use a default line-count of 60. You may omi
t the comma and columns specification; the default width is 200 columns.
as generates formfeeds whenever the specified number of lines is exceeded (or
whenever you explicitly request one, using .eject).
If you specify lines as 0, no formfeeds are generated save those explicitly sp
ecified with .eject.
7.59 .psize lines , columns
当生成清单列表时,使用本命令声明每页的行数—还可以可选地声明列数。
如果您不使用本命令,清单列表的行数为默认的60行。可以省略逗号和列参数:默认值为
200列。
当指定的行数过多的话,as会产生进纸操作。(如果您确实需要一个进纸动作,可以使用
.eject命令)
如果您指定行数为0,则不产生进纸操作,除非您明确地使用了.eject命令。
7.60 .purgem name
Undefine the macro name, so that later uses of the string will not be expanded
. See Section 7.50 [Macro], page 47.
7.60 .purgem name
取消name的宏定义,后面使用字符串name不会被宏扩展。参见 7.50 [Macro], 47页。
7.61 .pushsection name , subsection
This is one of the ELF section stack manipulation directives. The others are .
section (see Section 7.66 [Section], page 52), .subsection (see Section 7.79 [
SubSection], page 56), .popsection (see Section 7.56 [PopSection], page 50), a
nd .previous (see Section 7.55 [Previous], page 49).
This directive is a synonym for .section. It pushes the current section (and s
ubsection) onto the top of the section stack, and then replaces the current se
ction and subsection with name and subsection.
7.61 .pushsection name , subsection
本命令是一个ELF段堆栈操作命令。其余的几个是.section (参见 7.66 [Section], 52页
) , .subsection (参见7.79 [SubSection], 56页),.popsection (参见 7.56 [PopSecti
on], 50页), 和 .previous (参见 7.55 [Previous], 49页)。
本命令与.section命令是等价的。它将当前段(及子段)推入段堆栈的顶部。并使用name
和subsection来替代当前段和子段。
7.62 .quad bignums
.quad expects zero or more bignums, separated by commas. For each bignum, it e
mits an 8-byte integer. If the bignum won’t fit in 8 bytes, it prints a warni
ng message; and just takes the lowest order 8 bytes of the bignum.
The term “quad” comes from contexts in which a “word” is two bytes; hence
quad-word for 8 bytes.
7.62 .quad bignums
.quad 可带0或多个bignum参数,每个参数由逗号分隔。对于每个bignum都汇编成一个8字
节的整数。如果某个bignum用8字节无法表示,则给出警告信息;只汇编这个bignum的最低
8字节。
术语“quad”源于一个“word”代表2个字节,所以quad-word代表8个字节。
7.63 .rept count
Repeat the sequence of lines between the .rept directive and the next .endr di
rective count times.
For example, assembling
.rept 3
.long 0
.endr
is equivalent to assembling
.long 0
.long 0
.long 0
7.63 .rept count
汇编.rept和.endr之间的语句count次。
如, 汇编下列语句:
.rept 3
.long 0
.endr
与下列语句是等价的:
.long 0
.long 0
.long 0
7.64 sbttl "subheading"
Use subheading as the title (third line, immediately after the title line) whe
n generating assembly listings.
This directive affects subsequent pages, as well as the current page if it app
ears within ten lines of the top of a page.
7.64 sbttl "subheading"
当生成汇编清单时,使用subheading作为标题(第3行,紧跟在标题行之后)。
本命令对清单的后续页起作用,如果它位于当前页的前10行内,则对当前页也起作用。
7.65 .scl class
Set the storage-class value for a symbol. This directive may only be used insi
de a .def/.endef pair. Storage class may flag whether a symbol is static or ex
ternal, or it may record further symbolic debugging information.
The ‘.scl’ directive is primarily associated with COFF output; when configur
ed to generate b.out output format, as accepts this directive but ignores it.
7.65 .scl class
设置一个符号的存储类型值(storage-class value)。本命令只能在.def/.endef之间使
用。符号的存储类型可以表明符号是static类型或是external类型,或者进一步记录符号
的调试信息。
‘.scl’命令主要与在COFF输出有关,当生成b.out输出格式时,as接受本命令,但忽略本
命令。
7.66 .section name (COFF version)
Use the .section directive to assemble the following code into a section named
name.
This directive is only supported for targets that actually support arbitrarily
named sections; on a.out targets, for example, it is not accepted, even with
a standard a.out section name.
For COFF targets, the .section directive is used in one of the following ways:
.section name [, "flags"]
.section name [, subsegment]
If the optional argument is quoted, it is taken as flags to use for the sectio
n. Each flag is a single character. The following flags are recognized:
b bss section (uninitialized data)
n section is not loaded
w writable section
d data section
r read-only section
x executable section
s shared section (meaningful for PE targets)
If no flags are specified, the default flags depend upon the section name. If
the section name is not recognized, the default will be for the section to be
loaded and writable. Note the n and w flags remove attributes from the section
, rather than adding them, so if they are used on their own it will be as if n
o flags had been specified at all.
If the optional argument to the .section directive is not quoted, it is taken
as a subsegment number (see Section 4.4 [Sub-Sections], page 25).
7.66 .section name (COFF 版本)
使用.section命令将后续的代码汇编进一个定名为name的段。
本命令只能在目标格式真正支持任意命名段时使用;例如,汇编一个a.out目标格式时,即
使name是一个标准的a.out段名,本命令也不被接受。
当目标格式为COFF时,.section命令的使用为下面某一种格式:
.section name[, "flags"]
.section name[, subsegment]
如可选参数使用了引号,它将被视为该段的标志(flags)。每个标记是单个的字符。下列是
认可的标志。
b bss 段 (未初始化的数据)
n 未装入内存的段
w 可写的段
d 数据段
r 只读段
x 代码段 (executable section)
s 共享段 (目标为PE格式有意义)
如果本命令没有指定标志,则依靠段名来确定标志缺省值。如果该段名没有使用标准段名
,则默认该段已装入内存并且可写。注意在使用n和w标志组合时,不是增加这组属性,而
是删除该段的属性。所以如果只存在这两个标志,就代表该段没有指定任何标志。
如果本命令的可选参数没有使用引号,参数将被视为子段的编号。(参见 4.4 [Sub-Secti
ons], 25页)。
7.67 .section name (ELF 版本)
This is one of the ELF section stack manipulation directives. The others are .
subsection (see Section 7.79 [SubSection], page 56), .pushsection (see Section
7.61 [PushSection], page 50), .popsection (see Section 7.56 [PopSection], pag
e 50), and .previous (see Section 7.55 [Previous], page 49).
For ELF targets, the .section directive is used like this:
.section name [, "flags"[, @type]]
The optional flags argument is a quoted string which may contain any combinati
on of the following characters:
a section is allocatable
w section is writable
x section is executable
The optional type argument may contain one of the following constants:
@progbits section contains data
@nobits section does not contain data (i.e., section only occupies space)
If no flags are specified, the default flags depend upon the section name. If
the section name is not recognized, the default will be for the section to hav
e none of the above flags: it will not be allocated in memory, nor writable, n
or executable. The section will contain data.
For ELF targets, the assembler supports another type of .section directive for
compatibility with the Solaris assembler:
.section "name"[, flags...]
Note that the section name is quoted. There may be a sequence of comma separat
ed flags:
#alloc section is allocatable
#write section is writable
#execinstr section is executable
This directive replaces the current section and subsection. The replaced secti
on and subsection are pushed onto the section stack. See the contents of the g
as testsuite directory gas/testsuite/gas/elf for some examples of how this dir
ective and the other section stack directives work.
7.67 .section name (ELF 版本)
本命令是ELF的段堆栈操作命令之一,其他的段堆栈命令为.subsection (见 Section 7.7
9 [SubSection], page 56), .pushsection (见Section 7.61 [PushSection], page 50)
, .popsection (见 Section 7.56 [PopSection], page 50), and .previous (见 Secti
on 7.55 [Previous], page 49).
当目标格式为ELF时,.section命令应如下使用:
.section name [, "flags"[, @type]]
可选参数flags是被引号包围的字符串,可以由下列字符的任意组合:
a 可分配的段(allocatable)
w 可写段
x 代码段
可选的参数type可以包含下列的任一常量:
@progbits 包含数据的段
@nobits 不包含数据的段(只占用空间的段)
如果本命令没有指定标志,则依靠段名来确定标志缺省值。如果段名不是标准的段名,则
默认的该段不包含上述标志:该段不可分配内存,不可写,不可执行。该段是包含数据的
段。
当目标格式为ELF时,as还支持另一种形式的.section命令,以便兼容Solaris的汇编器:
.section "name"[, flags...]
注意段名是使用引号包围的,可能存在一系列由逗号分隔分隔的标志:
#alloc 可分配的段(section is allocatable)
#write 可写的段
#execinstr 可执行的段
本命令将(用段名为name的段)替代当前段和子段。被替换的段将被推入段堆栈。参见ga
s的测试套件目录gas/testsuite/gas/elf,可以找到一些本命令和其他段堆栈操作命令的
例子。
7.68 .set symbol, expression
Set the value of symbol to expression. This changes symbol’s value and type t
o conform to expression. If symbol was flagged as external, it remains flagged
(see Section 5.5 [Symbol Attributes], page 30).
You may .set a symbol many times in the same assembly.
If you .set a global symbol, the value stored in the object file is the last v
alue stored into it.
The syntax for set on the HPPA is ‘symbol .set expression’.
7.68 .set symbol, expression
设置symbol为expression。这将改变symbol的值域和类型领域以符合expression参数。如
果symbol已被标志为external,则symbol保持它的标志。(见 5.5 [Symbol Attributes],
30页)。
您可以在同一个汇编程序中多次使用.set命令来设置同一个符号。
如果设置一个全局符号,该符号在目标文件中值为最后设定的值。
在HPPA上的语法是‘symbol .set expression’。
7.69 .short expressions
.short is normally the same as ‘.word’. See Section 7.92 [.word], page 59.
In some configurations, however, .short and .word generate numbers of differen
t lengths; see Chapter 8 [Machine Dependencies], page 61.
7.69 .short expressions
本命令通常和’.word’命令一样,见7.92 [.word], 59页.
然而在某些配置中,.short和.word命令生成的数字长度却不相同;见第8章 [Machine De
pendencies], 61页.
7.70 .single flonums
This directive assembles zero or more flonums, separated by commas. It has the
same effect as .float. The exact kind of floating point numbers emitted depen
ds on how as is configured. See Chapter 8 [Machine Dependencies], page 61.
7.70 .single flonums
本命令可以汇编0个或多个浮点参数,各个参数之间使用逗号分隔。它的作用和.float相同
。生成浮点数的具体类型视as的配置而定。见第8章 [Machine Dependencies], 61页。
--------------------
一切有为法 如梦幻泡影
# 回复:linux下汇编的Directive Operands 2004-09-08 3:25 PM n9871009
Re: 7 汇编器命令(下) [re: amtb]
位组合:bit pattern,想不出有什么特别的意义,大概指的是有限个数的0和1所有的组合
吧。Fix me.
sleb128/uleb128: 基于128位的低地址结尾带/无符号的数。您有什么好建议?
==========================下==================================
7.71 .size (COFF 版本)
This directive is generated by compilers to include auxiliary debugging inform
ation in the symbol table. It is only permitted inside .def/.endef pairs.
‘.size’ is only meaningful when generating COFF format output; when as is ge
nerating b.out, it accepts this directive but ignores it.
7.71 .size (COFF 版本)
本命令一般由编译器生成,以在符号表中加入辅助调试信息。本命令只能在.def/.endef命
令对之间使用。
本命令只在生成COFF格式的输出文件有意义。当as生成b.out时,as接受本命令但忽略之。
7.72 .size name , expression (ELF 版本)
This directive is used to set the size associated with a symbol name. The size
in bytes is computed from expression which can make use of label arithmetic.
This directive is typically used to set the size of function symbols.
本命令经常用来设置符号name的内存大小。内存大小的单位是字节, 通过计算参数expres
sion得到,参数expression中可以使用标签进行计算。本命令常用来设置函数符号的长度
。
7.73 .sleb128 expressions
sleb128 stands for “signed little endian base 128.” This is a compact, varia
ble length representation of numbers used by the DWARF symbolic debugging form
at. See Section 7.86 [Uleb128], page 58.
7.73 .sleb128 expressions
sleb128代表“signed little endian base 128”(低地址结尾的带符号128位基数)。这是
一个紧凑的,变长的数字表示方法,当使用DWARF符号调试格式时使用。参见7.86 [Uleb1
28], 58页。
7.74 .skip size , fill
This directive emits size bytes, each of value fill. Both size and fill are ab
solute expressions. If the comma and fill are omitted, fill is assumed to be z
ero. This is the same as ‘.space’.
7.74 .skip size , fill
本命令生成size个字节,每个字节的值都是fill。参数size和fill都必须是纯粹的表达式
。如果省略逗号和fill,则默认fill的值为0。这与’.space’相同。
7.75 .space size , fill
This directive emits size bytes, each of value fill. Both size and fill are ab
solute expressions. If the comma and fill are omitted, fill is assumed to be z
ero. This is the same as ‘.skip’.
Warning: .space has a completely different meaning for HPPA targets; use .bloc
k as a substitute. See HP9000 Series 800 Assembly Language Reference Manual (H
P 92432-90001) for the meaning of the .space directive. See Section 8.8.5 [HPP
A Assembler Directives], page 84, for a summary.
On the AMD 29K, this directive is ignored; it is accepted for compatibility wi
th other AMD 29K assemblers.
Warning: In most versions of the gnu assembler, the directive .space has the e
ffect of .block See Chapter 8 [Machine Dependencies], page 61.
7.75 .space size , fill
本命令生成size个字节,每个字节的值都是fill。参数size和fill都必须是纯粹的表达式
。如果省略了逗号和fill,则默认fill的值为0。这与’.skip’相同。
警告:在生成HPPA目标格式时,.space的意义完全不同。应该使用.block命令替代本命令
。在HP9000系列800汇编语言参考手册(HP 92432-90001),可以找到.space命令的用法。参
见 8.8.5 [HPPA Assembler Directives],84页, 可以找到使用摘要。
在AMD 29K上,本命令将被忽略。出于兼容其它一些AMD 29K汇编器的目的,as接受本命令
。
警告:在gnu汇编器大多数版本中,这个.space命令和.block命令等效。见第8章 [Machin
e Dependencies], 61页。
7.76 .stabd, .stabn, .stabs
There are three directives that begin ‘.stab’. All emit symbols (see Chapter
5 [Symbols], page 29), for use by symbolic debuggers. The symbols are not ent
ered in the as hash table:they cannot be referenced elsewhere in the source fi
le. Up to five fields are required:
string This is the symbol’s name. It may contain any character except ‘\000’
, so is more general than ordinary symbol names. Some debuggers used to code a
rbitrarily complex structures into symbol names using this field.
type An absolute expression. The symbol’s type is set to the low 8 bits of th
is expression. Any bit pattern is permitted, but ld and debuggers choke on sil
ly bit patterns.
other An absolute expression. The symbol’s “other” attribute is set to the
low 8 bits of this expression.
desc An absolute expression. The symbol’s descriptor is set to the low 16 bit
s of this expression.
Value An absolute expression that becomes the symbol’s value.
If a warning is detected while reading a .stabd, .stabn, or .stabs statement,
the symbol has probably already been created; you get a half-formed symbol in
your object file. This is compatible with earlier assemblers!
.stabd type , other , desc
The “name” of the symbol generated is not even an empty string. It is a null
pointer, for compatibility. Older assemblers used a null pointer so they didn
’t waste space in object files with empty strings.
The symbol’s value is set to the location counter, relocatably. When your pro
gram is linked, the value of this symbol is the address of the location counte
r when the .stabd was assembled.
.stabn type , other , desc , value
The name of the symbol is set to the empty string "".
.stabs string , type , other , desc , value
All five fields are specified.
7.76 .stabd, .stabn, .stabs
有3个以.stab开头的命令。它们都用来产生符号,(参见第5章 [Symbols], 29页),供符号
调试器使用。这些符号没有收入as的散列表中:这些符号不能被源文件其他地方所访问。
它们至少需要5个属性域:
string 这是符号的名字。它可以包含除‘\000’之外的任何字符,故此可用名比普通符号
名更广泛。很多调试器经常利用这个空间,把任意复杂的结构编码为符号名。
type 这是一个纯粹的表达式。符号的类型属性由这个表达式的低8位设定。任何的位组合
(bit pattern)都可以,但连接器和调试器会被没有义的位组合所中断。
other 这是一个纯粹的表达式。由这个表达式的低8位设定此符号的“其它”属性。
desc 这是一个纯粹的表达式。由这个表达式的低16位设定此符号的描述符。
Value 这个纯粹的表达式将作为符号的值。
如果汇编.stabd, .stabn, 或 .stabs语句时引发了一个警告,该符号有可能已经被创建;
在目标文件中存在一个半成品的符号。这样做兼容于早期的汇编器!
.stabd type , other , desc
生成符号的“名字”甚至不是空字符串,而是一个空指针(null),这样安排是出于对兼
容性要求。早期的汇编器经常使用空指针,以避免空字符串在目标文件中浪费空间。
这个符号的值(值域)在重定位时设置为位置计数器的值。当程序连接之后,这个符号的
值是.stabd命令汇编时位置计数器的地址。
.stabn type , other , desc , value
这个符号的名字被设置为空字符串“”。
.stabs string , type , other , desc , value
5个属性域全部指定好。
7.77 .string "str"
Copy the characters in str to the object file. You may specify more than one s
tring to copy, separated by commas. Unless otherwise specified for a particula
r machine, the assembler marks the end of each string with a 0 byte. You can u
se any of the escape sequences described in Section 3.6.1.1 [Strings], page 19
.
7.77 .string "str"
将参数str中的字符复制到目标文件中去。您可以指定多个字符串进行复制,之间使用逗号
分隔。除非另外指定了具体的机器,汇编器将在每个字符串后追加一个0字节作为标记。您
可以使用任意的逃逸序列,参见19页中3.6.1.1 [Strings]的描述。
7.78 .struct expression
Switch to the absolute section, and set the section offset to expression, whic
h must be an absolute expression. You might use this as follows:
.struct 0
field1:
.struct field1 + 4
field2:
.struct field2 + 4
field3:
This would define the symbol field1 to have the value 0, the symbol field2 to
have the value 4, and the symbol field3 to have the value 8. Assembly would be
left in the absolute section, and you would need to use a .section directive
of some sort to change to some other section before further assembly.
7.78 .struct expression
切换到独立地址段,并用expression设定段的偏移量,expression必须是个纯粹的表达式
。您可以如下使用:
.struct 0
field1:
.struct field1 + 4
field2:
.struct field2 + 4
field3:
定义符号field1的值为0,符号field2的值为4,符号field3的值为8。这段汇编程序将保存
在独立地址段中,在进行下一步汇编前,您需要使用一个某种类型的.section命令,以切
换到相应的段。
7.79 .subsection name
This is one of the ELF section stack manipulation directives. The others are .
section (see Section 7.66 [Section], page 52),.pushsection (see Section 7.61 [
PushSection], page 50), .popsection (see Section 7.56 [PopSection], page 50),
and .previous (see Section 7.55 [Previous], page 49).
This directive replaces the current subsection with name. The current section
is not changed. The replaced subsection is put onto the section stack in place
of the then current top of stack subsection.
7.79 .subsection name
本命令是一个ELF段堆栈操作命令。其它的几个命令是(参见 7.66 [Section], 52页),
.pushsection (参见 7.61 [PushSection],50页), .popsection (参见 7.56 [PopSectio
n], 50页), and .previous (参见7.55 [Previous], 49页)。
本命令用name子段替换当前子段。当前段并不改变。被替换的子段入段堆栈,成为段堆栈
的新栈顶。
7.80 .symver
Use the .symver directive to bind symbols to specific version nodes within a s
ource file. This is only supported on ELF platforms, and is typically used whe
n assembling files to be linked into a shared library. There are cases where i
t may make sense to use this in objects to be bound into an application itself
so as to override a versioned symbol from a shared library.
For ELF targets, the .symver directive can be used like this:
.symver name, name2@nodename
If the symbol name is defined within the file being assembled, the .symver dir
ective effectively creates a symbol alias with the name name2@nodename, and in
fact the main reason that we just don’t try and create a regular alias is th
at the @ character isn’t permitted in symbol names. The name2 part of the nam
e is the actual name of the symbol by which it will be externally referenced.
The name name itself is merely a name of convenience that is used so that it i
s possible to have definitions for multiple versions of a function within a si
ngle source file, and so that the compiler can unambiguously know which versio
n of a function is being mentioned. The nodename portion of the alias should b
e the name of a node specified in the version script supplied to the linker wh
en building a shared library. If you are attempting to override a versioned sy
mbol from a shared library, then nodename should correspond to the nodename of
the symbol you are trying to override.
If the symbol name is not defined within the file being assembled, all referen
ces to name will be changed to name2@nodename. If no reference to name is made
, name2@nodename will be removed from the symbol table.
Another usage of the .symver directive is:
.symver name, name2@@nodename
In this case, the symbol name must exist and be defined within the file being
assembled. It is similar to name2@nodename. The difference is name2@@nodename
will also be used to resolve references to name2 by the linker.
The third usage of the .symver directive is:
.symver name, name2@@@nodename
When name is not defined within the file being assembled, it is treated as nam
e2@nodename. When name is defined within the file being assembled, the symbol
name, name, will be changed to name2@@nodename.
7.80 .symver
使用.symver命令把符号装订到在源文件里指定的节点。本命令只在ELF平台上可用,如果
当前汇编的文件被连接到一个共享库中时常常用到。有些情况下应该在目标文件中使用本
命令,把目标文件自我装订进某个应用软件中,从而取代共享库中旧版本符号。
对于ELF目标,.symver命令可以这样使用:
.symver name, name2@nodename
如果符号name的定义在当前正在汇编的文件中,这个.symver命令实际用name2@nodename创
建一个符号别名,而且我们不打算创建一个正规的别名,因为在符号名中是不允许存在‘
@’这个字符的。别名中name2才是符号的真正名字,外部访问是通过这个名字进行的。符
号自己的名字name仅仅为了使用上的方便,这样在同一个源文件中的一个函数才可能有多
个定义体;编译器才能够清楚当前使用的函数是哪个具体的定义。别名中的nodename部分
应是某个节点的名字,这个节点的名字是在建立共享库时,提供给连接器的版本脚本中指
定的。如果您想覆盖共享库中的旧版本符号,则nodename应该是将被取代符号的节点名。
如果符号name的定义不在当前正在汇编的文件中,则所有对name的访问都变为对name2@no
dename的访问。如果根本没有对name的访问,将会把name2@nodename从符号表中删除。
.symver命令的另一种用法:
.symver name, name2@@nodename
在这种情况下,符号name必须存在,并且它必须在当前正在汇编的文件中被定义。这类似
与name2@nodename。区别是name2@@nodename还被连接器用来解析对name2的访问。//注:
对name2的访问被转向到nodename
.symver命令的第3种用法:
.symver name, name2@@@nodename
如果name不是在当前正在汇编的文件中被定义的时候,对符号的处理就如同name2@nodena
me。如果name是当前正在汇编的文件中定义的,符号的名字name,会被转换为name2@@nod
ename。
7.81 .tag structname
This directive is generated by compilers to include auxiliary debugging inform
ation in the symbol table. It is only permitted inside .def/.endef pairs. Tags
are used to link structure definitions in the symbol table with instances of
those structures.
‘.tag’ is only used when generating COFF format output; when as is generatin
g b.out, it accepts this directive but ignores it.
7.81 .tag structname
本命令由编译器生成,用来在符号表中增加调试辅助的信息。本命令只允许在.def/.ende
f语句对内使用。标饰(tags)常用来连接符号表中的结构定义和该结构实例。
‘.tag’只能在生成COFF格式的输出文件时使用。当as生成b.out格式的输出文件时,接受
本命令但忽略之。
7.82 .text subsection
Tells as to assemble the following statements onto the end of the text subsect
ion numbered subsection, which is an absolute expression. If subsection is omi
tted, subsection number zero is used.
7.82 .text subsection
通知as把后续语句汇编到编号为subsection的正文子段的末尾,subsection是一个纯粹的
表达式。如果省略了参数subsection,则使用编号为0的子段。
7.83 .title "heading"
Use heading as the title (second line, immediately after the source file name
and page number) when generating assembly listings.
This directive affects subsequent pages, as well as the current page if it app
ears within ten lines of the top of a page.
7.83 .title "heading"
当生成汇编清单时,把heading作为标题使用(标题在第2行,紧跟在源文件名和页号后)
。
如果这个命令出现在某页的前10行中,它不但作用影响到后续的页,也同样影响到当前页
。
7.84 .type int (COFF version)
This directive, permitted only within .def/.endef pairs, records the integer i
nt as the type attribute of a symbol table entry.
‘.type’ is associated only with COFF format output; when as is configured fo
r b.out output, it accepts this directive but ignores it.
7.84 .type int (COFF 版本)
本命令紧允许在.def/.endef 命令对之间使用,把整数int作为类型属性记录进符号表表项
。
‘.type’只和COFF格式的输出有关,当as配置生成b.out输出格式时,as接受本命令但忽
略之。
7.85 .type name , type description (ELF version)
This directive is used to set the type of symbol name to be either a function
symbol or an object symbol. There are five different syntaxes supported for th
e type description field, in order to provide compatibility with various other
assemblers. The syntaxes supported are:
.type
.type
.type
.type
.type
.type
.type
.type
.type
.type
7.85 .type name , type description (ELF 版本)
本命令经常用来设置符号name的类型(属性)为函数符号或是目标符号两者之一。type d
escription部分允许使用5种不同的语法,以兼容众多的汇编器。这些语法是:
.type
.type
.type
.type
.type
.type
.type
.type
.type
.type
7.86 .uleb128 expressions
uleb128 stands for “unsigned little endian base 128.” This is a compact, var
iable length representation of numbers used by the DWARF symbolic debugging fo
rmat. See Section 7.73 [Sleb128], page 54.
7.86 .uleb128 expressions
uleb128代表“unsigned little endian base 128”(低地址结尾的无符号128位基数)。这
是一个紧凑的,变长的数字表示方法,当使用DWARF符号调试格式时使用。参见7.83 [Sle
b128], 54页。
7.87 .val addr
This directive, permitted only within .def/.endef pairs, records the address a
ddr as the value attribute of a symbol table entry.
‘.val’ is used only for COFF output; when as is configured for b.out, it acc
epts this directive but ignores it.
7.87 .val addr
本命令只能在.def/.endef命令对之间使用,把addr的地址作为值属性存入符号表的表项中
。
‘.val’命令只能在COFF输出时使用;当as被配置成生成b.out输出时,接受本命令但忽略
之。
7.88 .version "string"
This directive creates a .note section and places into it an ELF formatted not
e of type NT VERSION. The note’s name is set to string.
7.88 .version "string"
本命令创建一个.note段,并把一个NT VERSION类型ELF格式的note放入该.note段。Note的
名字被设置为string。
7.89 .vtable_entry table, offset
This directive finds or creates a symbol table and creates a VTABLE_ENTRY relo
cation for it with an addend of offset.
7.89 .vtable_entry table, offset
本命令寻找或创建一个符号表,并用offset作偏移量的增量,为此符号表产生一个VTABLE
_ENTRY重定位。
7.90 .vtable_inherit child, parent
This directive finds the symbol child and finds or creates the symbol parent a
nd then creates a VTABLE_INHERIT relocation for the parent whose addend is the
value of the child symbol. As a special case the parent name of 0 is treated
as refering the *ABS* section.
7.90 .vtable_inherit child, parent
本命令寻找符号child, 并寻找或创建符号parent,为符号parent产生一个VTABLE_INHERI
T重定位,parent的偏移量增量为符号child的值。一个特例,如果parent的名字为0,则将
它交给*ABS*段处理。
7.91 .weak names
This directive sets the weak attribute on the comma separated list of symbol n
ames. If the symbols do not already exist, they will be created.
7.91 .weak names
本命令设置names中每个符号(由逗号分隔)的weak属性。如果这些符号尚不存在,则创建
这些符号。
7.92 .word expressions
This directive expects zero or more expressions, of any section, separated by
commas.
The size of the number emitted, and its byte order, depend on what target comp
uter the assembly is for.
Warning: Special Treatment to support Compilers
Machines with a 32-bit address space, but that do less than 32-bit addressing,
require the following special treatment. If the machine of interest to you do
es 32-bit addressing (or doesn’t require it; see Chapter 8 [Machine Dependenc
ies], page 61), you can ignore this issue.
In order to assemble compiler output into something that works, as occasionall
y does strange things to ‘.word’ directives. Directives of the form ‘.word
sym1-sym2’ are often emitted by compilers as part of jump tables. Therefore,
when as assembles a directive of the form ‘.word sym1-sym2’, and the differe
nce between sym1 and sym2 does not fit in 16 bits, as creates a secondary jump
table, immediately before the next label. This secondary jump table is preced
ed by a short-jump to the first byte after the secondary table. This short-jum
p prevents the flow of control from accidentally falling into the new table. I
nside the table is a long-jump to sym2. The original ‘.word’ contains sym1 m
inus the address of the long-jump to sym2.
If there were several occurrences of ‘.word sym1-sym2’ before the secondary
jump table, all of them are adjusted. If there was a ‘.word sym3-sym4’, that
also did not fit in sixteen bits, a long-jump to sym4 is included in the seco
ndary jump table, and the .word directives are adjusted to contain sym3 minus
the address of the long-jump to sym4; and so on, for as many entries in the or
iginal jump table as necessary.
7.92 .word expressions
本命令可不带表达式或带多个表达式,这些表达式可以属于任意段,每个表达式由逗号分
隔。
汇编生成的数字的大小,字节顺序视生成程序运行的目标机器而定。
警告:支持编译器的特殊处理
有些机器具有32位地址空间,但不能完全进行32位寻址,需要下列的特殊处理。如果您关
心的机器能够进行32位寻址,(或者根本不需要32位寻址;见第8章[机器相关性],61页)
则可以忽略这个问题。
为了使由编译器产生源码的汇编结果能够正确地运行,as偶尔会对'.word'命令进行些奇怪
的操作。编译器在跳转表部分经常生成类似'.word sym1-sym2'形式的命令。所以,当as汇
编一条形如'.word sym1-sym2'的命令,且sym1和sym2之间的偏移量大于16位时,as会在下
个标签前创建一个'次级跳转表',在'次级跳转表'前面加插上一个短-跳转指令,这个短-跳
转指令的目的地址是'次级跳转表'之后的第一个字节。 这个短跳转防止控制流程意外地落
入新的跳转表(次级跳转表)。在'次级跳转表'内是个目的地址为sym2的长-跳转指令。原
来的'.word'命令调整为sym1减去到sym2的长-跳转指令地址,。
如果在次级跳转表前出现了几个'.word sym1-sym2',这些命令都要进行调整。如果存在一
个'.word sym3-sym4',且地址差也大与16位,次级跳转表中将包含一个至sym4的长-跳转
指令,且.word命令将被调整为包含sym3减去到sym4长-跳转指令的地址; 如是类推,处理
原始跳转表中的需要处理的各个表项。
7.93 Deprecated Directives
One day these directives won’t work. They are included for compatibility with
older assemblers.
.abort
.line
7.93 不赞成使用的命令
将来下列命令可能不再被支持,它们的存在只是为了与老版本的汇编器相兼容。
.abort
.line