aboutsummaryrefslogtreecommitdiff
path: root/gdb/elfread.c
diff options
context:
space:
mode:
authorJim Wilson <jimw@sifive.com>2019-10-17 15:38:27 -0700
committerJim Wilson <jimw@sifive.com>2019-10-17 15:38:27 -0700
commit330a6637a53d4b6694c9f8fa04155d4366453621 (patch)
tree160e5582b61fedb210bda098844ebc0a45b0c2ec /gdb/elfread.c
parentc5adaa1921c34d2b9711ec7cecd3cb4a253620db (diff)
downloadgdb-330a6637a53d4b6694c9f8fa04155d4366453621.zip
gdb-330a6637a53d4b6694c9f8fa04155d4366453621.tar.gz
gdb-330a6637a53d4b6694c9f8fa04155d4366453621.tar.bz2
RISC-V: Report unresolved relocation error via linker's callback function.
Two patches from Nelson Chu. It is better to use the linker's callback functions to handle the link time error when relocating. The unresolved relocation error can be regarded as an unsupported relocation. To make user easier to understand different errors, we need to extend the current error message format of the callback function since the format is fixed. bfd/ * elfnn-riscv.c (riscv_elf_relocate_section): Use asprintf to extend the error message if needed, and then store the result into the `msg_buf`. Finally, remember to free the unused `msg_buf`. All error message for the dangerous relocation should be set before we call the callback function. If we miss the error message since linker runs out of memory, we should set the default error message for the error. ld/ * testsuite/ld-riscv-elf/lib-nopic-01a.s: Create the shared library lib-nopic-01a.so, it will be linked with lib-nopic-01b.s. * testsuite/ld-riscv-elf/lib-nopic-01b.s: Add new test for the unresolved relocation. Link the non-pic code into a shared library may cause the error. * testsuite/ld-riscv-elf/lib-nopic-01b.d: Likewise. * testsuite/ld-riscv-elf/ld-riscv-elf.exp: Run the new test only when the shared library is supported. R_RISCV_CALL, R_RISCV_JAL and R_RISCV_RVC_JUMP are pc-relative relocation. For now, we do not allow the object with these relocation links into a shared library since the referenced symbols may be loaded to the places that too far from the pc. We can improve the error message for these unsupported relocation to notice user that they should recompile their code with `fPIC`. bfd/ * elfnn-riscv.c (riscv_elf_relocate_section): Report the error message that user should recompile their code with `fPIC` when linking non-pic code into shared library. ld/ * testsuite/ld-riscv-elf/lib-nopic-01b.d: Update the error message. Change-Id: Ib3347a0a6fa1c2b20a9647c314d5bec2c322ff04
Diffstat (limited to 'gdb/elfread.c')
0 files changed, 0 insertions, 0 deletions