电子说
所有的伪指令都是以 . 开头命令,然后剩下的命名通常是小写字母,比如 .section .type
格式:.section name [, "flags "[, %type [,flag_specific_arguments ]]]
The optional flags argument is a quoted string which may contain any combination of the 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
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 name , expression
This directive sets 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.
This directive is used to set the type of a symbol.
格式有多种形式,如下:
.type STT_
.type ,#
.type ,@
.type ,@
.type ,%
.type ,""
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.
.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
.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
.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 makes the symbol visible to ld. If you define symbol in your partial program, its value is made available to other partial programs that are linked with it. Otherwise, symbol takes its attributes from a symbol of the same name from another file linked into the same program.
.global 用于声明全局变量,是其让ld可见。
在当前地址放一个 32bit 的值
g_pfnVectors: .word _estack
.word Reset_Handler
.word NMI_Handler
.word HardFault_Handler
上面的代码表示,在连续相连的地址上,依次放各中断服务函数指针
审核编辑:符乾江
全部0条评论
快来发表一下你的评论吧 !