Beruflich Dokumente
Kultur Dokumente
YoonMo Yeon
2007. 7. 5.
Contents
• Assembler’s Syntax
• Comments
• Symbol and Labels
• Code Sections and Section Directives
• Analysis of Cstartup.s
Comments
• C-style comments
• delimited by /* and */
• Single-line comments (target-dependent)
• @ ARM
• ; AMD29K, ARC, PA-RISC, picoJava,
PowerPC, M880x0
• ! Hitachi(H8 and SuperH), SPARC, Z8000
• | Motorola 680x0
• # Intel x86, i960, VAX, V850
Symbols and Labels
• Definition
• symbolname = value
• label:
• Period(‘.’)
• represents the current value of the location
counter
• label: syntax is identical to label=.
• . = . + 16
• . = 0x2000
Symbols and Labels
• Default sections
• .text
• typically containing code and read-only data
• stored in read-only memory or write-protected
with MMU
• .data
• read/write variables
• .bss
• uninitialized variables
Section Directives
• flags
• a - allocatable
• w - writable
• x - executable
• M - mergeable
• S - contains zero-terminated strings
Section Directives
• type
• @progbits or @nobits
• entsize
• if flag M is specified, then the entsize must be
specified
• if flag S is specified, the section contains entsize
bytes long characters
• if flag S is not specified, the section contains
fixed entsize bytes long constants
Analysis of Cstartup.s
• .extern
• similar to C ‘extern’
directive
• .global
• can be referenced by
external modules
• .text
• indicates text section
• .code
• ARM instructions are
32bit(word)
Analysis of Cstartup.s
• .set
• .equ
Analysis of Cstartup.s
• Stack Setup
• load the end of stack
• Start of main()
• section boundaries
• defined in ld script
• begin/end
of .bss, .data, stack
Analysis of Cstartup.s
• Vector table
Analysis of Cstartup.s
End of Presentation
• Q&A