[RFA] Change bfd machine consts to enums.
Richard Earnshaw
rearnsha@arm.com
Thu Feb 14 07:03:00 GMT 2002
> >
> > Submitted for your approval: this changes the bfd_mach_* consts
> > from #defines to enums, to make it easier to debug bfd.
> >
> > Michael
> >
> > 2002-02-13 Michael Snyder <msnyder@redhat.com>
> >
> > * archures.c: Change bfd_mach_ constants to enums.
> > * bfd-in2.h: Regenerate.
>
> I'm not sure this is correct, and I certainly don't think it's portable.
>
> Consider
> + .enum bfd_mach_arm
> + .{
> + . bfd_mach_arm_2 = 1,
> + . bfd_mach_arm_2a,
> + . bfd_mach_arm_3,
> + . bfd_mach_arm_3M,
> + . bfd_mach_arm_4,
> + . bfd_mach_arm_4T,
> + . bfd_mach_arm_5,
> + . bfd_mach_arm_5T,
> + . bfd_mach_arm_5TE,
> + . bfd_mach_arm_XScale
> + .};
>
> and
>
> + .enum bfd_mach_fr30
> + .{
> + . bfd_mach_fr30 = 0x46523330
> + .};
>
> Now the first of these is used in cpu-arm.c to initialize a field that is
> of type enum bfd_architecture and the second is also used to initialize a
> similar field in cpu-fr30.c. But on a machine that uses packed enums
> these two are of different sizes. Regardless of this, it should still be
> a type error for the static initializations to be converted without a cast.
Oops, no. That's not quite right. In the fr30 case it is used to
initialize an unsigned int, so that's ok.
It's the cpu-arm.c code that's all messed up: bfd_mach_arm_... is being
used to initialize a field of type enum bfd_archticture (which should be
using bfd_arch_arm, if it gets anything).
Nick, any idea where this bit of bogosity came from?
R.
More information about the Binutils
mailing list