強制編譯空的section
說明
- 一般默認如果一個
section
沒有內容是不會創建的。不過不知道最新的
ld,gcc
有沒有修改。強制
. = 0, . = . + 0, . = sym, . = . + sym and . = ALIGN (. != 0, expr, 1)
. = .
案例
環境
centos 7,gcc 4.8.5
代碼
test.c
int main() { asm("movl $42, %ebx \n\t" "movl $1 , %eax \n\t" "int $0x80 \n\t"); }
makefile
.PHONY:all clean ENTRY=-e main all: gcc -fno-builtin -c test.c -o test.o -g ld -T link.lds test.o -g -o ad.out $(ENTRY) clean: rm -f test.o *.out
link
腳本SECTIONS { .text 0x400404 : { *(.text) } .empty : { . = . ; } }