Basic Linker Script Concepts
Every loadable or allocatable output section has two addresses. The first is the VMA, or virtual memory address. This is the address the section will have when the output file is run. The second is the LMA, or load memory address. This is the address at which the section will be loaded.
You can see the sections in an object file by using the objdump
program with the -h option.
例如执行
objdump XX.exe –h
stage1.exec.exe: file format pei-i386
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00000200 00007c00 00007c00 000001f0 2**4
CONTENTS, ALLOC, LOAD, CODE
1 .stab 000006c0 00007e00 00007e00 000003f0 2**2
CONTENTS, READONLY, DEBUGGING
2 .stabstr 00000038 000084c0 000084c0 00000bf0 2**0
CONTENTS, READONLY, DEBUGGING
You can see the symbols in an object file by using the nm
program, or by using the objdump
program with the -t option.
objdump XX.exe –t
stage1.exec.exe: file format pei-i386
SYMBOL TABLE:
[ 0](sec -2)(fl 0x00)(ty 0)(scl 103) (nx 1) 0x00000002 stage1.S
File
[ 2](sec -2)(fl 0x00)(ty 0)(scl 103) (nx 1) 0x00000004 stage1.S
File
[ 4](sec -2)(fl 0x00)(ty 0)(scl 103) (nx 1) 0x00000006 ./stage1.h
File
[ 6](sec -2)(fl 0x00)(ty 0)(scl 103) (nx 1) 0x00000008 stage1.S
File
[ 8](sec -2)(fl 0x00)(ty 0)(scl 103) (nx 1) 0x0000000a <command line>
File
[ 10](sec -2)(fl 0x00)(ty 0)(scl 103) (nx 1) 0x0000000c <built-in>
File
[ 12](sec -2)(fl 0x00)(ty 0)(scl 103) (nx 1) 0x0000000e c:\My_Code\tmp\grub4dos-0.4.4\stage1//
File
[ 14](sec -2)(fl 0x00)(ty 0)(scl 103) (nx 1) 0x0000003f stage1.S
File
[ 16](sec 1)(fl 0x00)(ty 0)(scl 6) (nx 0) 0x0000004a after_BPB
[ 17](sec 1)(fl 0x00)(ty 0)(scl 6) (nx 0) 0x00000004 mode
[ 18](sec 1)(fl 0x00)(ty 0)(scl 6) (nx 0) 0x00000005 disk_address_packet
[ 19](sec 1)(fl 0x00)(ty 0)(scl 6) (nx 0) 0x00000005 sectors
[ 20](sec 1)(fl 0x00)(ty 0)(scl 6) (nx 0) 0x00000009 heads
[ 21](sec 1)(fl 0x00)(ty 0)(scl 6) (nx 0) 0x0000000d cylinders
[ 22](sec 1)(fl 0x00)(ty 0)(scl 6) (nx 0) 0x0000000f sector_start
[ 23](sec 1)(fl 0x00)(ty 0)(scl 6) (nx 0) 0x00000010 head_start
[ 24](sec 1)(fl 0x00)(ty 0)(scl 6) (nx 0) 0x00000011 cylinder_start
[ 25](sec 1)(fl 0x00)(ty 0)(scl 6) (nx 0) 0x0000003e stage1_version
[ 26](sec 1)(fl 0x00)(ty 0)(scl 6) (nx 0) 0x00000040 boot_drive
[ 27](sec 1)(fl 0x00)(ty 0)(scl 6) (nx 0) 0x00000041 force_lba
[ 28](sec 1)(fl 0x00)(ty 0)(scl 6) (nx 0) 0x00000042 stage2_address
[ 29](sec 1)(fl 0x00)(ty 0)(scl 6) (nx 0) 0x00000044 stage2_sector
[ 30](sec 1)(fl 0x00)(ty 0)(scl 6) (nx 0) 0x00000048 stage2_segment
[ 31](sec 1)(fl 0x00)(ty 0)(scl 6) (nx 0) 0x0000004b boot_drive_check
[ 32](sec 1)(fl 0x00)(ty 0)(scl 6) (nx 0) 0x00000059 real_start
[ 33](sec 1)(fl 0x00)(ty 0)(scl 6) (nx 0) 0x0000017f notification_string
[ 34](sec 1)(fl 0x00)(ty 0)(scl 6) (nx 0) 0x000001a7 message
[ 35](sec 1)(fl 0x00)(ty 0)(scl 6) (nx 0) 0x000000cc chs_mode
[ 36](sec 1)(fl 0x00)(ty 0)(scl 6) (nx 0) 0x00000095 lba_mode
[ 37](sec 1)(fl 0x00)(ty 0)(scl 6) (nx 0) 0x00000149 copy_buffer
[ 38](sec 1)(fl 0x00)(ty 0)(scl 6) (nx 0) 0x000000dc final_init
[ 39](sec 1)(fl 0x00)(ty 0)(scl 6) (nx 0) 0x000001c3 floppy_probe
[ 40](sec 1)(fl 0x00)(ty 0)(scl 6) (nx 0) 0x00000169 hd_probe_error
[ 41](sec 1)(fl 0x00)(ty 0)(scl 6) (nx 0) 0x00000106 setup_sectors
[ 42](sec 1)(fl 0x00)(ty 0)(scl 6) (nx 0) 0x00000161 geometry_error
[ 43](sec 1)(fl 0x00)(ty 0)(scl 6) (nx 0) 0x00000171 read_error
[ 44](sec 1)(fl 0x00)(ty 0)(scl 6) (nx 0) 0x00000185 geometry_error_string
[ 45](sec 1)(fl 0x00)(ty 0)(scl 6) (nx 0) 0x00000177 general_error
[ 46](sec 1)(fl 0x00)(ty 0)(scl 6) (nx 0) 0x0000018a hd_probe_error_string
[ 47](sec 1)(fl 0x00)(ty 0)(scl 6) (nx 0) 0x00000194 read_error_string
[ 48](sec 1)(fl 0x00)(ty 0)(scl 6) (nx 0) 0x00000199 general_error_string
[ 49](sec 1)(fl 0x00)(ty 0)(scl 6) (nx 0) 0x0000017d stop
[ 50](sec 1)(fl 0x00)(ty 0)(scl 6) (nx 0) 0x000001b8 nt_magic
[ 51](sec 1)(fl 0x00)(ty 0)(scl 6) (nx 0) 0x000001be part_start
[ 52](sec 1)(fl 0x00)(ty 0)(scl 6) (nx 0) 0x000001be probe_values
[ 53](sec 1)(fl 0x00)(ty 0)(scl 6) (nx 0) 0x000001c6 probe_loop
[ 54](sec 1)(fl 0x00)(ty 0)(scl 6) (nx 0) 0x000001da fd_probe_error_string
[ 55](sec 1)(fl 0x00)(ty 0)(scl 3) (nx 1) 0x00000000 .text
AUX scnlen 0x200 nreloc 1 nlnno 0
[ 57](sec 0)(fl 0x00)(ty 0)(scl 3) (nx 1) 0x00000000 .data
AUX scnlen 0x0 nreloc 0 nlnno 0
[ 59](sec 0)(fl 0x00)(ty 0)(scl 3) (nx 1) 0x00000000 .bss
AUX scnlen 0x0 nreloc 0 nlnno 0
[ 61](sec 2)(fl 0x00)(ty 0)(scl 3) (nx 1) 0x00000000 .stab
AUX scnlen 0x6c0 nreloc 143 nlnno 0
[ 63](sec -1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00007e00 __rdata_end__
[ 64](sec -1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00007e00 __data_start__
[ 65](sec -1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00001000 __size_of_stack_commit__
[ 66](sec -1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00200000 __size_of_stack_reserve__
[ 67](sec -1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000004 __major_subsystem_version__
[ 68](sec -1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00007e00 edata
[ 69](sec -1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00007e00 __bss_start__
[ 70](sec -1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00001000 __size_of_heap_commit__
[ 71](sec -1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00007e00 __common_start__
[ 72](sec -1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 __dll__
[ 73](sec -1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 __minor_os_version__
[ 74](sec -1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00400000 __image_base__
[ 75](sec -1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00001000 __section_alignment__
[ 76](sec -1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00007e00 end
[ 77](sec -1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00007e00 __data_end__
[ 78](sec 1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000200 etext
[ 79](sec -1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00007e00 __bss_end__
[ 80](sec 1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 _start
[ 81](sec -1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000200 __file_alignment__
[ 82](sec -1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000004 __major_os_version__
[ 83](sec -1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00100000 __size_of_heap_reserve__
[ 84](sec -1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000003 __subsystem__
[ 85](sec -1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00007e00 __rdata_start__
[ 86](sec -1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000001 __major_image_version__
[ 87](sec -1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 __loader_flags__
[ 88](sec -1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 __minor_subsystem_version__
[ 89](sec -1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 __minor_image_version__
[ 90](sec 1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 start