More Related Content
Similar to Hello world make
Similar to Hello world make (20)
Hello world make
- 14. • Executable and Linkable Format の略
• Linux 等で用いられる実行ファイルの形式の一つ(Windows でいう
hoge.exe)
- 18. ELF ヘッダ
• 自分が ELF ファイルであることを示す文字列
• これがないとただのテキストファイルと見分けがつかない
• あとは互換性を考えたり、後述のプログラムヘッダの位置を記述し
たり、とにかく雑多なデータ
- 34. 6. ABI のバージョン (e_ident::EI_ABIVERSION)
• 1 byte
• EI_OSABI が System V ABI なのでここは 0x0 でいい
- 76. Hello World 表示用
• この後追加する .rodata のアドレスによって “Hello World” の位置
が変わる
• 今回は 0x40009f の位置に置かれるため
“¥x48¥xc7¥xc2¥x0d¥x00¥x00¥x00¥x48¥x8d¥x35¥x19¥x00¥x00¥x00¥x4
8¥xc7¥xc0¥x01¥x00¥x00¥x00¥x48¥xc7¥xc7¥x00¥x00¥x00¥x00¥x0f¥x05
¥x48¥xc7¥xc0¥x3c¥x00¥x00¥x00¥x0f¥x05”
- 77. mov rdx, 0xd
lea rsi, [0x40009f]
mov rax, 1
mov rdi, 0
syscall
mov rax, 0x3c
syscall
- 102. NULL セクション
• sh_name: 0x0
• sh_type: 0x0
• sh_flags: 0x0
• sh_addr: 0x0
• sh_offset: 0x0
• sh_size: 0x0
• sh_link: 0x0
• sh_info: 0x0
• sh_addralign: 0x0
• sh_entsize: 0x0
- 103. .shstrtab セクション
• sh_name: 0x1
• sh_type: 0x3
• sh_flags: 0x0
• sh_addr: 0x0
• sh_offset: 0xac
• sh_size: 0x19
• sh_link: 0x0
• sh_info: 0x0
• sh_addralign: 0x1
• sh_entsize: 0x0
- 104. .text セクション
• sh_name: 0xb
• sh_type: 0x1
• sh_flags: 0b0110
• sh_addr: 0x78
• sh_offset: 0x78
• sh_size: 0x27
• sh_link: 0x0
• sh_info: 0x0
• sh_addralign: 0x10
• sh_entsize: 0x0
- 105. .rodata セクション
• sh_name: 0x11
• sh_type: 0x1
• sh_flags: 0b0010
• sh_addr: 0x9f
• sh_offset: 0x9f
• sh_size: 0xd
• sh_link: 0x0
• sh_info: 0x0
• sh_addralign: 0x4
• sh_entsize: 0x0