@(编译相关)[gcc设置段基址]html
[TOC]node
向gcc/g++中传入这个命令行选项:-Wl,-Ttext-segment=<地址>
,-Wl表示这个命令行选项是传给连接器(即,ld)的。shell
查找ld的命令行选项手册(https://ftp.gnu.org/old-gnu/Manuals/ld-2.9.1/html_node/ld_3.html#SEC3)可找到下面的说明:命令行
-Tbss org -Tdata org -Ttext org Use org as the starting address for--respectively--the bss, data, or the text segment of the output file. org must be a single hexadecimal integer; for compatibility with other linkers, you may omit the leading `0x' usually associated with hexadecimal values.
上面英文的意思是:使用org做为输出文件的bss,data或text段的起始地址。org必须是一个十六进制整数;为了与其余连接器兼容,不要在十六进制数的前面添加'0x'。code
起始地址能够理解为基址。htm
我没有找到"-Ttext-segment"这个命令行选项,我认为"-Ttext-segment"与"-Ttext"表示同一个意思。ci
使用下面的命令,gcc编译出来的ELF文件的text段基址为0x60000000:get
gcc -Wl,-Ttext-segment=0x60000000 ...