diff options
author | James Cowgill <james.cowgill@mips.com> | 2018-03-03 15:49:21 +0000 |
---|---|---|
committer | Maciej W. Rozycki <macro@mips.com> | 2018-03-03 15:49:21 +0000 |
commit | dfb93f11587ca08b820c7c785278366f2505cfd1 (patch) | |
tree | 19952490ddd453f8fb532d608c92012da84b0c18 /ld/testsuite | |
parent | b9671caf8fe1abd737846edf7dcd627870f986cc (diff) | |
download | gdb-dfb93f11587ca08b820c7c785278366f2505cfd1.zip gdb-dfb93f11587ca08b820c7c785278366f2505cfd1.tar.gz gdb-dfb93f11587ca08b820c7c785278366f2505cfd1.tar.bz2 |
PR ld/21900: MIPS: Fix relocation processing with undefined symbols
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.
Diffstat (limited to 'ld/testsuite')
-rw-r--r-- | ld/testsuite/ld-mips-elf/mips-elf.exp | 1 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/undefined-warn.d | 13 | ||||
-rw-r--r-- | ld/testsuite/ld-mips-elf/undefined.s | 4 |
3 files changed, 18 insertions, 0 deletions
diff --git a/ld/testsuite/ld-mips-elf/mips-elf.exp b/ld/testsuite/ld-mips-elf/mips-elf.exp index 144b007..95d677e 100644 --- a/ld/testsuite/ld-mips-elf/mips-elf.exp +++ b/ld/testsuite/ld-mips-elf/mips-elf.exp @@ -995,6 +995,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 0000000..b43018e --- /dev/null +++ b/ld/testsuite/ld-mips-elf/undefined-warn.d @@ -0,0 +1,13 @@ +#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]* + \.\.\. diff --git a/ld/testsuite/ld-mips-elf/undefined.s b/ld/testsuite/ld-mips-elf/undefined.s index d946a5a..98f46de 100644 --- a/ld/testsuite/ld-mips-elf/undefined.s +++ b/ld/testsuite/ld-mips-elf/undefined.s @@ -22,3 +22,7 @@ foo: 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 |