Currently, when `mips_elf_calculate_relocation' is asked to relocate an
undefined symbol, it reports an error or a warning 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, which is a
regression from commit
e7e2196da3f0 ("MIPS/BFD: Correctly report
undefined relocations").
Fix this by continuing after calling the `undefined_symbol' hook unless
this is an error condition.
bfd/
PR ld/21900
* elfxx-mips.c (mips_elf_calculate_relocation): Only return
after calling `undefined_symbol' hook if this is an error
condition. Assume the value of 0 for the symbol requested
otherwise.
ld/
PR ld/21900
* testsuite/ld-mips-elf/undefined-warn.d: New test.
* testsuite/ld-mips-elf/undefined.s: Add padding at the end.
* testsuite/ld-mips-elf/mips-elf.exp: Run the new test.
+2018-03-03 James Cowgill <james.cowgill@mips.com>
+ Maciej W. Rozycki <macro@mips.com>
+
+ PR ld/21900
+ * elfxx-mips.c (mips_elf_calculate_relocation): Only return
+ after calling `undefined_symbol' hook if this is an error
+ condition. Assume the value of 0 for the symbol requested
+ otherwise.
+
2018-03-02 Jim Wilson <jimw@sifive.com>
PR 22903
}
else
{
+ bfd_boolean reject_undefined
+ = (info->unresolved_syms_in_objects == RM_GENERATE_ERROR
+ || ELF_ST_VISIBILITY (h->root.other) != STV_DEFAULT);
+
(*info->callbacks->undefined_symbol)
(info, h->root.root.root.string, 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;
+ input_section, relocation->r_offset, reject_undefined);
+
+ if (reject_undefined)
+ return bfd_reloc_undefined;
+
+ symbol = 0;
}
target_is_16_bit_code_p = ELF_ST_IS_MIPS16 (h->root.other);
+2018-03-03 James Cowgill <james.cowgill@mips.com>
+ Maciej W. Rozycki <macro@mips.com>
+
+ PR ld/21900
+ * testsuite/ld-mips-elf/undefined-warn.d: New test.
+ * testsuite/ld-mips-elf/undefined.s: Add padding at the end.
+ * testsuite/ld-mips-elf/mips-elf.exp: Run the new test.
+
2018-03-02 Jim Wilson <jimw@sifive.com>
PR 22903
}
run_dump_test "undefined"
+run_dump_test "undefined-warn"
# Test the conversion from jr to b
if { $linux_gnu } {
--- /dev/null
+#objdump: -d --prefix-addresses --show-raw-insn
+#name: MIPS undefined reference with --warn-unresolved-symbols
+#source: undefined.s
+#ld: -e foo --warn-unresolved-symbols
+#warning: \A[^\n]*\.o: in function `foo':\n\(\.text\+0x0\): warning: undefined reference to `bar'\Z
+
+.*: file format .*
+
+Disassembly of section \.text:
+
+# Loaded value must not be 0.
+[0-9a-f]+ <[^>]*> 2402.... li v0,[-1-9][0-9]*
+ \.\.\.
li $2, %got_page(bar)
.end foo
.size foo, . - foo
+
+# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
+ .align 4, 0
+ .space 16