binutils-gdb/ld/testsuite
Jim Wilson 330a6637a5 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
2019-10-17 15:38:27 -07:00
..
config
ld-aarch64 AArch64: Fix LD crash on weak and undefined TLS symbols. (PR/24602). 2019-08-22 11:43:15 +01:00
ld-alpha
ld-arc [ARC] Add linker relaxation. 2019-07-24 16:33:29 +03:00
ld-arm ld-arm/tls-gdesc-neg test 2019-10-07 13:14:11 +10:30
ld-auto-import
ld-avr
ld-bootstrap bfd, ld: add CTF section linking 2019-10-03 17:04:56 +01:00
ld-bpf ld: use a specific linker script in BPF targets 2019-08-07 13:57:30 +02:00
ld-cdtest
ld-checks
ld-cris Dynamic TLS section symbols 2019-07-13 09:57:50 +09:30
ld-crx
ld-csky
ld-cygwin
ld-d10v
ld-discard
ld-elf Bogus "final link failed" messages 2019-10-07 13:37:23 +10:30
ld-elfcomm
ld-elfvers
ld-elfvsb Rename elf32.em to elf.em 2019-09-11 13:45:18 +09:30
ld-elfweak
ld-fastcall
ld-frv
ld-gc
ld-h8300
ld-i386 i386: Adjust for new output format from readelf 2019-09-09 09:21:36 -07:00
ld-ia64
ld-ifunc
ld-libs
ld-linkonce
ld-m68hc11
ld-m68k
ld-mep
ld-metag
ld-mips-elf Rename elf32.em to elf.em 2019-09-11 13:45:18 +09:30
ld-misc
ld-mmix
ld-mn10300
ld-msp430-elf Add support for new functionality in the msp430 backend of GCC. 2019-10-07 16:34:31 +01:00
ld-nds32
ld-nios2
ld-or1k
ld-pe
ld-pie
ld-plugin ld-plugin/pr24406-1.c: Correct buffer size to read 2019-09-23 08:51:36 -07:00
ld-powerpc PowerPC local got test 2019-10-09 00:20:19 +10:30
ld-pru
ld-riscv-elf RISC-V: Report unresolved relocation error via linker's callback function. 2019-10-17 15:38:27 -07:00
ld-s12z
ld-s390 Dynamic TLS section symbols 2019-07-13 09:57:50 +09:30
ld-scripts Rename elf32.em to elf.em 2019-09-11 13:45:18 +09:30
ld-selective
ld-sh
ld-shared Rename elf32.em to elf.em 2019-09-11 13:45:18 +09:30
ld-size
ld-sparc Dynamic TLS section symbols 2019-07-13 09:57:50 +09:30
ld-spu
ld-srec Work around gcc10 FAIL: S-records with constructors 2019-09-22 21:13:10 +09:30
ld-tic6x
ld-tilegx
ld-tilepro
ld-undefined ld: use a specific linker script in BPF targets 2019-08-07 13:57:30 +02:00
ld-unique
ld-v850
ld-vax-elf
ld-visium
ld-vxworks
ld-x86-64 x86-64: Move PIC check for PC-relative relocations back 2019-08-16 14:25:58 -07:00
ld-xc16x
ld-xstormy16
ld-xtensa
ld-z8k
lib
ChangeLog-2004
ChangeLog-2005
ChangeLog-2006
ChangeLog-2007
ChangeLog-2008
ChangeLog-2009
ChangeLog-2010
ChangeLog-2011
ChangeLog-2012
ChangeLog-2013
ChangeLog-2014
ChangeLog-2015
ChangeLog-9303