This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: ELF executable & relocatable
- From: Michael Eager <eager at eagercon dot com>
- To: S kris <kris_bs at hotmail dot com>
- Cc: gcc at gcc dot gnu dot org, help-make at gnu dot org
- Date: Tue, 24 Jun 2003 11:11:31 -0700
- Subject: Re: ELF executable & relocatable
- References: <Law14-F93NLXiEzCS4J00029b8b@hotmail.com>
S kris wrote:
hi
I have a very strange query? please clarify.
I understand that the ELF executable binary in Linux is usually not
relocatable. So how to make or produce an ELF executable binary to be
relocatable? Eventually the image should be both executable and
relocatable, so that if binary in not loaded at its preferred load
address then it should be able to fixup the addresses using .reloc section.
Try these linker flags:
`-q'
`--emit-relocs'
Leave relocation sections and contents in fully linked
exececutables. Post link analysis and optimization tools may need
this information in order to perform correct modifications of
executables. This results in larger executables.
`-r'
`--relocateable'
Generate relocatable output--i.e., generate an output file that
can in turn serve as input to `ld'. This is often called "partial
linking". As a side effect, in environments that support standard
Unix magic numbers, this option also sets the output file's magic
number to `OMAGIC'. If this option is not specified, an absolute
file is produced. When linking C++ programs, this option _will
not_ resolve references to constructors; to do that, use `-Ur'.
When an input file does not have the same format as the output
file, partial linking is only supported if that input file does
not contain any relocations. Different output formats can have
further restrictions; for example some `a.out'-based formats do
not support partial linking with input files in other formats at
all.
This option does the same thing as `-i'.
--
Michael Eager Eager Consulting eager@eagercon.com
1960 Park Blvd., Palo Alto, CA 94306 650-325-8077