help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ELF executable & relocatable


From: Michael Eager
Subject: Re: ELF executable & relocatable
Date: Tue, 24 Jun 2003 11:11:31 -0700
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4a) Gecko/20030401

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     address@hidden
1960 Park Blvd., Palo Alto, CA 94306  650-325-8077





reply via email to

[Prev in Thread] Current Thread [Next in Thread]