diff options
author | Jozef Lawrynowicz <jozef.l@mittosystems.com> | 2020-09-08 16:13:48 +0100 |
---|---|---|
committer | Jozef Lawrynowicz <jozef.l@mittosystems.com> | 2020-09-08 16:18:38 +0100 |
commit | 7d81bc937cd3949fc3bed8194646d3a4563f94b2 (patch) | |
tree | 6d1300169968fa3dae4c85e0c633f27ed61cb5ca /include | |
parent | f1363b0fb4eb8bbe9ef08f1e78ff6ffa71e07b8b (diff) | |
download | gdb-7d81bc937cd3949fc3bed8194646d3a4563f94b2.zip gdb-7d81bc937cd3949fc3bed8194646d3a4563f94b2.tar.gz gdb-7d81bc937cd3949fc3bed8194646d3a4563f94b2.tar.bz2 |
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.
Diffstat (limited to 'include')
-rw-r--r-- | include/ChangeLog | 7 | ||||
-rw-r--r-- | include/elf/msp430.h | 4 |
2 files changed, 11 insertions, 0 deletions
diff --git a/include/ChangeLog b/include/ChangeLog index eff8116..6017c8b 100644 --- a/include/ChangeLog +++ b/include/ChangeLog @@ -1,3 +1,10 @@ +2020-09-08 Jozef Lawrynowicz <jozef.l@mittosystems.com> + Kuan-Lin Chen <kuanlinchentw@gmail.com> + + * 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. + 2020-09-08 Alex Coplan <alex.coplan@arm.com> * opcode/aarch64.h (aarch64_sys_ins_reg_supported_p): Also take diff --git a/include/elf/msp430.h b/include/elf/msp430.h index 536f714..8d047cd 100644 --- a/include/elf/msp430.h +++ b/include/elf/msp430.h @@ -113,6 +113,8 @@ START_RELOC_NUMBERS (elf_msp430_reloc_type) RELOC_NUMBER (R_MSP430_RL_PCREL, 8) RELOC_NUMBER (R_MSP430_8, 9) RELOC_NUMBER (R_MSP430_SYM_DIFF, 10) + RELOC_NUMBER (R_MSP430_GNU_SET_ULEB128, 11) /* GNU only. */ + RELOC_NUMBER (R_MSP430_GNU_SUB_ULEB128, 12) /* GNU only. */ END_RELOC_NUMBERS (R_MSP430_max) START_RELOC_NUMBERS (elf_msp430x_reloc_type) @@ -137,6 +139,8 @@ START_RELOC_NUMBERS (elf_msp430x_reloc_type) RELOC_NUMBER (R_MSP430X_10_PCREL, 19) /* Red Hat invention. Used for Jump instructions. */ RELOC_NUMBER (R_MSP430X_2X_PCREL, 20) /* Red Hat invention. Used for relaxing jumps. */ RELOC_NUMBER (R_MSP430X_SYM_DIFF, 21) /* Red Hat invention. Used for relaxing debug info. */ + RELOC_NUMBER (R_MSP430X_GNU_SET_ULEB128, 22) /* GNU only. */ + RELOC_NUMBER (R_MSP430X_GNU_SUB_ULEB128, 23) /* GNU only. */ END_RELOC_NUMBERS (R_MSP430x_max) #endif /* _ELF_MSP430_H */ |