From 757a636fb585824699b1cc4f8f23dbc3a6a6d914 Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Tue, 6 May 2014 20:13:03 +0100 Subject: [PATCH] bfd/ * elfxx-mips.h (elfxx-mips.h): Declare. * elfxx-mips.c (mips_elf_merge_obj_attributes): Use it to report Tag_GNU_MIPS_ABI_FP mismatches. (_bfd_mips_fp_abi_string): New function. --- bfd/ChangeLog | 7 ++ bfd/elfxx-mips.c | 236 ++++++++++++++--------------------------------- bfd/elfxx-mips.h | 2 + 3 files changed, 77 insertions(+), 168 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index db4c6fb9d7b..902dc73f7e6 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,10 @@ +2014-05-06 Richard Sandiford + + * elfxx-mips.h (elfxx-mips.h): Declare. + * elfxx-mips.c (mips_elf_merge_obj_attributes): Use it to report + Tag_GNU_MIPS_ABI_FP mismatches. + (_bfd_mips_fp_abi_string): New function. + 2014-05-02 Alan Modra * targets.c: Sort bfd_target vectors somewhat alphabetically. diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c index d939444c1ab..f8c1e64df1f 100644 --- a/bfd/elfxx-mips.c +++ b/bfd/elfxx-mips.c @@ -14364,176 +14364,49 @@ mips_elf_merge_obj_attributes (bfd *ibfd, bfd *obfd) out_attr = elf_known_obj_attributes (obfd)[OBJ_ATTR_GNU]; if (in_attr[Tag_GNU_MIPS_ABI_FP].i != out_attr[Tag_GNU_MIPS_ABI_FP].i) { - out_attr[Tag_GNU_MIPS_ABI_FP].type = 1; - if (out_attr[Tag_GNU_MIPS_ABI_FP].i == Val_GNU_MIPS_ABI_FP_ANY) - out_attr[Tag_GNU_MIPS_ABI_FP].i = in_attr[Tag_GNU_MIPS_ABI_FP].i; - else if (in_attr[Tag_GNU_MIPS_ABI_FP].i != Val_GNU_MIPS_ABI_FP_ANY) - switch (out_attr[Tag_GNU_MIPS_ABI_FP].i) - { - case Val_GNU_MIPS_ABI_FP_DOUBLE: - switch (in_attr[Tag_GNU_MIPS_ABI_FP].i) - { - case Val_GNU_MIPS_ABI_FP_SINGLE: - _bfd_error_handler - (_("Warning: %B uses %s (set by %B), %B uses %s"), - obfd, abi_fp_bfd, ibfd, "-mdouble-float", "-msingle-float"); - break; - - case Val_GNU_MIPS_ABI_FP_SOFT: - _bfd_error_handler - (_("Warning: %B uses %s (set by %B), %B uses %s"), - obfd, abi_fp_bfd, ibfd, "-mhard-float", "-msoft-float"); - break; - - case Val_GNU_MIPS_ABI_FP_64: - _bfd_error_handler - (_("Warning: %B uses %s (set by %B), %B uses %s"), - obfd, abi_fp_bfd, ibfd, - "-mdouble-float", "-mips32r2 -mfp64"); - break; - - default: - _bfd_error_handler - (_("Warning: %B uses %s (set by %B), " - "%B uses unknown floating point ABI %d"), - obfd, abi_fp_bfd, ibfd, - "-mdouble-float", in_attr[Tag_GNU_MIPS_ABI_FP].i); - break; - } - break; - - case Val_GNU_MIPS_ABI_FP_SINGLE: - switch (in_attr[Tag_GNU_MIPS_ABI_FP].i) - { - case Val_GNU_MIPS_ABI_FP_DOUBLE: - _bfd_error_handler - (_("Warning: %B uses %s (set by %B), %B uses %s"), - obfd, abi_fp_bfd, ibfd, "-msingle-float", "-mdouble-float"); - break; - - case Val_GNU_MIPS_ABI_FP_SOFT: - _bfd_error_handler - (_("Warning: %B uses %s (set by %B), %B uses %s"), - obfd, abi_fp_bfd, ibfd, "-mhard-float", "-msoft-float"); - break; - - case Val_GNU_MIPS_ABI_FP_64: - _bfd_error_handler - (_("Warning: %B uses %s (set by %B), %B uses %s"), - obfd, abi_fp_bfd, ibfd, - "-msingle-float", "-mips32r2 -mfp64"); - break; - - default: - _bfd_error_handler - (_("Warning: %B uses %s (set by %B), " - "%B uses unknown floating point ABI %d"), - obfd, abi_fp_bfd, ibfd, - "-msingle-float", in_attr[Tag_GNU_MIPS_ABI_FP].i); - break; - } - break; - - case Val_GNU_MIPS_ABI_FP_SOFT: - switch (in_attr[Tag_GNU_MIPS_ABI_FP].i) - { - case Val_GNU_MIPS_ABI_FP_DOUBLE: - case Val_GNU_MIPS_ABI_FP_SINGLE: - case Val_GNU_MIPS_ABI_FP_64: - _bfd_error_handler - (_("Warning: %B uses %s (set by %B), %B uses %s"), - obfd, abi_fp_bfd, ibfd, "-msoft-float", "-mhard-float"); - break; - - default: - _bfd_error_handler - (_("Warning: %B uses %s (set by %B), " - "%B uses unknown floating point ABI %d"), - obfd, abi_fp_bfd, ibfd, - "-msoft-float", in_attr[Tag_GNU_MIPS_ABI_FP].i); - break; - } - break; - - case Val_GNU_MIPS_ABI_FP_64: - switch (in_attr[Tag_GNU_MIPS_ABI_FP].i) - { - case Val_GNU_MIPS_ABI_FP_DOUBLE: - _bfd_error_handler - (_("Warning: %B uses %s (set by %B), %B uses %s"), - obfd, abi_fp_bfd, ibfd, - "-mips32r2 -mfp64", "-mdouble-float"); - break; - - case Val_GNU_MIPS_ABI_FP_SINGLE: - _bfd_error_handler - (_("Warning: %B uses %s (set by %B), %B uses %s"), - obfd, abi_fp_bfd, ibfd, - "-mips32r2 -mfp64", "-msingle-float"); - break; - - case Val_GNU_MIPS_ABI_FP_SOFT: - _bfd_error_handler - (_("Warning: %B uses %s (set by %B), %B uses %s"), - obfd, abi_fp_bfd, ibfd, "-mhard-float", "-msoft-float"); - break; - - default: - _bfd_error_handler - (_("Warning: %B uses %s (set by %B), " - "%B uses unknown floating point ABI %d"), - obfd, abi_fp_bfd, ibfd, - "-mips32r2 -mfp64", in_attr[Tag_GNU_MIPS_ABI_FP].i); - break; - } - break; - - default: - switch (in_attr[Tag_GNU_MIPS_ABI_FP].i) - { - case Val_GNU_MIPS_ABI_FP_DOUBLE: - _bfd_error_handler - (_("Warning: %B uses unknown floating point ABI %d " - "(set by %B), %B uses %s"), - obfd, abi_fp_bfd, ibfd, - out_attr[Tag_GNU_MIPS_ABI_FP].i, "-mdouble-float"); - break; + int out_fp, in_fp; - case Val_GNU_MIPS_ABI_FP_SINGLE: - _bfd_error_handler - (_("Warning: %B uses unknown floating point ABI %d " - "(set by %B), %B uses %s"), - obfd, abi_fp_bfd, ibfd, - out_attr[Tag_GNU_MIPS_ABI_FP].i, "-msingle-float"); - break; - - case Val_GNU_MIPS_ABI_FP_SOFT: - _bfd_error_handler - (_("Warning: %B uses unknown floating point ABI %d " - "(set by %B), %B uses %s"), - obfd, abi_fp_bfd, ibfd, - out_attr[Tag_GNU_MIPS_ABI_FP].i, "-msoft-float"); - break; - - case Val_GNU_MIPS_ABI_FP_64: - _bfd_error_handler - (_("Warning: %B uses unknown floating point ABI %d " - "(set by %B), %B uses %s"), - obfd, abi_fp_bfd, ibfd, - out_attr[Tag_GNU_MIPS_ABI_FP].i, "-mips32r2 -mfp64"); - break; + out_fp = out_attr[Tag_GNU_MIPS_ABI_FP].i; + in_fp = in_attr[Tag_GNU_MIPS_ABI_FP].i; + out_attr[Tag_GNU_MIPS_ABI_FP].type = 1; + if (out_fp == Val_GNU_MIPS_ABI_FP_ANY) + out_attr[Tag_GNU_MIPS_ABI_FP].i = in_fp; + else if (in_fp != Val_GNU_MIPS_ABI_FP_ANY) + { + const char *out_string, *in_string; - default: - _bfd_error_handler - (_("Warning: %B uses unknown floating point ABI %d " - "(set by %B), %B uses unknown floating point ABI %d"), - obfd, abi_fp_bfd, ibfd, - out_attr[Tag_GNU_MIPS_ABI_FP].i, - in_attr[Tag_GNU_MIPS_ABI_FP].i); - break; - } - break; - } + out_string = _bfd_mips_fp_abi_string (out_fp); + in_string = _bfd_mips_fp_abi_string (in_fp); + /* First warn about cases involving unrecognised ABIs. */ + if (!out_string && !in_string) + _bfd_error_handler + (_("Warning: %B uses unknown floating point ABI %d " + "(set by %B), %B uses unknown floating point ABI %d"), + obfd, abi_fp_bfd, ibfd, out_fp, in_fp); + else if (!out_string) + _bfd_error_handler + (_("Warning: %B uses unknown floating point ABI %d " + "(set by %B), %B uses %s"), + obfd, abi_fp_bfd, ibfd, out_fp, in_string); + else if (!in_string) + _bfd_error_handler + (_("Warning: %B uses %s (set by %B), " + "%B uses unknown floating point ABI %d"), + obfd, abi_fp_bfd, ibfd, out_string, in_fp); + else + { + /* If one of the bfds is soft-float, the other must be + hard-float. The exact choice of hard-float ABI isn't + really relevant to the error message. */ + if (in_fp == Val_GNU_MIPS_ABI_FP_SOFT) + out_string = "-mhard-float"; + else if (out_fp == Val_GNU_MIPS_ABI_FP_SOFT) + in_string = "-mhard-float"; + _bfd_error_handler + (_("Warning: %B uses %s (set by %B), %B uses %s"), + obfd, abi_fp_bfd, ibfd, out_string, in_string); + } + } } /* Check for conflicting Tag_GNU_MIPS_ABI_MSA attributes and merge @@ -14944,6 +14817,33 @@ _bfd_mips_elf_get_target_dtag (bfd_vma dtag) } } +/* Return the meaning of Tag_GNU_MIPS_ABI_FP value FP, or null if + not known. */ + +const char * +_bfd_mips_fp_abi_string (int fp) +{ + switch (fp) + { + /* These strings aren't translated because they're simply + option lists. */ + case Val_GNU_MIPS_ABI_FP_DOUBLE: + return "-mdouble-float"; + + case Val_GNU_MIPS_ABI_FP_SINGLE: + return "-msingle-float"; + + case Val_GNU_MIPS_ABI_FP_SOFT: + return "-msoft-float"; + + case Val_GNU_MIPS_ABI_FP_64: + return "-mips32r2 -mfp64"; + + default: + return 0; + } +} + bfd_boolean _bfd_mips_elf_print_private_bfd_data (bfd *abfd, void *ptr) { diff --git a/bfd/elfxx-mips.h b/bfd/elfxx-mips.h index e6ec6730f6a..95b98ac1c62 100644 --- a/bfd/elfxx-mips.h +++ b/bfd/elfxx-mips.h @@ -108,6 +108,8 @@ extern bfd_boolean _bfd_mips_elf_merge_private_bfd_data (bfd *, bfd *); extern bfd_boolean _bfd_mips_elf_set_private_flags (bfd *, flagword); +extern const char * _bfd_mips_fp_abi_string + (int); extern bfd_boolean _bfd_mips_elf_print_private_bfd_data (bfd *, void *); extern bfd_boolean _bfd_mips_elf_discard_info -- 2.30.2