Simple Sand Samples |
説明のないとってもシンプルなサンプルプログラム集
COBOL | awk | C言語 | D言語 | GO言語 | Lua | Vim |
bash | Perl | Gauche | Clojure | CLISP | EmacsLisp | VimScript |
tcsh | Ruby | Groovy | Java | C# | VBScript | JavaScript |
Io言語 | Python | Erlang | Scala | VB.NET | Excel/VBA | PHP |
Tcl | Haskell | OCaml | PowerShell | Windows | Unix/Linux |
Linuxコマンド > ld リンクコマンド
|
|
sample.c(C言語ソース例)
|
|
sample.ld(リンカスクリプト例)
|
|
~$ ls
sample.c
sample.ld
~$ gcc -c sample.c
~$ ls
sample.c
sample.ld
sample.o
Allocating common symbols
Common symbol size file
a 0x4 sample.o
Memory Configuration
Name Origin Length Attributes
rom 0x0000000000000000 0x0000000000020000 xr
ram 0x0000000000010000 0x0000000000100000 !xr
ram2 0x0000000000040000 0x0000000000400000 !xr
*default* 0x0000000000000000 0xffffffffffffffff
Linker script and memory map
0x0000000000001000 samplelabel = 0x1000
.text 0x0000000000000000 0xd
*(.text)
.text 0x0000000000000000 0xd sample.o
0x0000000000000000 main
.iplt 0x0000000000000010 0x0
.iplt 0x0000000000000000 0x0 sample.o
.eh_frame 0x0000000000000010 0x58
.eh_frame 0x0000000000000010 0x58 sample.o
.rel.dyn 0x0000000000000068 0x0
.rel.iplt 0x0000000000000000 0x0 sample.o
.data 0x0000000000010000 0x9
*(.data)
.data 0x0000000000010000 0x4 sample.o
0x0000000000010000 b
*(.ABC_SECTION)
.ABC_SECTION 0x0000000000010004 0x5 sample.o
0x0000000000010004 c
.igot.plt 0x000000000001000c 0x0
.igot.plt 0x0000000000000000 0x0 sample.o
.bss 0x0000000000040000 0x4
*(.bss)
.bss 0x0000000000040000 0x0 sample.o
COMMON 0x0000000000040000 0x4 sample.o
0x0000000000040000 a
LOAD sample.o
OUTPUT(a.out elf32-i386)
.comment 0x0000000000000000 0x1c
.comment 0x0000000000000000 0x1c sample.o
0x1d (size before relaxing)
.note.GNU-stack
0x0000000000000000 0x0
.note.GNU-stack
0x0000000000000000 0x0 sample.o
sample.c
sample.ld
~$ gcc -c sample.c
~$ ls
sample.c
sample.ld
sample.o
リンカスクリプトを指定してリンクコマンド実行
~$ ld -T sample.ld sample.oメモリMAP表示
~$ ld -T sample.ld sample.o -MAPAllocating common symbols
Common symbol size file
a 0x4 sample.o
Memory Configuration
Name Origin Length Attributes
rom 0x0000000000000000 0x0000000000020000 xr
ram 0x0000000000010000 0x0000000000100000 !xr
ram2 0x0000000000040000 0x0000000000400000 !xr
*default* 0x0000000000000000 0xffffffffffffffff
Linker script and memory map
0x0000000000001000 samplelabel = 0x1000
.text 0x0000000000000000 0xd
*(.text)
.text 0x0000000000000000 0xd sample.o
0x0000000000000000 main
.iplt 0x0000000000000010 0x0
.iplt 0x0000000000000000 0x0 sample.o
.eh_frame 0x0000000000000010 0x58
.eh_frame 0x0000000000000010 0x58 sample.o
.rel.dyn 0x0000000000000068 0x0
.rel.iplt 0x0000000000000000 0x0 sample.o
.data 0x0000000000010000 0x9
*(.data)
.data 0x0000000000010000 0x4 sample.o
0x0000000000010000 b
*(.ABC_SECTION)
.ABC_SECTION 0x0000000000010004 0x5 sample.o
0x0000000000010004 c
.igot.plt 0x000000000001000c 0x0
.igot.plt 0x0000000000000000 0x0 sample.o
.bss 0x0000000000040000 0x4
*(.bss)
.bss 0x0000000000040000 0x0 sample.o
COMMON 0x0000000000040000 0x4 sample.o
0x0000000000040000 a
LOAD sample.o
OUTPUT(a.out elf32-i386)
.comment 0x0000000000000000 0x1c
.comment 0x0000000000000000 0x1c sample.o
0x1d (size before relaxing)
.note.GNU-stack
0x0000000000000000 0x0
.note.GNU-stack
0x0000000000000000 0x0 sample.o