所有的偽指令都是以 . 開(kāi)頭命令,然后剩下的命名通常是小寫(xiě)字母,比如 .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
實(shí)例:
.section .stack, "aw", %nobits /* 命名一個(gè)”.stack"段, 該段具有可分配和可寫(xiě)屬性,該段不包含數(shù)據(jù),該段用于保存堆棧值 */
.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 ;聲明一個(gè) object 對(duì)象
.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可見(jiàn)。
.word
在當(dāng)前地址放一個(gè) 32bit 的值
g_pfnVectors: .word _estack
.word Reset_Handler
.word NMI_Handler
.word HardFault_Handler
上面的代碼表示,在連續(xù)相連的地址上,依次放各中斷服務(wù)函數(shù)指針
審核編輯:符乾江
-
單片機(jī)
+關(guān)注
關(guān)注
6040文章
44594瀏覽量
636915 -
GNU
+關(guān)注
關(guān)注
0文章
143瀏覽量
17517
發(fā)布評(píng)論請(qǐng)先 登錄
相關(guān)推薦
評(píng)論