This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[patch] Tweak the use of EF_M68K_... flags.
- From: Kazu Hirata <kazu at codesourcery dot com>
- To: binutils at sourceware dot org
- Date: Thu, 7 Dec 2006 08:01:12 -0800
- Subject: [patch] Tweak the use of EF_M68K_... flags.
Hi,
Attached is a patch to tweak the use of EF_M68K_... flags in
preparation for mering fido support. (Note that fido is a new CPU32
variant.)
When we merge the fido support, we are planning to reuse the bottom 8
bits of EF_M68K_... flags to specify CPU32 variants. The new
semantics of e_flags is as follows:
- If the upper 24 bits are equal to EF_M68K_68000, then the bottom 8
bits do not mean anything.
- If the upper 24 bits are equal to EF_M68K_CPU32, then the bottom 8
bits specify CPU32 variants.
- Otherwise, the bottom 8 bits specify ColdFire variants.
This patch replaces every if-then-else chain for EF_M68K_* to:
if ((eflags & EF_M68K_ARCH_MASK) == EF_M68K_M68000)
/* We are M68000. */
;
else if ((eflags & EF_M68K_ARCH_MASK) == EF_M68K_CPU32)
/* We are CPU32. */
;
else
/* We are ColdFire. */
;
Tested by building binutils. OK to apply?
Kazu Hirata
bfd/
2006-12-07 Kazu Hirata <kazu@codesourcery.com>
* elf32-m68k.c (elf32_m68k_object_p,
elf32_m68k_print_private_bfd_data): Use EF_M68K_ARCH_MASK to
extract architecture mask.
include/elf/
2006-12-07 Kazu Hirata <kazu@codesourcery.com>
* m68k.h (EF_M68K_ARCH_MASK): New.
Index: bfd/elf32-m68k.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-m68k.c,v
retrieving revision 1.94
diff -c -d -p -r1.94 elf32-m68k.c
*** bfd/elf32-m68k.c 7 Dec 2006 15:39:01 -0000 1.94
--- bfd/elf32-m68k.c 7 Dec 2006 15:45:04 -0000
*************** elf32_m68k_object_p (bfd *abfd)
*** 429,439 ****
unsigned features = 0;
flagword eflags = elf_elfheader (abfd)->e_flags;
! if (eflags & EF_M68K_M68000)
features |= m68000;
! else if (eflags & EF_M68K_CPU32)
features |= cpu32;
! else if (eflags & EF_M68K_CF_ISA_MASK)
{
switch (eflags & EF_M68K_CF_ISA_MASK)
{
--- 429,439 ----
unsigned features = 0;
flagword eflags = elf_elfheader (abfd)->e_flags;
! if ((eflags & EF_M68K_ARCH_MASK) == EF_M68K_M68000)
features |= m68000;
! else if ((eflags & EF_M68K_ARCH_MASK) == EF_M68K_CPU32)
features |= cpu32;
! else
{
switch (eflags & EF_M68K_CF_ISA_MASK)
{
*************** elf32_m68k_merge_private_bfd_data (ibfd,
*** 518,525 ****
else
{
out_flags = elf_elfheader (obfd)->e_flags;
! in_isa = (in_flags & EF_M68K_CF_ISA_MASK);
! out_isa = (out_flags & EF_M68K_CF_ISA_MASK);
if (in_isa > out_isa)
out_flags ^= in_isa ^ out_isa;
out_flags |= in_flags ^ in_isa;
--- 518,534 ----
else
{
out_flags = elf_elfheader (obfd)->e_flags;
! unsigned int variant_mask;
!
! if ((in_flags & EF_M68K_ARCH_MASK) == EF_M68K_M68000)
! variant_mask = 0;
! else if ((in_flags & EF_M68K_ARCH_MASK) == EF_M68K_CPU32)
! variant_mask = 0;
! else
! variant_mask = EF_M68K_CF_ISA_MASK;
!
! in_isa = (in_flags & variant_mask);
! out_isa = (out_flags & variant_mask);
if (in_isa > out_isa)
out_flags ^= in_isa ^ out_isa;
out_flags |= in_flags ^ in_isa;
*************** elf32_m68k_print_private_bfd_data (abfd,
*** 548,605 ****
/* xgettext:c-format */
fprintf (file, _("private flags = %lx:"), elf_elfheader (abfd)->e_flags);
! if (eflags & EF_M68K_CPU32)
! fprintf (file, " [cpu32]");
!
! if (eflags & EF_M68K_M68000)
fprintf (file, " [m68000]");
!
! if (eflags & EF_M68K_CFV4E)
! fprintf (file, " [cfv4e]");
!
! if (eflags & EF_M68K_CF_ISA_MASK)
{
! char const *isa = _("unknown");
! char const *mac = _("unknown");
! char const *additional = "";
!
! switch (eflags & EF_M68K_CF_ISA_MASK)
! {
! case EF_M68K_CF_ISA_A_NODIV:
! isa = "A";
! additional = " [nodiv]";
! break;
! case EF_M68K_CF_ISA_A:
! isa = "A";
! break;
! case EF_M68K_CF_ISA_A_PLUS:
! isa = "A+";
! break;
! case EF_M68K_CF_ISA_B_NOUSP:
! isa = "B";
! additional = " [nousp]";
! break;
! case EF_M68K_CF_ISA_B:
! isa = "B";
! break;
! }
! fprintf (file, " [isa %s]%s", isa, additional);
! if (eflags & EF_M68K_CF_FLOAT)
! fprintf (file, " [float]");
! switch (eflags & EF_M68K_CF_MAC_MASK)
{
! case 0:
! mac = NULL;
! break;
! case EF_M68K_CF_MAC:
! mac = "mac";
! break;
! case EF_M68K_CF_EMAC:
! mac = "emac";
! break;
}
- if (mac)
- fprintf (file, " [%s]", mac);
}
fputc ('\n', file);
--- 557,615 ----
/* xgettext:c-format */
fprintf (file, _("private flags = %lx:"), elf_elfheader (abfd)->e_flags);
! if ((eflags & EF_M68K_ARCH_MASK) == EF_M68K_M68000)
fprintf (file, " [m68000]");
! else if ((eflags & EF_M68K_ARCH_MASK) == EF_M68K_CPU32)
! fprintf (file, " [cpu32]");
! else
{
! if ((eflags & EF_M68K_ARCH_MASK) == EF_M68K_CFV4E)
! fprintf (file, " [cfv4e]");
!
! if (eflags & EF_M68K_CF_ISA_MASK)
{
! char const *isa = _("unknown");
! char const *mac = _("unknown");
! char const *additional = "";
!
! switch (eflags & EF_M68K_CF_ISA_MASK)
! {
! case EF_M68K_CF_ISA_A_NODIV:
! isa = "A";
! additional = " [nodiv]";
! break;
! case EF_M68K_CF_ISA_A:
! isa = "A";
! break;
! case EF_M68K_CF_ISA_A_PLUS:
! isa = "A+";
! break;
! case EF_M68K_CF_ISA_B_NOUSP:
! isa = "B";
! additional = " [nousp]";
! break;
! case EF_M68K_CF_ISA_B:
! isa = "B";
! break;
! }
! fprintf (file, " [isa %s]%s", isa, additional);
! if (eflags & EF_M68K_CF_FLOAT)
! fprintf (file, " [float]");
! switch (eflags & EF_M68K_CF_MAC_MASK)
! {
! case 0:
! mac = NULL;
! break;
! case EF_M68K_CF_MAC:
! mac = "mac";
! break;
! case EF_M68K_CF_EMAC:
! mac = "emac";
! break;
! }
! if (mac)
! fprintf (file, " [%s]", mac);
}
}
fputc ('\n', file);
Index: binutils/readelf.c
===================================================================
RCS file: /cvs/src/src/binutils/readelf.c,v
retrieving revision 1.352
diff -c -d -p -r1.352 readelf.c
*** binutils/readelf.c 7 Dec 2006 15:39:01 -0000 1.352
--- binutils/readelf.c 7 Dec 2006 15:45:04 -0000
*************** get_machine_flags (unsigned e_flags, uns
*** 2012,2022 ****
break;
case EM_68K:
! if (e_flags & EF_M68K_CPU32)
! strcat (buf, ", cpu32");
! if (e_flags & EF_M68K_M68000)
strcat (buf, ", m68000");
! if (e_flags & EF_M68K_CF_ISA_MASK)
{
char const *isa = _("unknown");
char const *mac = _("unknown mac");
--- 2012,2022 ----
break;
case EM_68K:
! if ((e_flags & EF_M68K_ARCH_MASK) == EF_M68K_M68000)
strcat (buf, ", m68000");
! else if ((e_flags & EF_M68K_ARCH_MASK) == EF_M68K_CPU32)
! strcat (buf, ", cpu32");
! else
{
char const *isa = _("unknown");
char const *mac = _("unknown mac");
Index: include/elf/m68k.h
===================================================================
RCS file: /cvs/src/src/include/elf/m68k.h,v
retrieving revision 1.13
diff -c -d -p -r1.13 m68k.h
*** include/elf/m68k.h 7 Dec 2006 15:39:02 -0000 1.13
--- include/elf/m68k.h 7 Dec 2006 15:45:04 -0000
*************** START_RELOC_NUMBERS (elf_m68k_reloc_type
*** 52,63 ****
RELOC_NUMBER (R_68K_GNU_VTENTRY, 24)
END_RELOC_NUMBERS (R_68K_max)
#define EF_M68K_CPU32 0x00810000
#define EF_M68K_M68000 0x01000000
#define EF_M68K_CFV4E 0x00008000
/* We use the bottom 8 bits to encode information about the
! coldfire variant. */
#define EF_M68K_CF_ISA_MASK 0x0F /* Which ISA */
#define EF_M68K_CF_ISA_A_NODIV 0x01 /* ISA A except for div */
#define EF_M68K_CF_ISA_A 0x02
--- 52,67 ----
RELOC_NUMBER (R_68K_GNU_VTENTRY, 24)
END_RELOC_NUMBERS (R_68K_max)
+ /* We use the top 24 bits to encode information about the
+ architecture variant. */
#define EF_M68K_CPU32 0x00810000
#define EF_M68K_M68000 0x01000000
#define EF_M68K_CFV4E 0x00008000
+ #define EF_M68K_ARCH_MASK (EF_M68K_M68000 | EF_M68K_CPU32 | EF_M68K_CFV4E)
/* We use the bottom 8 bits to encode information about the
! coldfire variant. If we use any of these bits, the top 24 bits are
! either 0 or EF_M68K_CFV4E. */
#define EF_M68K_CF_ISA_MASK 0x0F /* Which ISA */
#define EF_M68K_CF_ISA_A_NODIV 0x01 /* ISA A except for div */
#define EF_M68K_CF_ISA_A 0x02