aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthieu Longo <matthieu.longo@arm.com>2024-11-14 17:08:27 +0000
committerMatthieu Longo <matthieu.longo@arm.com>2024-12-02 15:18:40 +0000
commitd350b1501777553d6742bc5eb2982efc5103b84d (patch)
tree1f84168e57052f10c61883566472f438639cac0e
parent061040ffc3ef36365ab71ab8fd9ca3bb3306d4a1 (diff)
downloadbinutils-d350b1501777553d6742bc5eb2982efc5103b84d.zip
binutils-d350b1501777553d6742bc5eb2982efc5103b84d.tar.gz
binutils-d350b1501777553d6742bc5eb2982efc5103b84d.tar.bz2
aarch64: refactoring _bfd_aarch64_elf_link_setup_gnu_properties (part 4)
Move the code related to the creation of the gnu.note section to a separate function: _bfd_aarch64_elf_create_gnu_property_section
-rw-r--r--bfd/elfxx-aarch64.c49
1 files changed, 27 insertions, 22 deletions
diff --git a/bfd/elfxx-aarch64.c b/bfd/elfxx-aarch64.c
index 6660dfc..9a27988 100644
--- a/bfd/elfxx-aarch64.c
+++ b/bfd/elfxx-aarch64.c
@@ -724,16 +724,40 @@ _bfd_aarch64_elf_find_1st_bfd_input_with_gnu_property (
return prev;
}
+/* Create a GNU property section for the given bfd input. */
+static void
+_bfd_aarch64_elf_create_gnu_property_section (struct bfd_link_info *info,
+ bfd *ebfd)
+{
+ asection *sec;
+ sec = bfd_make_section_with_flags (ebfd,
+ NOTE_GNU_PROPERTY_SECTION_NAME,
+ (SEC_ALLOC
+ | SEC_LOAD
+ | SEC_IN_MEMORY
+ | SEC_READONLY
+ | SEC_HAS_CONTENTS
+ | SEC_DATA));
+ if (sec == NULL)
+ info->callbacks->einfo (
+ _("%F%P: failed to create GNU property section\n"));
+
+ unsigned align = (bfd_get_mach (ebfd) & bfd_mach_aarch64_ilp32) ? 2 : 3;
+ if (!bfd_set_section_alignment (sec, align))
+ info->callbacks->einfo (_("%F%pA: failed to align section\n"),
+ sec);
+
+ elf_section_type (sec) = SHT_NOTE;
+}
+
/* Find the first input bfd with GNU property and merge it with GPROP. If no
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)
{
- asection *sec;
bfd *pbfd;
elf_property *prop;
- unsigned align;
struct elf_aarch64_obj_tdata *tdata = elf_aarch64_tdata (info->output_bfd);
uint32_t outprop = tdata->gnu_property_aarch64_feature_1_and;
@@ -762,26 +786,7 @@ _bfd_aarch64_elf_link_setup_gnu_properties (struct bfd_link_info *info)
/* If no GNU property node was found, create the GNU property note
section. */
if (!has_gnu_property)
- {
- sec = bfd_make_section_with_flags (ebfd,
- NOTE_GNU_PROPERTY_SECTION_NAME,
- (SEC_ALLOC
- | SEC_LOAD
- | SEC_IN_MEMORY
- | SEC_READONLY
- | SEC_HAS_CONTENTS
- | SEC_DATA));
- if (sec == NULL)
- info->callbacks->einfo (
- _("%F%P: failed to create GNU property section\n"));
-
- align = (bfd_get_mach (ebfd) & bfd_mach_aarch64_ilp32) ? 2 : 3;
- if (!bfd_set_section_alignment (sec, align))
- info->callbacks->einfo (_("%F%pA: failed to align section\n"),
- sec);
-
- elf_section_type (sec) = SHT_NOTE;
- }
+ _bfd_aarch64_elf_create_gnu_property_section (info, ebfd);
}
pbfd = _bfd_elf_link_setup_gnu_properties (info);