diff options
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/elfnn-riscv.c | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c index 36cbf1e..d8c9066 100644 --- a/bfd/elfnn-riscv.c +++ b/bfd/elfnn-riscv.c @@ -134,6 +134,9 @@ struct riscv_elf_link_hash_table /* The data segment phase, don't relax the section when it is exp_seg_relro_adjust. */ int *data_segment_phase; + + /* Relocations for variant CC symbols may be present. */ + int variant_cc; }; /* Instruction access functions. */ @@ -1172,6 +1175,11 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) h->root.u.def.section = s; h->root.u.def.value = h->plt.offset; } + + /* If the symbol has STO_RISCV_VARIANT_CC flag, then raise the + variant_cc flag of riscv_elf_link_hash_table. */ + if (h->other & STO_RISCV_VARIANT_CC) + htab->variant_cc = 1; } else { @@ -1555,7 +1563,18 @@ riscv_elf_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) return false; } - return _bfd_elf_add_dynamic_tags (output_bfd, info, true); + /* Add dynamic entries. */ + if (elf_hash_table (info)->dynamic_sections_created) + { + if (!_bfd_elf_add_dynamic_tags (output_bfd, info, true)) + return false; + + if (htab->variant_cc + && !_bfd_elf_add_dynamic_entry (info, DT_RISCV_VARIANT_CC, 0)) + return false; + } + + return true; } #define TP_OFFSET 0 @@ -5227,6 +5246,28 @@ riscv_elf_modify_segment_map (bfd *abfd, return true; } +/* Merge non-visibility st_other attributes. */ + +static void +riscv_elf_merge_symbol_attribute (struct elf_link_hash_entry *h, + unsigned int st_other, + bool definition ATTRIBUTE_UNUSED, + bool dynamic ATTRIBUTE_UNUSED) +{ + unsigned int isym_sto = st_other & ~ELF_ST_VISIBILITY (-1); + unsigned int h_sto = h->other & ~ELF_ST_VISIBILITY (-1); + + if (isym_sto == h_sto) + return; + + if (isym_sto & ~STO_RISCV_VARIANT_CC) + _bfd_error_handler (_("unknown attribute for symbol `%s': 0x%02x"), + h->root.root.string, isym_sto); + + if (isym_sto & STO_RISCV_VARIANT_CC) + h->other |= STO_RISCV_VARIANT_CC; +} + #define TARGET_LITTLE_SYM riscv_elfNN_vec #define TARGET_LITTLE_NAME "elfNN-littleriscv" #define TARGET_BIG_SYM riscv_elfNN_be_vec @@ -5263,6 +5304,7 @@ riscv_elf_modify_segment_map (bfd *abfd, #define elf_backend_additional_program_headers \ riscv_elf_additional_program_headers #define elf_backend_modify_segment_map riscv_elf_modify_segment_map +#define elf_backend_merge_symbol_attribute riscv_elf_merge_symbol_attribute #define elf_backend_init_index_section _bfd_elf_init_1_index_section |