[PATCH] MIPS: Do not return after calling undefined_symbol hook
James Cowgill
james.cowgill@mips.com
Wed Feb 7 18:01:00 GMT 2018
Currently, when mips_elf_calculate_relocation is asked to relocate an
undefined symbol, it reports the error and immediately returns without
performing the relocation. This is fine if the link fails, but if
unresolved_syms_in_objects == RM_GENERATE_WARNING, the link will
continue and output some unrelocated code.
Fix this by continuing after calling the undefined_symbol hook.
I need someone to commit this for me.
bfd/
PR 21900
* elfxx-mips.c (mips_elf_calculate_relocation): Do not return
after calling undefined_symbol hook.
ld/
PR 21900
* testsuite/ld-mips-elf/mips-elf.exp: Run new test.
* testsuite/ld-mips-elf/undefined-warn.d: New test.
---
bfd/elfxx-mips.c | 2 +-
ld/testsuite/ld-mips-elf/mips-elf.exp | 1 +
ld/testsuite/ld-mips-elf/undefined-warn.d | 15 +++++++++++++++
3 files changed, 17 insertions(+), 1 deletion(-)
create mode 100644 ld/testsuite/ld-mips-elf/undefined-warn.d
diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
index 246d51c9cc..76e079170e 100644
--- a/bfd/elfxx-mips.c
+++ b/bfd/elfxx-mips.c
@@ -5483,7 +5483,7 @@ mips_elf_calculate_relocation (bfd *abfd, bfd *input_bfd,
input_section, relocation->r_offset,
(info->unresolved_syms_in_objects == RM_GENERATE_ERROR)
|| ELF_ST_VISIBILITY (h->root.other));
- return bfd_reloc_undefined;
+ symbol = 0;
}
target_is_16_bit_code_p = ELF_ST_IS_MIPS16 (h->root.other);
diff --git a/ld/testsuite/ld-mips-elf/mips-elf.exp b/ld/testsuite/ld-mips-elf/mips-elf.exp
index 13dbbc64f9..e6cd41ed79 100644
--- a/ld/testsuite/ld-mips-elf/mips-elf.exp
+++ b/ld/testsuite/ld-mips-elf/mips-elf.exp
@@ -994,6 +994,7 @@ if { $linux_gnu } {
}
run_dump_test "undefined"
+run_dump_test "undefined-warn"
# Test the conversion from jr to b
if { $linux_gnu } {
diff --git a/ld/testsuite/ld-mips-elf/undefined-warn.d b/ld/testsuite/ld-mips-elf/undefined-warn.d
new file mode 100644
index 0000000000..2c61aa8706
--- /dev/null
+++ b/ld/testsuite/ld-mips-elf/undefined-warn.d
@@ -0,0 +1,15 @@
+#name: MIPS undefined reference with --warn-unresolved-symbols
+#source: undefined.s
+#as: -EB -32
+#ld: -EB -e foo --warn-unresolved-symbols
+#warning: \A[^\n]*\.o: In function `foo':\n\(\.text\+0x0\): warning: undefined reference to `bar'\Z
+#objdump: -d
+
+.*: file format .*
+
+Disassembly of section \.text:
+
+.* <foo>:
+# Loaded value must not be 0
+.*: 2402.... li v0,[-1-9][0-9]*
+ \.\.\.
--
2.16.1
More information about the Binutils
mailing list