binutils-gdb/ld/testsuite
Jozef Lawrynowicz 7d81bc937c MSP430: Support relocations for subtract expressions in .uleb128 directives
Link-time relaxations of branches are common for MSP430, given that GCC
can generate pessimal branch instructions, and the
-mcode-region=either/-mdata-region=either options to shuffle sections
can further change the type of branch instruction required.

These relaxations can result in invalid code when .uleb128
directives, used in the .gcc_except_table section, are used to calculate
the distance between two labels. A value for the .uleb128 directive is
calculated at assembly-time, and can't be updated at link-time, even if
relaxation causes the distance between the labels to change.

This patch adds relocations for subtract expressions in .uleb128
directives, to allow the linker to re-calculate the value of these
expressions after relaxation has been performed.

bfd/ChangeLog:
	* bfd-in2.h (bfd_reloc_code_real): Add
	BFD_RELOC_MSP430_{SET,SUB}_ULEB128.
	* elf32-msp430.c (msp430_elf_ignore_reloc): New.
	(elf_msp430_howto_table): Add R_MSP430{,X}_GNU_{SET,SUB}_ULEB128.
	(msp430_reloc_map): Add R_MSP430_GNU_{SET,SUB}_ULEB128.
	(msp430x_reloc_map): Add R_MSP430X_GNU_{SET,SUB}_ULEB128.
	(write_uleb128): New.
	(msp430_final_link_relocate): Handle R_MSP430{,X}_GNU_{SET,SUB}_ULEB128.
	* libbfd.c (_bfd_write_unsigned_leb128): New.
	* libbfd.h (_bfd_write_unsigned_leb128): New prototype.
	Add BFD_RELOC_MSP430_{SET,SUB}_ULEB128.
	* reloc.c: Document BFD_RELOC_MSP430_{SET,SUB}_ULEB128.

binutils/ChangeLog:
	* readelf.c (target_specific_reloc_handling): Handle
	R_MSP430{,X}_GNU_{SET,SUB}_ULEB128.

gas/ChangeLog:
	* config/tc-msp430.c (msp430_insert_uleb128_fixes): New.
	(msp430_md_end): Call msp430_insert_uleb128_fixes.

include/ChangeLog:
	* elf/msp430.h (elf_msp430_reloc_type): Add
	R_MSP430_GNU_{SET,SUB}_ULEB128.
	(elf_msp430x_reloc_type): Add R_MSP430X_GNU_{SET,SUB}_ULEB128.

ld/ChangeLog:
	* testsuite/ld-msp430-elf/msp430-elf.exp: Run new tests.
	* testsuite/ld-msp430-elf/uleb128.s: New test.
	* testsuite/ld-msp430-elf/uleb128_430.d: New test.
	* testsuite/ld-msp430-elf/uleb128_430x.d: New test.
2020-09-08 16:18:38 +01:00
..
config ld: Change NOSANTIZE_CFLAGS to NOSANITIZE_CFLAGS 2020-09-03 17:17:19 -07:00
ld-aarch64
ld-alpha Remove commit 9fb2400ce6 2020-08-27 13:52:45 +01:00
ld-arc
ld-arm AArch64: Relax thumb-plt testcases regexpr. 2020-08-14 07:52:00 +01:00
ld-auto-import
ld-avr
ld-bootstrap
ld-bpf bpf: add missing tests from previous commits 2020-08-07 20:40:01 +02:00
ld-cdtest
ld-checks
ld-cris
ld-crx
ld-csky CSKY: Support attribute section. 2020-08-28 17:23:24 +08:00
ld-ctf binutils, ld: dequote libctf error messages 2020-08-27 13:16:39 +01:00
ld-cygwin
ld-d10v
ld-discard
ld-dynamic
ld-elf PR26580, Size and alignment of commons vs as-needed shared lib 2020-09-08 22:30:38 +09:30
ld-elfcomm ld: Change NOSANTIZE_CFLAGS to NOSANITIZE_CFLAGS 2020-09-03 17:17:19 -07:00
ld-elfvers ld: Change NOSANTIZE_CFLAGS to NOSANITIZE_CFLAGS 2020-09-03 17:17:19 -07:00
ld-elfvsb ld: Change NOSANTIZE_CFLAGS to NOSANITIZE_CFLAGS 2020-09-03 17:17:19 -07:00
ld-elfweak ld: Change NOSANTIZE_CFLAGS to NOSANITIZE_CFLAGS 2020-09-03 17:17:19 -07:00
ld-fastcall
ld-frv
ld-gc ld: Change NOSANTIZE_CFLAGS to NOSANITIZE_CFLAGS 2020-09-03 17:17:19 -07:00
ld-h8300
ld-i386
ld-ia64
ld-ifunc ld: Add -fno-lto to linker tests 2020-07-31 07:57:04 -07:00
ld-libs tic54x ld testsuite 2020-08-25 19:31:57 +09:30
ld-linkonce
ld-m68hc11
ld-m68k
ld-mep
ld-metag
ld-mips-elf MIPS: Make the IRIX naming of local section symbols consistent 2020-07-29 20:56:41 +01:00
ld-misc More just-syms changes 2020-07-28 13:09:20 +09:30
ld-mmix
ld-mn10300
ld-msp430-elf MSP430: Support relocations for subtract expressions in .uleb128 directives 2020-09-08 16:18:38 +01:00
ld-nds32
ld-nios2
ld-or1k
ld-pdp11
ld-pe Change the default characteristics of DLLs built by the linker to more secure settings. 2020-08-27 12:58:27 +01:00
ld-pie
ld-plugin Allow plugin syms to mark as-needed shared libs needed 2020-09-04 14:06:44 +09:30
ld-powerpc PowerPC TPREL_HA/LO optimisation 2020-08-24 21:15:06 +09:30
ld-pru
ld-riscv-elf RISC-V: Minor cleanup and typos when merging elf attributes. 2020-09-03 11:12:02 +08:00
ld-s12z
ld-s390
ld-scripts ld: Change NOSANTIZE_CFLAGS to NOSANITIZE_CFLAGS 2020-09-03 17:17:19 -07:00
ld-selective ld: Change NOSANTIZE_CFLAGS to NOSANITIZE_CFLAGS 2020-09-03 17:17:19 -07:00
ld-sh
ld-shared ld: Change NOSANTIZE_CFLAGS to NOSANITIZE_CFLAGS 2020-09-03 17:17:19 -07:00
ld-size ld: Change NOSANTIZE_CFLAGS to NOSANITIZE_CFLAGS 2020-09-03 17:17:19 -07:00
ld-sparc sparc testsuite fallout 2020-08-24 21:48:16 +09:30
ld-spu
ld-srec ld: Change NOSANTIZE_CFLAGS to NOSANITIZE_CFLAGS 2020-09-03 17:17:19 -07:00
ld-tic6x
ld-tilegx
ld-tilepro
ld-undefined
ld-unique
ld-v850
ld-vax-elf
ld-visium
ld-vxworks
ld-x86-64 ld: Change NOSANTIZE_CFLAGS to NOSANITIZE_CFLAGS 2020-09-03 17:17:19 -07:00
ld-xc16x
ld-xstormy16
ld-xtensa
ld-z8k
ld-z80
lib Fixes for testsuite failures introduced by the changes made for PR 19011. 2020-08-28 09:43:13 +01:00
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