所有的伪指令都是以 . 开头命令,然后剩下的命名通常是小写字母,比如 .section .type
.section
格式:.section name [, "flags "[, %type [,flag_specific_arguments ]]]
flags:
The optional flags argument is a quoted string which may contain any combination ofthe following characters:
a section is allocatable
w section is writable
x section is executable
M section is mergeable
S section contains zero terminated strings
G section is a member of a section group
T section is used for thread-local-storage
type:
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)
note: section contains data which is used by things other than the program
init_array:section contains an array of pointers to init functions
fini_array:section contains an array of pointers to finish functions
preinit_array:section contains an array of pointers to pre-init functions
实例:
.section .stack, "aw", %nobits /* 命名一个”.stack"段, 该段具有可分配和可写属性,该段不包含数据,该段用于保存堆栈值 */
.size
格式:.size name , expression
This directive sets the size associated with a symbol name. The size in bytes is computedfrom expression which can make use of label arithmetic. This directive is typically used toset the size of function symbols.
.type
This directive is used to set the type of a symbol.
格式有多种形式,如下:
.type STT_
.type ,#
.type ,@
.type ,@
.type ,%
.type ,""
The types supported are:
STT_FUNC
function
Mark the symbol as being a function name.
STT_GNU_IFUNC
gnu_indirect_function
Mark the symbol as an indirect function when evaluated during reloc processing.
(This is only supported on Linux targeted assemblers).
STT_OBJECT
object
Mark the symbol as being a data object.
STT_TLS
tls_object
Mark the symbol as being a thead-local data object.
STT_COMMON
common
Mark the symbol as being a common data object.
STT_NOTYPE
notype
Does not mark the symbol in any way. It is supported just for completeness.
例子1
.section .text.Reset_Handler
.type Reset_Handler, %function Reset_Handler:
ldr sp, =_estack /* set stack pointer */
bl entry
bx lr
.size Reset_Handler, .-Reset_Handler
例子2
.section .text.Reset_Handler
.type Reset_Handler, STT_FUNC Reset_Handler:
ldr sp, =_estack /* set stack pointer */
bl entry
bx lr
.size Reset_Handler, .-Reset_Handler
例子3
.global g_pfnVectors .section
.isr_vector,"a",%progbits
.type g_pfnVectors, %object ;声明一个 object 对象
.size g_pfnVectors, .-g_pfnVectors
g_pfnVectors: .word _estack
.word Reset_Handler
.word NMI_Handler
.word HardFault_Handler
.word MemManage_Handler
.word BusFault_Handler
.word UsageFault_Handler
.global
.global makes the symbol visible to ld. If you define symbol in your partial program, itsvalue is made available to other partial programs that are linked with it. Otherwise, symboltakes its attributes from a symbol of the same name from another file linked into the sameprogram.
.global 用于声明全局变量,是其让ld可见。
.word
在当前地址放一个 32bit 的值
g_pfnVectors: .word _estack
.word Reset_Handler
.word NMI_Handler
.word HardFault_Handler
上面的代码表示,在连续相连的地址上,依次放各中断服务函数指针
审核编辑:符乾江
-
单片机
+关注
关注
6036文章
44557浏览量
635130 -
GNU
+关注
关注
0文章
143浏览量
17492
发布评论请先 登录
相关推荐
评论