Is there a way to change the section start addresses when compiling?

Elden Crom EldenC@TucsonEmbedded.com
Mon Feb 15 16:54:00 GMT 2010


I think you want to change the linker map...

If you are invoking the linker (ld) directly then you can use  " -Ttext=org" or "-Wl,Ttext=org" from gcc's command line....
PS to see how the linker is getting invoked from gcc use  "gcc -v ...." and look at the invocation of 'collect2'.
gcc hello.c -v -Wl,-Ttext=0x8090000

________________________________________
From: gcc-help-owner@gcc.gnu.org [gcc-help-owner@gcc.gnu.org] on behalf of 안기찬 [externalist2@gmail.com]
Sent: Monday, February 15, 2010 9:14 AM
To: gcc-help@gcc.gnu.org
Subject: Is there a way to change the section start addresses when compiling?

For instance, if I compile a source code, the .text section ends up in
Virtual Address 0x8069b20. I was wondering if there was a way to force
the .text segment address to another address, say, 0x8090000. If
possible, I would like to change other section base addresses as well
such as .rodata and .bss etc, and so what I'm looking for is a compile
option for gcc for that purpose. Does such compile option exist?
If it does, then that would be the most ideal solution for my current
problem, but if not, it would still be nice if gcc could compile the
binary at a completely different ImageBase than 0x8048000(i.e.
0x8090000). Does any know of a way to do those things? Thanks in
advance! and sorry for my sloppy english. ;)



More information about the Gcc-help mailing list