diff options
author | Matthieu Longo <matthieu.longo@arm.com> | 2024-11-14 16:41:05 +0000 |
---|---|---|
committer | Matthieu Longo <matthieu.longo@arm.com> | 2024-12-02 15:18:40 +0000 |
commit | 946b753836b65ef5785e488e6b1527bb78d62694 (patch) | |
tree | ae2f6d04d849a650628c7a4934d4e9d4ce92a62a /bfd | |
parent | fc569c422fd9485e33085a4ae4aa628306344745 (diff) | |
download | binutils-946b753836b65ef5785e488e6b1527bb78d62694.zip binutils-946b753836b65ef5785e488e6b1527bb78d62694.tar.gz binutils-946b753836b65ef5785e488e6b1527bb78d62694.tar.bz2 |
aarch64: refactoring _bfd_aarch64_elf_link_setup_gnu_properties (part 1)
Exposing the output GNU property as a parameter of
_bfd_aarch64_elf_link_setup_gnu_properties seems to break the
encapsulation. The output GNU property update should be part of the
function that sets up the GNU properties.
This patch removes the parameter, and perform the update of the GNU
property on the output object inside the function.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/elfnn-aarch64.c | 38 | ||||
-rw-r--r-- | bfd/elfxx-aarch64.c | 9 | ||||
-rw-r--r-- | bfd/elfxx-aarch64.h | 27 |
3 files changed, 41 insertions, 33 deletions
diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c index ae7105a..482ce6a 100644 --- a/bfd/elfnn-aarch64.c +++ b/bfd/elfnn-aarch64.c @@ -2526,29 +2526,6 @@ struct elf_aarch64_local_symbol bfd_vma tlsdesc_got_jump_table_offset; }; -struct elf_aarch64_obj_tdata -{ - struct elf_obj_tdata root; - - /* local symbol descriptors */ - struct elf_aarch64_local_symbol *locals; - - /* Zero to warn when linking objects with incompatible enum sizes. */ - int no_enum_size_warning; - - /* Zero to warn when linking objects with incompatible wchar_t sizes. */ - int no_wchar_size_warning; - - /* All GNU_PROPERTY_AARCH64_FEATURE_1_AND properties. */ - uint32_t gnu_property_aarch64_feature_1_and; - - /* Software protections options. */ - struct aarch64_protection_opts sw_protections; -}; - -#define elf_aarch64_tdata(bfd) \ - ((struct elf_aarch64_obj_tdata *) (bfd)->tdata.any) - #define elf_aarch64_locals(bfd) (elf_aarch64_tdata (bfd)->locals) #define is_aarch64_elf(bfd) \ @@ -10615,12 +10592,19 @@ elfNN_aarch64_backend_symbol_processing (bfd *abfd, asymbol *sym) static bfd * elfNN_aarch64_link_setup_gnu_properties (struct bfd_link_info *info) { + bfd *pbfd = _bfd_aarch64_elf_link_setup_gnu_properties (info); + + /* When BTI is forced on the command line, information flows from plt_type to + outprop, so plt_type has already been set and outprop don't have any effect + on plt_type. + Whereas if BTI is inferred from the input bfds, information flows from + outprop to plt_type. If the property GNU_PROPERTY_AARCH64_FEATURE_1_BTI + has been set on all the input bfds, then BTI is set on the output bfd and + plt_type is updated accordingly. */ struct elf_aarch64_obj_tdata * tdata = elf_aarch64_tdata (info->output_bfd); uint32_t outprop = tdata->gnu_property_aarch64_feature_1_and; - bfd *pbfd = _bfd_aarch64_elf_link_setup_gnu_properties (info, &outprop); - tdata->gnu_property_aarch64_feature_1_and = outprop; - tdata->sw_protections.plt_type - |= (outprop & GNU_PROPERTY_AARCH64_FEATURE_1_BTI) ? PLT_BTI : 0; + if (outprop & GNU_PROPERTY_AARCH64_FEATURE_1_BTI) + tdata->sw_protections.plt_type |= PLT_BTI; setup_plt_values (info, tdata->sw_protections.plt_type); return pbfd; } diff --git a/bfd/elfxx-aarch64.c b/bfd/elfxx-aarch64.c index 2c0afb5..5d2c9e9 100644 --- a/bfd/elfxx-aarch64.c +++ b/bfd/elfxx-aarch64.c @@ -701,8 +701,7 @@ _bfd_aarch64_elf_write_core_note (bfd *abfd, char *buf, int *bufsiz, int note_ty such input is found, add it to a new section at the last input. Update GPROP accordingly. */ bfd * -_bfd_aarch64_elf_link_setup_gnu_properties (struct bfd_link_info *info, - uint32_t *gprop) +_bfd_aarch64_elf_link_setup_gnu_properties (struct bfd_link_info *info) { asection *sec; bfd *pbfd; @@ -710,7 +709,8 @@ _bfd_aarch64_elf_link_setup_gnu_properties (struct bfd_link_info *info, elf_property *prop; unsigned align; - uint32_t outprop = *gprop; + struct elf_aarch64_obj_tdata *tdata = elf_aarch64_tdata (info->output_bfd); + uint32_t outprop = tdata->gnu_property_aarch64_feature_1_and; /* Find a normal input file with GNU property note. */ for (pbfd = info->input_bfds; @@ -792,7 +792,8 @@ _bfd_aarch64_elf_link_setup_gnu_properties (struct bfd_link_info *info, break; } } - *gprop = outprop; + + tdata->gnu_property_aarch64_feature_1_and = outprop; return pbfd; } diff --git a/bfd/elfxx-aarch64.h b/bfd/elfxx-aarch64.h index 43db992..8302654 100644 --- a/bfd/elfxx-aarch64.h +++ b/bfd/elfxx-aarch64.h @@ -65,6 +65,30 @@ struct aarch64_protection_opts }; typedef struct aarch64_protection_opts aarch64_protection_opts; +struct elf_aarch64_local_symbol; +struct elf_aarch64_obj_tdata +{ + struct elf_obj_tdata root; + + /* local symbol descriptors */ + struct elf_aarch64_local_symbol *locals; + + /* Zero to warn when linking objects with incompatible enum sizes. */ + int no_enum_size_warning; + + /* Zero to warn when linking objects with incompatible wchar_t sizes. */ + int no_wchar_size_warning; + + /* All GNU_PROPERTY_AARCH64_FEATURE_1_AND properties. */ + uint32_t gnu_property_aarch64_feature_1_and; + + /* Software protections options. */ + struct aarch64_protection_opts sw_protections; +}; + +#define elf_aarch64_tdata(bfd) \ + ((struct elf_aarch64_obj_tdata *) (bfd)->tdata.any) + /* An enum to define what kind of erratum fixes we should apply. This gives the user a bit more control over the sequences we generate. */ typedef enum @@ -155,8 +179,7 @@ _bfd_aarch64_elf_write_core_note (bfd *, char *, int *, int, ...); #define elf_backend_write_core_note _bfd_aarch64_elf_write_core_note extern bfd * -_bfd_aarch64_elf_link_setup_gnu_properties (struct bfd_link_info *, - uint32_t *); +_bfd_aarch64_elf_link_setup_gnu_properties (struct bfd_link_info *); extern enum elf_property_kind _bfd_aarch64_elf_parse_gnu_properties (bfd *, unsigned int, |