diff options
author | Max Filippov <jcmvbkbc@gmail.com> | 2020-05-10 08:03:08 -0700 |
---|---|---|
committer | Max Filippov <jcmvbkbc@gmail.com> | 2020-06-15 13:01:30 -0700 |
commit | 7a77f1ac2c6f899faa39e8c0b42d4284d586c44e (patch) | |
tree | a62d6ddd84a685332322b873f7b2cd4facdc3601 /bfd/elf32-xtensa.c | |
parent | cae64165f47b64898c4f1982d294862cfae89a47 (diff) | |
download | gdb-7a77f1ac2c6f899faa39e8c0b42d4284d586c44e.zip gdb-7a77f1ac2c6f899faa39e8c0b42d4284d586c44e.tar.gz gdb-7a77f1ac2c6f899faa39e8c0b42d4284d586c44e.tar.bz2 |
xtensa: allow runtime ABI selection
2020-06-15 Max Filippov <jcmvbkbc@gmail.com>
bfd/
* elf32-xtensa.c (XSHAL_ABI, XTHAL_ABI_UNDEFINED)
(XTHAL_ABI_WINDOWED, XTHAL_ABI_CALL0): New macros.
(elf32xtensa_abi): New global variable.
(xtensa_abi_choice): New function.
(elf_xtensa_create_plt_entry): Use xtensa_abi_choice instead of
XSHAL_ABI to select PLT code.
gas/
* config/tc-xtensa.c (XTHAL_ABI_WINDOWED, XTHAL_ABI_CALL0): New
macros.
(elf32xtensa_abi): New declaration.
(option_abi_windowed, option_abi_call0): New enum constants.
(md_longopts): Add entries for --abi-windowed and --abi-call0.
(md_parse_option): Add handlers for --abi-windowed and
--abi-call0.
(xtensa_add_config_info): Use xtensa_abi_choice instead of
XSHAL_ABI to format ABI tag.
* doc/as.texi (Target Xtensa options): Add --abi-windowed and
--abi-call0 to the list of options.
* doc/c-xtensa.texi: Add description for options --abi-windowed
and --abi-call0.
* testsuite/gas/xtensa/abi-call0.d: New test definition.
* testsuite/gas/xtensa/abi-windowed.d: New test definition.
* testsuite/gas/xtensa/abi.s: New test source.
include/
* elf/xtensa.h (xtensa_abi_choice): New declaration.
ld/
* emultempl/xtensaelf.em (XSHAL_ABI): Remove macro definition.
(XTHAL_ABI_UNDEFINED, XTHAL_ABI_WINDOWED, XTHAL_ABI_CALL0): New
macros.
(elf32xtensa_abi): New declaration.
(xt_config_info_unpack_and_check): Set elf32xtensa_abi if it is
undefined. Use xtensa_abi_choice instead of XSHAL_ABI to test
ABI tag consistency.
(xtensa_add_config_info): Use xtensa_abi_choice instead of
XSHAL_ABI to format ABI tag.
(PARSE_AND_LIST_PROLOGUE): Define OPTION_ABI_WINDOWED,
OPTION_ABI_CALL0 and declare elf32xtensa_abi.
(PARSE_AND_LIST_LONGOPTS): Add entries for --abi-windowed and
--abi-call0.
(PARSE_AND_LIST_OPTIONS): Add help text for --abi-windowed and
--abi-call0.
(PARSE_AND_LIST_ARGS_CASES): Add handlers for --abi-windowed and
--abi-call0.
* ld.texi: Add description for options --abi-windowed and
--abi-call0.
Diffstat (limited to 'bfd/elf32-xtensa.c')
-rw-r--r-- | bfd/elf32-xtensa.c | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c index 9dc815e..b223424 100644 --- a/bfd/elf32-xtensa.c +++ b/bfd/elf32-xtensa.c @@ -37,6 +37,22 @@ #define XTENSA_NO_NOP_REMOVAL 0 +#ifndef XSHAL_ABI +#define XSHAL_ABI 0 +#endif + +#ifndef XTHAL_ABI_UNDEFINED +#define XTHAL_ABI_UNDEFINED -1 +#endif + +#ifndef XTHAL_ABI_WINDOWED +#define XTHAL_ABI_WINDOWED 0 +#endif + +#ifndef XTHAL_ABI_CALL0 +#define XTHAL_ABI_CALL0 1 +#endif + /* Local helper functions. */ static bfd_boolean add_extra_plt_sections (struct bfd_link_info *, int); @@ -164,6 +180,10 @@ int elf32xtensa_no_literal_movement = 1; bfd_boolean elf32xtensa_separate_props = FALSE; +/* Xtensa ABI. It affects PLT entry code. */ + +int elf32xtensa_abi = XTHAL_ABI_UNDEFINED; + /* Rename one of the generic section flags to better document how it is used here. */ /* Whether relocations have been processed. */ @@ -2247,6 +2267,13 @@ bfd_elf_xtensa_reloc (bfd *abfd, return flag; } +int xtensa_abi_choice (void) +{ + if (elf32xtensa_abi == XTHAL_ABI_UNDEFINED) + return XSHAL_ABI; + else + return elf32xtensa_abi; +} /* Set up an entry in the procedure linkage table. */ @@ -2259,6 +2286,7 @@ elf_xtensa_create_plt_entry (struct bfd_link_info *info, bfd_vma plt_base, got_base; bfd_vma code_offset, lit_offset, abi_offset; int chunk; + int abi = xtensa_abi_choice (); chunk = reloc_index / PLT_ENTRIES_PER_CHUNK; splt = elf_xtensa_get_plt_section (info, chunk); @@ -2279,10 +2307,10 @@ elf_xtensa_create_plt_entry (struct bfd_link_info *info, /* Fill in the entry in the procedure linkage table. */ memcpy (splt->contents + code_offset, (bfd_big_endian (output_bfd) - ? elf_xtensa_be_plt_entry[XSHAL_ABI != XTHAL_ABI_WINDOWED] - : elf_xtensa_le_plt_entry[XSHAL_ABI != XTHAL_ABI_WINDOWED]), + ? elf_xtensa_be_plt_entry[abi != XTHAL_ABI_WINDOWED] + : elf_xtensa_le_plt_entry[abi != XTHAL_ABI_WINDOWED]), PLT_ENTRY_SIZE); - abi_offset = XSHAL_ABI == XTHAL_ABI_WINDOWED ? 3 : 0; + abi_offset = abi == XTHAL_ABI_WINDOWED ? 3 : 0; bfd_put_16 (output_bfd, l32r_offset (got_base + 0, plt_base + code_offset + abi_offset), splt->contents + code_offset + abi_offset + 1); |