This is the mail archive of the
binutils-cvs@sourceware.org
mailing list for the binutils project.
[binutils-gdb] MIPS/opcodes: Only call `bfd_mips_elf_get_abiflags' if BFD64
- From: Maciej W.Rozycki <macro at sourceware dot org>
- To: bfd-cvs at sourceware dot org
- Date: 19 Dec 2016 11:41:38 -0000
- Subject: [binutils-gdb] MIPS/opcodes: Only call `bfd_mips_elf_get_abiflags' if BFD64
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=4df995c77118d07c12fb260dbba0ca2b281324f1
commit 4df995c77118d07c12fb260dbba0ca2b281324f1
Author: Maciej W. Rozycki <macro@imgtec.com>
Date: Mon Dec 19 11:32:05 2016 +0000
MIPS/opcodes: Only call `bfd_mips_elf_get_abiflags' if BFD64
Complement commit 5e7fc731f80e ("MIPS/opcodes: Also set disassembler's
ASE flags from ELF structures") and fix an `--enable-targets=all' GDB
build regression on 32-bit hosts where the MIPS target is a secondary:
../opcodes/libopcodes.a(mips-dis.o): In function `set_default_mips_dis_options':
mips-dis.c:(.text+0x906): undefined reference to `bfd_mips_elf_get_abiflags'
collect2: error: ld returned 1 exit status
make[2]: *** [gdb] Error 1
by avoiding making a call to the `bfd_mips_elf_get_abiflags' function,
which is not available, because there is no MIPS/ELF BFD included in
32-bit BFD builds. This call is only made from a conditional code block
guarded by a check against `bfd_target_elf_flavour', which is dead in
such a configuration, however cannot be optimized away by the compiler.
Also some other MIPS BFDs may be available, such as a.out, ECOFF or PE,
so the disassembler has to remain functional.
opcodes/
* mips-dis.c (set_default_mips_dis_options) [BFD64]: Only call
`bfd_mips_elf_get_abiflags' here.
Diff:
---
opcodes/ChangeLog | 5 +++++
opcodes/mips-dis.c | 11 +++++++++--
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog
index d247bac..2618f90 100644
--- a/opcodes/ChangeLog
+++ b/opcodes/ChangeLog
@@ -1,3 +1,8 @@
+2016-12-19 Maciej W. Rozycki <macro@imgtec.com>
+
+ * mips-dis.c (set_default_mips_dis_options) [BFD64]: Only call
+ `bfd_mips_elf_get_abiflags' here.
+
2016-12-16 Nick Clifton <nickc@redhat.com>
* arm-dis.c (print_insn_thumb32): Fix compile time warning
diff --git a/opcodes/mips-dis.c b/opcodes/mips-dis.c
index c30bbd0..cd9893e 100644
--- a/opcodes/mips-dis.c
+++ b/opcodes/mips-dis.c
@@ -846,8 +846,15 @@ set_default_mips_dis_options (struct disassemble_info *info)
{
struct bfd *abfd = info->section->owner;
Elf_Internal_Ehdr *header = elf_elfheader (abfd);
- Elf_Internal_ABIFlags_v0 *abiflags = bfd_mips_elf_get_abiflags (abfd);
-
+ Elf_Internal_ABIFlags_v0 *abiflags = NULL;
+
+ /* We won't ever get here if !BFD64, because we won't then have
+ a MIPS/ELF BFD, however we need to guard against a link error
+ in a `--enable-targets=...' configuration with a 32-bit host,
+ where the MIPS target is a secondary. */
+#ifdef BFD64
+ abiflags = bfd_mips_elf_get_abiflags (abfd);
+#endif
/* If an ELF "newabi" binary, use the n32/(n)64 GPR names. */
if (is_newabi (header))
mips_gpr_names = mips_gpr_names_newabi;