無法理解 c 語言中那些 變量和常量 被加載到內(nèi)存里的存儲布局, 所以只能找gas文檔來學(xué)學(xué)匯編。
有關(guān)
.fill
這個(gè)偽指令的解釋, 無法明白到底是什么意思。
.fill repeat , size , value
result, size and value are absolute expressions. This emits repeat
copies of size bytes. Repeat may be zero or more. Size may be zero or more,
but if it is more than 8, then it is deemed to have the value 8, compatible with other people's assemblers. The contents of each repeat bytes is taken from an 8-byte number. The highest order 4 bytes are zero. The lowest order 4 bytes are value rendered in the byte-order of an interger on the computer as is assembling for. Each size bytes in a repetition is taken from the lowest order size bytes of this number. Again, this bizarre behavior is compatible with other people's assemblers.
size and value are optional. If the second comma and value are absent, value is assumed zero. If the firsr comma and following tokens are
absent, size is assumed to be 1.
--------------------------------------------------------------------------------
.fill repeat , size , value
result, size and value are absolute expressions.
結(jié)果,size 和 value是絕對表達(dá)式。
This emits repeat copies of size bytes. Repeat may be zero or more.
這個(gè)偽指令用來重復(fù)拷貝size大小的字節(jié)數(shù)。repeat (重復(fù)次數(shù))可以是零或更大。
Size may be zero or more,but if it is more than 8, then it is deemed to have the value 8, compatible with other people's assemblers.
size可以是零或更大,但是如果size比8大, 為了和其他的匯編器兼容,它的值會被認(rèn)為是8。
The contents of each repeat bytes is taken from an 8-byte number. The highest order 4 bytes are zero. The lowest order 4 bytes are value rendered in the byte-order of an interger on the computer as is assembling for.
每個(gè)重復(fù)拷貝的內(nèi)容被降低自于一個(gè)8字節(jié)的數(shù)。最高順序4字節(jié)是零。最低順序字節(jié)是value的值,在電腦上用一個(gè)字節(jié)順序的匯編整數(shù)來表示。
Each size bytes in a repetition is taken from the lowest order size bytes of this number. Again, this bizarre behavior is compatible with other people's assemblers.
每個(gè)size 字節(jié)被降低來自最低順序字節(jié)數(shù)。同樣的, 這些奇怪的行為也是為了和別的匯編器兼容。
size and value are optional. If the second comma and value are absent, value is assumed zero. If the firsr comma and following tokens are
absent, size is assumed to be 1.
size 和 value 是可選的。 如果第二個(gè)分號和value不寫, value 就被假定為1。如果第一個(gè)分號和后面的tokens 不寫,size 就被假定為1。
-----------------------------------------------------------------------------------------------
.
.
.
/arch/m32r/boot/compressed/head.S:55: .fillinsn
./arch/m32r/boot/setup.S:167: .fillinsn
./arch/xtensa/kernel/head.S:239: .fill PAGE_SIZE, 1, 0
./arch/xtensa/kernel/head.S:241: .fill PAGE_SIZE, 1, 0
./arch/xtensa/kernel/coprocessor.S:332: .fill XCHAL_CP_MAX, 4, 0
./arch/x86/kernel/head_32.S:616: .fill 1024*KPMDS,4,0
./arch/x86/kernel/head_32.S:619: .fill 1024,4,0
./arch/x86/kernel/head_32.S:622: .fill 1024,4,0
./arch/x86/kernel/head_32.S:624: .fill 4096,1,0
./arch/x86/kernel/head_32.S:713: .fill GDT_ENTRY_BOOT_CS,8,0
./arch/x86/kernel/trampoline_64.S:160: .fill 510,8,0
./arch/x86/kernel/head_64.S:356: .fill 511,8,0
./arch/x86/kernel/head_64.S:359: .fill L3_START_KERNEL,8,0
./arch/x86/kernel/head_64.S:365: .fill 506,8,0
./arch/x86/kernel/head_64.S:368: .fill 5,8,0
./arch/x86/kernel/head_64.S:371: .fill 512,8,0
./arch/x86/kernel/head_64.S:394: .fill 512, 8, 0
./arch/x86/boot/compressed/head_32.S:188: .fill BOOT_HEAP_SIZE, 1, 0
./arch/x86/boot/compressed/head_32.S:190: .fill BOOT_STACK_SIZE, 1, 0
./arch/x86/boot/compressed/head_64.S:320: .fill BOOT_HEAP_SIZE, 1, 0
./arch/x86/boot/compressed/head_64.S:322: .fill BOOT_STACK_SIZE, 1, 0
./arch/ia64/kvm/trampoline.S:98: ld8.fill r4=[r2],16; \
./arch/ia64/kvm/trampoline.S:99: ld8.fill r5=[r3],16; \
./arch/ia64/kvm/trampoline.S:101: ld8.fill r6=[r2],48; \
.
.
.作者: linux_Ultra 時(shí)間: 2009-7-25 08:44
./arch/x86/kernel/head_32.S
------------------------------
/*
* BSS section
*/
.section ".bss.page_aligned","wa"
.align PAGE_SIZE_asm
#ifdef CONFIG_X86_PAE
swapper_pg_pmd:
.fill 1024*KPMDS,4,0
#else
ENTRY(swapper_pg_dir)
.fill 1024,4,0
#endif
swapper_pg_fixmap:
.fill 1024,4,0
ENTRY(empty_zero_page)
.fill 4096,1,0作者: linux_Ultra 時(shí)間: 2009-7-25 08:50
如:
.fill 1024,4,0------------>拷貝1024個(gè)塊,每個(gè)塊是4個(gè)字節(jié),每個(gè)塊用0來初始化?作者: linux_Ultra 時(shí)間: 2009-7-25 13:13
在linuxforum上找到的這本gas手冊的翻譯項(xiàng)目。
關(guān)于這部分的翻譯:
-----------------------------------------------
7.28 .fill repeat , size , value
repeat, size and value are absolute expressions. This emits repeat copies of size bytes. Repeat may be zero or more. Size may be zero or more, but if it is more than 8, then it is deemed to have the value 8, compatible with other people’s assemblers. The contents of each repeat bytes are taken from an 8-byte number. The highest order 4 bytes are zero. The lowest order 4 bytes are value rendered in the byte-order of an integer on the computer as is assembling for. Each size bytes in a repetition is taken from the lowest order size bytes of this number. Again, this bizarre behavior is compatible with other people’s assemblers.
size and value are optional. If the second comma and value are absent, value is assumed zero. If the first comma and following tokens are absent, size is assumed to be 1.
7.3 .align abs-expr, abs-expr, abs-expr
Pad the location counter (in the current subsection) to a particular storage boundary. The first expression (which must be absolute) is the alignment required, as described below.
The second expression (also absolute) gives the fill value to be stored in the padding bytes. It (and the comma) may be omitted. If it is omitted, the padding bytes are normally zero. However, on some systems, if the section is marked as containing code and the fill value is omitted, the space is filled with no-op instructions.
The third expression is also absolute, and is also optional. If it is present, it is the maximum number of bytes that should be skipped by this alignment directive. If doing the alignment would require skipping more bytes than the specified maximum, then the alignment is not done at all. You can omit the fill value (the second argument) entirely by simply using two commas after the required alignment; this can be useful if you want the alignment to be filled with no-op instructions when appropriate.
The way the required alignment is specified varies from system to system. For the a29k, hppa, m68k, m88k, w65, sparc, and Hitachi SH, and i386 using ELF format, the first expression is the alignment request in bytes. For example ‘.align 8’ advances the location counter until it is a multiple of 8. If the location counter is already a multiple of 8, no change is needed.
For other systems, including the i386 using a.out format, and the arm and strongarm, it is the number of low-order zero bits the location counter must have after advancement. For example ‘.align 3’ advances the location counter until it a multiple of 8. If the location counter is already a multiple of 8, no change is needed.
This inconsistency is due to the different behaviors of the various native assemblers for these systems which GAS must emulate. GAS also provides .balign and .p2align directives, described later, which have a consistent behavior across all architectures (but are specific to GAS).