+2021-06-24 Luis Machado <luis.machado@arm.com>
+
+ * aarch64-tdep.c: Include elf/aarch64.h.
+ (aarch64_bfd_has_capabilities): Make more robust.
+ (aarch64_gdbarch_init): Set have_capability if we have a pure-cap
+ ABI marker.
+
2021-06-24 Luis Machado <luis.machado@arm.com>
* aarch64-linux-nat.c (maint_print_cap_from_addr_cmd)
#include "inferior.h"
#include "elf-bfd.h"
+#include "elf/aarch64.h" /* for ELF flags. */
#define submask(x) ((1L << ((x) + 1)) - 1)
#define bit(obj,st) (((obj) >> (st)) & 1)
gdb_assert (abfd != nullptr);
- asection *cap_relocs = bfd_get_section_by_name (abfd, "__cap_relocs");
+ int e_flags = elf_elfheader (abfd)->e_flags;
if (aarch64_debug)
- debug_printf ("%s: cap_relocs = %s\n", __func__,
- cap_relocs == nullptr? "not found" : "found");
+ debug_printf ("%s: e_flags = %x\n", __func__, e_flags);
- if (cap_relocs != nullptr)
+ if (e_flags & EF_AARCH64_CHERI_PURECAP)
return true;
- /* Assume regular non-capability symbol file. */
+ if (aarch64_debug)
+ debug_printf ("%s: e_flags doesn't contain EF_AARCH64_CHERI_PURECAP.\n",
+ __func__);
+
+ /* Use the LSB of e_entry for now. If the LSB is set, this means we have a
+ Morello pure capability binary. */
+ if (elf_elfheader (abfd)->e_entry & 1)
+ return true;
+
+ if (aarch64_debug)
+ debug_printf ("%s: e_entry's LSB is not set. Assuming AAPCS64 ABI.\n",
+ __func__);
+
+ /* Assume this is a Hybrid ABI ELF. */
return false;
}
have_capability = true;
}
}
+ else if (aarch64_current_abi_global == AARCH64_ABI_AAPCS64_CAP)
+ have_capability = true;
/* If there is already a candidate, use it. */
for (gdbarch_list *best_arch = gdbarch_list_lookup_by_info (arches, &info);
#define DT_AARCH64_PAC_PLT (DT_LOPROC + 3)
#define DT_AARCH64_VARIANT_PCS (DT_LOPROC + 5)
+/* AArch64-specific e_flags entries. */
+#define EF_AARCH64_CHERI_PURECAP 0x00010000
+
/* AArch64-specific values for st_other. */
#define STO_AARCH64_VARIANT_PCS 0x80 /* Symbol may follow different call
convention from the base PCS. */