This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
SH bfd patch to set correct CPU type checked in
- To: binutils at sourceware dot cygnus dot com
- Subject: SH bfd patch to set correct CPU type checked in
- From: Joern Rennecke <amylaar at cygnus dot co dot uk>
- Date: Thu, 31 Aug 2000 23:16:26 +0100 (BST)
- CC: amylaar at pasanda dot cygnus dot co dot uk, law at cygnus dot com
With the addition of the sh-dsp / sh3-dsp targets, it became necessary
to encode the cpu type in the elfheader, so that sh-dsp/sh3-dsp
programs can be distinguished from sh3e / sh4 object files.
I had used this opportunity to properly encode the minumum cpu required
to run a particular file, so that not only the simulator can select the
right instruction set, but also gdb can automatically select the right
register set to display.
To provide backwards compatibility, all flags cleared in the elfheader
are interpreted as sh4 code (since the sh4 instruction set is a superset
of the instruction set of all supported CPUs before the sh-dsp support
was added).
However, sometimes ld starts out with a 'blank' output file, meaning that
the flags are not initialized, and calls sh_elf_merge_private_data
when the first object file is loaded. Just zeroing the uninitialized flags
then is not what is wanted, since it means that everything is considered
to be SH4 code. The right action is to set the uninitialized flags to the
pattern used for SH1 code, which is the least common denominator of all
SH instruction sets.
Approved by Jeffrey Law.
Thu Aug 31 22:49:30 2000 J"orn Rennecke <amylaar@cygnus.co.uk>
* elf32-sh.c (sh_elf_merge_private_data): If ibfd's elf header flags
are not initialized, set them to indicate the SH1 instruction set.
Index: elf32-sh.c
===================================================================
RCS file: /cvs/cvsfiles/devo/bfd/elf32-sh.c,v
retrieving revision 1.8.12.7
diff -p -r1.8.12.7 elf32-sh.c
*** elf32-sh.c 2000/06/01 12:02:09 1.8.12.7
--- elf32-sh.c 2000/08/10 09:52:07
*************** sh_elf_merge_private_data (ibfd, obfd)
*** 2350,2357 ****
if (! elf_flags_init (obfd))
{
elf_flags_init (obfd) = true;
! elf_elfheader (obfd)->e_flags = 0;
}
old_flags = elf_elfheader (obfd)->e_flags;
new_flags = elf_elfheader (ibfd)->e_flags;
--- 2350,2358 ----
if (! elf_flags_init (obfd))
{
+ /* This happens when ld starts out with a 'blank' output file. */
elf_flags_init (obfd) = true;
! elf_elfheader (obfd)->e_flags = EF_SH1;
}
old_flags = elf_elfheader (obfd)->e_flags;
new_flags = elf_elfheader (ibfd)->e_flags;