This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFC: Remove output_target in ld


"H. J. Lu" <hjl@lucon.org> writes:

> On Sun, May 21, 2006 at 03:30:02PM -0700, H. J. Lu wrote:
> > ld has both output_target and ld_emulation, which has a target_name
> > field. Both of them are supposed to specify the output target name.
> > However, they aren't consistent, especially when a linker supports
> > different endians. Why do we need output_target? Can we set
> > ld_emulation correctly and use ld_emulation->target_name to replace
> > output_target. Also ld supports the GNUTARGET enviroment variable.
> > But we don't use it to set ld_emulation. I'd like to modify ld to
> > make ld_emulation consistent:
> > 
> > 1. Initialize ld_emulation properly with
> >    a. GNUTARGET.
> >    b. -m EMULATION.
> >    and correct endian, based on -EL/-BL.
> > 2. Use ld_emulation->target_name to identify the output target.
> > 
> 
> I realized that emulation may be just a subset of supported targets.
> Can we generate little endian ELF with big endian emulation? If yes,
> how do we do it?

The MIPS targets do this, for example.  If you configure for mips-elf,
the emulation is elf32ebmip.  That defaults to big-endian.  If you
trace the emulparams file, you will find this:

SCRIPT_NAME=elf
OUTPUT_FORMAT="elf32-bigmips"
BIG_OUTPUT_FORMAT="elf32-bigmips"
LITTLE_OUTPUT_FORMAT="elf32-littlemips"

Then elf.sc does this:

test -z "${BIG_OUTPUT_FORMAT}" && BIG_OUTPUT_FORMAT=${OUTPUT_FORMAT}
test -z "${LITTLE_OUTPUT_FORMAT}" && LITTLE_OUTPUT_FORMAT=${OUTPUT_FORMAT}
...
OUTPUT_FORMAT("${OUTPUT_FORMAT}", "${BIG_OUTPUT_FORMAT}",
	      "${LITTLE_OUTPUT_FORMAT}")

The three argument OUTPUT_FORMAT specifies which output format to use
if -EB or -EL is explicitly specified.

So, yes, there are more output targets than there are emulations.

Originally there were only supposed to be a couple of emulations.  But
then we would up specifying all sorts of things in the emulation, like
the default text addresses.  We didn't have to put stuff like that in
the emulation for the a.out object file format, in which addresses are
implied.  So now it's true that every new target tends to add a new
emulation.  But that wasn't the original plan.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]