public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* RFC: Remove output_target in ld
@ 2006-05-22  8:45 H. J. Lu
  2006-05-22  8:49 ` H. J. Lu
  0 siblings, 1 reply; 3+ messages in thread
From: H. J. Lu @ 2006-05-22  8:45 UTC (permalink / raw)
  To: binutils

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.


H.J.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: RFC: Remove output_target in ld
  2006-05-22  8:45 RFC: Remove output_target in ld H. J. Lu
@ 2006-05-22  8:49 ` H. J. Lu
  2006-05-22  8:57   ` Ian Lance Taylor
  0 siblings, 1 reply; 3+ messages in thread
From: H. J. Lu @ 2006-05-22  8:49 UTC (permalink / raw)
  To: binutils

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?


H.J.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: RFC: Remove output_target in ld
  2006-05-22  8:49 ` H. J. Lu
@ 2006-05-22  8:57   ` Ian Lance Taylor
  0 siblings, 0 replies; 3+ messages in thread
From: Ian Lance Taylor @ 2006-05-22  8:57 UTC (permalink / raw)
  To: H. J. Lu; +Cc: binutils

"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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-05-22  3:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-22  8:45 RFC: Remove output_target in ld H. J. Lu
2006-05-22  8:49 ` H. J. Lu
2006-05-22  8:57   ` Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).