gcc and ld

gcc可以通过-Wl将参数传入ld命令

GCC:
-Wl,option

Pass option as an option to the linker. If option contains commas, it is split into multiple options at the commas.

LD:

-Tbss org

-Tdata org
-Ttext org
Same as –section-start, with .bss, .data or .text as the sectionname.

-T scriptfile

--script=scriptfile
Use scriptfile as the linker script. This script replaces ld's default linker script (rather than adding to it), so commandfile must specify everything necessary to describe the output file. See Scripts. If scriptfile does not exist in the current directory, ld looks for it in the directories specified by any preceding -L options. Multiple -T options accumulate.



例子:
gcc  -g  -nostdlib -Wl,-N,-Ttext,7C00 -Wl,-T../ldscript -o stage1.exec.exe  stage1.o 

objcopy -O binary stage1.exec.exe stage1

posted @ 2009-05-21 17:03  Fan Zhang  阅读(259)  评论(0)    收藏  举报