aboutsummaryrefslogtreecommitdiff
path: root/bfd/elflink.c
diff options
context:
space:
mode:
Diffstat (limited to 'bfd/elflink.c')
-rw-r--r--bfd/elflink.c77
1 files changed, 77 insertions, 0 deletions
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 238a4aa..e2cb28c 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -12167,6 +12167,83 @@ bfd_elf_gc_record_vtentry (bfd *abfd ATTRIBUTE_UNUSED,
return TRUE;
}
+/* Map an ELF section header flag to its corresponding string. */
+typedef struct
+{
+ char *flag_name;
+ flagword flag_value;
+} elf_flags_to_name_table;
+
+static elf_flags_to_name_table elf_flags_to_names [] =
+{
+ { "SHF_WRITE", SHF_WRITE },
+ { "SHF_ALLOC", SHF_ALLOC },
+ { "SHF_EXECINSTR", SHF_EXECINSTR },
+ { "SHF_MERGE", SHF_MERGE },
+ { "SHF_STRINGS", SHF_STRINGS },
+ { "SHF_INFO_LINK", SHF_INFO_LINK},
+ { "SHF_LINK_ORDER", SHF_LINK_ORDER},
+ { "SHF_OS_NONCONFORMING", SHF_OS_NONCONFORMING},
+ { "SHF_GROUP", SHF_GROUP },
+ { "SHF_TLS", SHF_TLS },
+ { "SHF_MASKOS", SHF_MASKOS },
+ { "SHF_EXCLUDE", SHF_EXCLUDE },
+};
+
+void
+bfd_elf_lookup_section_flags (struct bfd_link_info *info,
+ struct flag_info *finfo)
+{
+ bfd *output_bfd = info->output_bfd;
+ const struct elf_backend_data *bed = get_elf_backend_data (output_bfd);
+ struct flag_info_list *tf = finfo->flag_list;
+ int with_hex = 0;
+ int without_hex = 0;
+
+ for (tf = finfo->flag_list; tf != NULL; tf = tf->next)
+ {
+ int i;
+ if (bed->elf_backend_lookup_section_flags_hook)
+ {
+ flagword hexval =
+ (*bed->elf_backend_lookup_section_flags_hook) ((char *) tf->name);
+
+ if (hexval != 0)
+ {
+ if (tf->with == with_flags)
+ with_hex |= hexval;
+ else if (tf->with == without_flags)
+ without_hex |= hexval;
+ tf->valid = TRUE;
+ continue;
+ }
+ }
+ for (i = 0; i < 12; i++)
+ {
+ if (!strcmp (tf->name, elf_flags_to_names[i].flag_name))
+ {
+ if (tf->with == with_flags)
+ with_hex |= elf_flags_to_names[i].flag_value;
+ else if (tf->with == without_flags)
+ without_hex |= elf_flags_to_names[i].flag_value;
+ tf->valid = TRUE;
+ continue;
+ }
+ }
+ if (tf->valid == FALSE)
+ {
+ info->callbacks->einfo
+ (_("Unrecognized INPUT_SECTION_FLAG %s\n"), tf->name);
+ return;
+ }
+ }
+ finfo->flags_initialized = TRUE;
+ finfo->only_with_flags |= with_hex;
+ finfo->not_with_flags |= without_hex;
+
+ return;
+}
+
struct alloc_got_off_arg {
bfd_vma gotoff;
struct bfd_link_info *info;