diff options
author | Yury Khrustalev <yury.khrustalev@arm.com> | 2025-03-27 16:48:24 +0000 |
---|---|---|
committer | Yury Khrustalev <yury.khrustalev@arm.com> | 2025-04-17 12:34:01 +0100 |
commit | bb71794c479b15aa4ca6b4a74b87af75079a2a36 (patch) | |
tree | 83563ac9b9a61029be234faff4cd51b6d84840da | |
parent | 610f55b542e95dbfa438cfda92f29c2704e8409f (diff) | |
download | binutils-bb71794c479b15aa4ca6b4a74b87af75079a2a36.zip binutils-bb71794c479b15aa4ca6b4a74b87af75079a2a36.tar.gz binutils-bb71794c479b15aa4ca6b4a74b87af75079a2a36.tar.bz2 |
aarch64: ld: Fix scanning of GNU properties for AARCH64_FEATURE_1_AND
Fixes [1]. Previously iteration over GNU properties of an input file
could stop before reaching GNU_PROPERTY_AARCH64_FEATURE_1_AND which
would result in incorrect inference of properties of the output file.
In the particular use case described in [1], the memory seal property
GNU_PROPERTY_MEMORY_SEAL with number 3, if present in the input file,
prevented reading information from GNU_PROPERTY_AARCH64_FEATURE_1_AND
property due to filtering by property number.
[1] PR32818 https://sourceware.org/bugzilla/show_bug.cgi?id=32818
-rw-r--r-- | bfd/elfxx-aarch64.c | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/bfd/elfxx-aarch64.c b/bfd/elfxx-aarch64.c index 45a0205..68e004ef 100644 --- a/bfd/elfxx-aarch64.c +++ b/bfd/elfxx-aarch64.c @@ -930,28 +930,20 @@ _bfd_aarch64_elf_link_setup_gnu_properties (struct bfd_link_info *info) GNU properties (if found). */ bfd *pbfd = _bfd_elf_link_setup_gnu_properties (info); - /* If pbfd has any GNU_PROPERTY_AARCH64_FEATURE_1_AND properties, update - outprop accordingly. */ if (pbfd != NULL) { - /* The property list is sorted in order of type. */ - for (elf_property_list *p = elf_properties (pbfd); - (p != NULL) - && (GNU_PROPERTY_AARCH64_FEATURE_1_AND <= p->property.pr_type); - p = p->next) - { - /* This merge of features should happen only once as all the identical - properties are supposed to have been merged at this stage by - _bfd_elf_link_setup_gnu_properties(). */ - if (p->property.pr_type == GNU_PROPERTY_AARCH64_FEATURE_1_AND) - { - outprop = (p->property.u.number - & (GNU_PROPERTY_AARCH64_FEATURE_1_BTI - | GNU_PROPERTY_AARCH64_FEATURE_1_PAC - | GNU_PROPERTY_AARCH64_FEATURE_1_GCS)); - break; - } - } + elf_property_list *p; + elf_property_list *plist = elf_properties (pbfd); + + /* If pbfd has any GNU_PROPERTY_AARCH64_FEATURE_1_AND properties, update + outprop accordingly. */ + if ((p = _bfd_elf_find_property (plist, + GNU_PROPERTY_AARCH64_FEATURE_1_AND, NULL)) + != NULL) + outprop = p->property.u.number + & (GNU_PROPERTY_AARCH64_FEATURE_1_BTI + | GNU_PROPERTY_AARCH64_FEATURE_1_PAC + | GNU_PROPERTY_AARCH64_FEATURE_1_GCS); } tdata->gnu_property_aarch64_feature_1_and = outprop; |