diff options
57 files changed, 732 insertions, 268 deletions
diff --git a/bfd/archive.c b/bfd/archive.c index 697b2ed..52d3119 100644 --- a/bfd/archive.c +++ b/bfd/archive.c @@ -142,7 +142,6 @@ SUBSECTION #include "filenames.h" #include "bfdlink.h" #if BFD_SUPPORTS_PLUGINS -#include "plugin-api.h" #include "plugin.h" #endif @@ -29,12 +29,12 @@ AC_DEFUN([BFD_HAVE_SYS_PROCFS_TYPE], [AC_REQUIRE([BFD_SYS_PROCFS_H]) AC_MSG_CHECKING([for $1 in sys/procfs.h]) AC_CACHE_VAL(bfd_cv_have_sys_procfs_type_$1, - [AC_TRY_COMPILE([ + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #define _SYSCALL32 -#include <sys/procfs.h>], - [$1 avar], - bfd_cv_have_sys_procfs_type_$1=yes, - bfd_cv_have_sys_procfs_type_$1=no +#include <sys/procfs.h>]], + [[$1 avar]])], + [bfd_cv_have_sys_procfs_type_$1=yes], + [bfd_cv_have_sys_procfs_type_$1=no] )]) if test $bfd_cv_have_sys_procfs_type_$1 = yes; then AC_DEFINE([HAVE_]translit($1, [a-z], [A-Z]), 1, @@ -49,12 +49,12 @@ AC_DEFUN([BFD_HAVE_SYS_PROCFS_TYPE_MEMBER], [AC_REQUIRE([BFD_SYS_PROCFS_H]) AC_MSG_CHECKING([for $1.$2 in sys/procfs.h]) AC_CACHE_VAL(bfd_cv_have_sys_procfs_type_member_$1_$2, - [AC_TRY_COMPILE([ + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #define _SYSCALL32 -#include <sys/procfs.h>], - [$1 avar; void* aref = (void*) &avar.$2], - bfd_cv_have_sys_procfs_type_member_$1_$2=yes, - bfd_cv_have_sys_procfs_type_member_$1_$2=no +#include <sys/procfs.h>]], + [[$1 avar; void* aref = (void*) &avar.$2]])], + [bfd_cv_have_sys_procfs_type_member_$1_$2=yes], + [bfd_cv_have_sys_procfs_type_member_$1_$2=no] )]) if test $bfd_cv_have_sys_procfs_type_member_$1_$2 = yes; then AC_DEFINE([HAVE_]translit($1, [a-z], [A-Z])[_]translit($2, [a-z], [A-Z]), 1, @@ -62,4 +62,3 @@ AC_DEFUN([BFD_HAVE_SYS_PROCFS_TYPE_MEMBER], fi AC_MSG_RESULT($bfd_cv_have_sys_procfs_type_member_$1_$2) ]) - diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h index b791623..f24342c 100644 --- a/bfd/elf-bfd.h +++ b/bfd/elf-bfd.h @@ -2632,7 +2632,7 @@ extern bool _bfd_elf_link_output_relocs struct elf_link_hash_entry **); extern void _bfd_elf_link_add_glibc_version_dependency - (struct elf_find_verdep_info *, const char *[]); + (struct elf_find_verdep_info *, const char *const []); extern void _bfd_elf_link_add_dt_relr_dependency (struct elf_find_verdep_info *); @@ -10948,7 +10948,7 @@ elfcore_grok_win32pstatus (bfd *abfd, Elf_Internal_Note *note) type = bfd_get_32 (abfd, note->descdata); - struct + static const struct { const char *type_name; unsigned long min_size; @@ -13345,7 +13345,7 @@ elf_parse_notes (bfd *abfd, char *buf, size_t size, file_ptr offset, case bfd_core: { #define GROKER_ELEMENT(S,F) {S, sizeof (S) - 1, F} - struct + static const struct { const char * string; size_t len; diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index b5d1866..df60430 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -12542,7 +12542,7 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, case R_ARM_THM_ALU_ABS_G2_NC: case R_ARM_THM_ALU_ABS_G3_NC: { - const int shift_array[4] = {0, 8, 16, 24}; + static const int shift_array[4] = {0, 8, 16, 24}; bfd_vma insn = bfd_get_16 (input_bfd, hit_data); bfd_vma addr = value; int shift = shift_array[r_type - R_ARM_THM_ALU_ABS_G0_NC]; @@ -14061,11 +14061,12 @@ set_secondary_compatible_arch (bfd *abfd, int arch) static int tag_cpu_arch_combine (bfd *ibfd, int oldtag, int *secondary_compat_out, - int newtag, int secondary_compat, const char* name_table[]) + int newtag, int secondary_compat, + const char *const name_table[]) { #define T(X) TAG_CPU_ARCH_##X int tagl, tagh, result; - const int v6t2[] = + static const int v6t2[] = { T(V6T2), /* PRE_V4. */ T(V6T2), /* V4. */ @@ -14077,7 +14078,7 @@ tag_cpu_arch_combine (bfd *ibfd, int oldtag, int *secondary_compat_out, T(V7), /* V6KZ. */ T(V6T2) /* V6T2. */ }; - const int v6k[] = + static const int v6k[] = { T(V6K), /* PRE_V4. */ T(V6K), /* V4. */ @@ -14090,7 +14091,7 @@ tag_cpu_arch_combine (bfd *ibfd, int oldtag, int *secondary_compat_out, T(V7), /* V6T2. */ T(V6K) /* V6K. */ }; - const int v7[] = + static const int v7[] = { T(V7), /* PRE_V4. */ T(V7), /* V4. */ @@ -14104,7 +14105,7 @@ tag_cpu_arch_combine (bfd *ibfd, int oldtag, int *secondary_compat_out, T(V7), /* V6K. */ T(V7) /* V7. */ }; - const int v6_m[] = + static const int v6_m[] = { -1, /* PRE_V4. */ -1, /* V4. */ @@ -14119,7 +14120,7 @@ tag_cpu_arch_combine (bfd *ibfd, int oldtag, int *secondary_compat_out, T(V7), /* V7. */ T(V6_M) /* V6_M. */ }; - const int v6s_m[] = + static const int v6s_m[] = { -1, /* PRE_V4. */ -1, /* V4. */ @@ -14135,7 +14136,7 @@ tag_cpu_arch_combine (bfd *ibfd, int oldtag, int *secondary_compat_out, T(V6S_M), /* V6_M. */ T(V6S_M) /* V6S_M. */ }; - const int v7e_m[] = + static const int v7e_m[] = { -1, /* PRE_V4. */ -1, /* V4. */ @@ -14152,7 +14153,7 @@ tag_cpu_arch_combine (bfd *ibfd, int oldtag, int *secondary_compat_out, T(V7E_M), /* V6S_M. */ T(V7E_M) /* V7E_M. */ }; - const int v8[] = + static const int v8[] = { T(V8), /* PRE_V4. */ T(V8), /* V4. */ @@ -14177,7 +14178,7 @@ tag_cpu_arch_combine (bfd *ibfd, int oldtag, int *secondary_compat_out, T(V8), /* V8.3. */ T(V8), /* V8.1-M.MAIN. */ }; - const int v8r[] = + static const int v8r[] = { T(V8R), /* PRE_V4. */ T(V8R), /* V4. */ @@ -14196,7 +14197,7 @@ tag_cpu_arch_combine (bfd *ibfd, int oldtag, int *secondary_compat_out, T(V8), /* V8. */ T(V8R), /* V8R. */ }; - const int v8m_baseline[] = + static const int v8m_baseline[] = { -1, /* PRE_V4. */ -1, /* V4. */ @@ -14216,7 +14217,7 @@ tag_cpu_arch_combine (bfd *ibfd, int oldtag, int *secondary_compat_out, -1, /* V8R. */ T(V8M_BASE) /* V8-M BASELINE. */ }; - const int v8m_mainline[] = + static const int v8m_mainline[] = { -1, /* PRE_V4. */ -1, /* V4. */ @@ -14237,7 +14238,7 @@ tag_cpu_arch_combine (bfd *ibfd, int oldtag, int *secondary_compat_out, T(V8M_MAIN), /* V8-M BASELINE. */ T(V8M_MAIN) /* V8-M MAINLINE. */ }; - const int v8_1m_mainline[] = + static const int v8_1m_mainline[] = { -1, /* PRE_V4. */ -1, /* V4. */ @@ -14262,7 +14263,7 @@ tag_cpu_arch_combine (bfd *ibfd, int oldtag, int *secondary_compat_out, -1, /* Unused (20). */ T(V8_1M_MAIN) /* V8.1-M MAINLINE. */ }; - const int v9[] = + static const int v9[] = { T(V9), /* PRE_V4. */ T(V9), /* V4. */ @@ -14288,7 +14289,7 @@ tag_cpu_arch_combine (bfd *ibfd, int oldtag, int *secondary_compat_out, T(V9), /* V8.1-M.MAIN. */ T(V9), /* V9. */ }; - const int v4t_plus_v6_m[] = + static const int v4t_plus_v6_m[] = { -1, /* PRE_V4. */ -1, /* V4. */ @@ -14315,7 +14316,7 @@ tag_cpu_arch_combine (bfd *ibfd, int oldtag, int *secondary_compat_out, T(V9), /* V9. */ T(V4T_PLUS_V6_M) /* V4T plus V6_M. */ }; - const int *comb[] = + static const int *const comb[] = { v6t2, v6k, @@ -14539,7 +14540,7 @@ elf32_arm_merge_eabi_attributes (bfd *ibfd, struct bfd_link_info *info) int secondary_compat = -1, secondary_compat_out = -1; unsigned int saved_out_attr = out_attr[i].i; int arch_attr; - static const char *name_table[] = + static const char *const name_table[] = { /* These aren't real CPU names, but we can't guess that from the architecture version alone. */ diff --git a/bfd/elflink.c b/bfd/elflink.c index c4f57cf..7b03754 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -28,7 +28,6 @@ #include "libiberty.h" #include "objalloc.h" #if BFD_SUPPORTS_PLUGINS -#include "plugin-api.h" #include "plugin.h" #endif @@ -2381,7 +2380,7 @@ elf_link_add_glibc_verneed (struct elf_find_verdep_info *rinfo, void _bfd_elf_link_add_glibc_version_dependency (struct elf_find_verdep_info *rinfo, - const char *version_dep[]) + const char *const version_dep[]) { Elf_Internal_Verneed *t = NULL; int glibc_minor_base = INT_MAX; @@ -2406,7 +2405,7 @@ _bfd_elf_link_add_dt_relr_dependency (struct elf_find_verdep_info *rinfo) { if (rinfo->info->enable_dt_relr) { - const char *version[] = + static const char *const version[] = { "GLIBC_ABI_DT_RELR", NULL diff --git a/bfd/elfnn-loongarch.c b/bfd/elfnn-loongarch.c index 1ddea2f..8beb3d8 100644 --- a/bfd/elfnn-loongarch.c +++ b/bfd/elfnn-loongarch.c @@ -4903,6 +4903,60 @@ loongarch_relax_delete_or_nop (bfd *abfd, bfd_put (32, abfd, LARCH_NOP, contents + addr); } +/* If some bytes in a symbol is deleted, we need to adjust its size. */ +static void +loongarch_relax_resize_symbol (bfd_size_type *size, bfd_vma orig_value, + splay_tree pdops) +{ + splay_tree_key key = (splay_tree_key)orig_value; + bfd_vma orig_end = orig_value + *size; + splay_tree_node node = splay_tree_predecessor (pdops, key); + + if (node) + { + bfd_vma addr = (bfd_vma)node->key; + struct pending_delete_op *op = (struct pending_delete_op *)node->value; + + /* This shouldn't happen unless people write something really insane like + .reloc ., R_LARCH_ALIGN, 60 + .rept 15 + 1: nop + .endr + .set x, 1b + .size x, . - 1b + But let's just try to make it "work" anyway. */ + if (orig_value < addr + op->size) + { + bfd_size_type n_deleted = op->size - (orig_value - addr); + if (n_deleted >= *size) + { + *size = 0; + return; + } + + *size -= n_deleted; + } + } + + node = splay_tree_lookup (pdops, key); + if (!node) + node = splay_tree_successor (pdops, key); + + for (; node; node = splay_tree_successor (pdops, node->key)) + { + bfd_vma addr = (bfd_vma)node->key; + struct pending_delete_op *op = (struct pending_delete_op *)node->value; + + if (addr >= orig_end) + return; + + if (orig_end < addr + op->size) + *size -= orig_end - addr; + else + *size -= op->size; + } +} + static void loongarch_relax_perform_deletes (bfd *abfd, asection *sec, struct bfd_link_info *link_info) @@ -5001,30 +5055,8 @@ loongarch_relax_perform_deletes (bfd *abfd, asection *sec, sym->st_value = loongarch_calc_relaxed_addr (link_info, orig_value); - /* If the symbol *spans* some deleted bytes, that is its *end* is in - the moved bytes but its *start* isn't, then we must adjust its - size. - - This test needs to use the original value of st_value, otherwise - we might accidentally decrease size when deleting bytes right - before the symbol. */ - bfd_vma sym_end = orig_value + sym->st_size; - if (sym_end <= toaddr) - { - splay_tree_node node = splay_tree_predecessor ( - pdops, (splay_tree_key)orig_value); - for (; node; node = splay_tree_successor (pdops, node->key)) - { - bfd_vma addr = (bfd_vma)node->key; - struct pending_delete_op *op - = (struct pending_delete_op *)node->value; - - if (addr >= sym_end) - break; - if (orig_value <= addr && sym_end > addr) - sym->st_size -= op->size; - } - } + if (orig_value + sym->st_size <= toaddr) + loongarch_relax_resize_symbol (&sym->st_size, orig_value, pdops); } } @@ -5071,29 +5103,13 @@ loongarch_relax_perform_deletes (bfd *abfd, asection *sec, { bfd_vma orig_value = sym_hash->root.u.def.value; - /* As above, adjust the value. */ + /* As above, adjust the value and size. */ if (orig_value <= toaddr) sym_hash->root.u.def.value = loongarch_calc_relaxed_addr (link_info, orig_value); - /* As above, adjust the size if needed. */ - bfd_vma sym_end = orig_value + sym_hash->size; - if (sym_end <= toaddr) - { - splay_tree_node node = splay_tree_predecessor ( - pdops, (splay_tree_key)orig_value); - for (; node; node = splay_tree_successor (pdops, node->key)) - { - bfd_vma addr = (bfd_vma)node->key; - struct pending_delete_op *op - = (struct pending_delete_op *)node->value; - - if (addr >= sym_end) - break; - if (orig_value <= addr && sym_end > addr) - sym_hash->size -= op->size; - } - } + if (orig_value + sym_hash->size <= toaddr) + loongarch_relax_resize_symbol (&sym_hash->size, orig_value, pdops); } } } diff --git a/bfd/elfxx-riscv.c b/bfd/elfxx-riscv.c index 1200032..3567573 100644 --- a/bfd/elfxx-riscv.c +++ b/bfd/elfxx-riscv.c @@ -43,7 +43,7 @@ static bfd_reloc_status_type riscv_elf_ignore_reloc /* The relocation table used for SHT_RELA sections. */ -static reloc_howto_type howto_table[] = +static const reloc_howto_type howto_table[] = { /* No relocation. */ HOWTO (R_RISCV_NONE, /* type */ @@ -879,7 +879,7 @@ static reloc_howto_type howto_table[] = false) /* pcrel_offset */ }; -static reloc_howto_type howto_table_internal[] = +static const reloc_howto_type howto_table_internal[] = { /* R_RISCV_DELETE. */ EMPTY_HOWTO (0), @@ -1204,7 +1204,7 @@ struct riscv_implicit_subset const riscv_subset_t *); }; /* Please added in order since this table is only run once time. */ -static struct riscv_implicit_subset riscv_implicit_subsets[] = +static const struct riscv_implicit_subset riscv_implicit_subsets[] = { {"g", "+i,+m,+a,+f,+d,+zicsr,+zifencei", check_implicit_always}, {"e", "+i", check_implicit_always}, @@ -1336,7 +1336,7 @@ static struct riscv_implicit_subset riscv_implicit_subsets[] = }; /* This table records the mapping form RISC-V Profiles into march string. */ -static struct riscv_profiles riscv_profiles_table[] = +static const struct riscv_profiles riscv_profiles_table[] = { /* RVI20U only contains the base extension 'i' as mandatory extension. */ {"rvi20u64", "rv64i"}, @@ -1408,7 +1408,7 @@ struct riscv_supported_ext /* The standard extensions must be added in canonical order. */ -static struct riscv_supported_ext riscv_supported_std_ext[] = +static const struct riscv_supported_ext riscv_supported_std_ext[] = { {"e", ISA_SPEC_CLASS_20191213, 1, 9, 0 }, {"e", ISA_SPEC_CLASS_20190608, 1, 9, 0 }, @@ -1443,7 +1443,7 @@ static struct riscv_supported_ext riscv_supported_std_ext[] = {NULL, 0, 0, 0, 0} }; -static struct riscv_supported_ext riscv_supported_std_z_ext[] = +static const struct riscv_supported_ext riscv_supported_std_z_ext[] = { {"zic64b", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 }, {"ziccamoa", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 }, @@ -1550,7 +1550,7 @@ static struct riscv_supported_ext riscv_supported_std_z_ext[] = {NULL, 0, 0, 0, 0} }; -static struct riscv_supported_ext riscv_supported_std_s_ext[] = +static const struct riscv_supported_ext riscv_supported_std_s_ext[] = { {"sha", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 }, {"shcounterenw", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 }, @@ -1597,12 +1597,12 @@ static struct riscv_supported_ext riscv_supported_std_s_ext[] = {NULL, 0, 0, 0, 0} }; -static struct riscv_supported_ext riscv_supported_std_zxm_ext[] = +static const struct riscv_supported_ext riscv_supported_std_zxm_ext[] = { {NULL, 0, 0, 0, 0} }; -static struct riscv_supported_ext riscv_supported_vendor_x_ext[] = +static const struct riscv_supported_ext riscv_supported_vendor_x_ext[] = { {"xcvalu", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 }, {"xcvbi", ISA_SPEC_CLASS_DRAFT, 1, 0, 0 }, @@ -1639,7 +1639,7 @@ static struct riscv_supported_ext riscv_supported_vendor_x_ext[] = {NULL, 0, 0, 0, 0} }; -const struct riscv_supported_ext *riscv_all_supported_ext[] = +static const struct riscv_supported_ext *riscv_all_supported_ext[] = { riscv_supported_std_ext, riscv_supported_std_z_ext, @@ -1701,7 +1701,7 @@ riscv_get_prefix_class (const char *arch) static bool riscv_known_prefixed_ext (const char *ext, - struct riscv_supported_ext *known_exts) + const struct riscv_supported_ext *known_exts) { size_t i; for (i = 0; known_exts[i].name != NULL; ++i) @@ -1894,7 +1894,7 @@ riscv_get_default_ext_version (enum riscv_spec_class *default_isa_spec, || *default_isa_spec == ISA_SPEC_CLASS_NONE) return; - struct riscv_supported_ext *table = NULL; + const struct riscv_supported_ext *table = NULL; enum riscv_prefix_ext_class class = riscv_get_prefix_class (name); switch (class) { @@ -2185,7 +2185,7 @@ riscv_update_subset1 (riscv_parse_subset_t *, riscv_subset_t *, const char *); static void riscv_parse_add_implicit_subsets (riscv_parse_subset_t *rps) { - struct riscv_implicit_subset *t = riscv_implicit_subsets; + const struct riscv_implicit_subset *t = riscv_implicit_subsets; for (; t->ext; t++) { riscv_subset_t *subset = NULL; diff --git a/bfd/format.c b/bfd/format.c index bd9fa8d..fba8d2a 100644 --- a/bfd/format.c +++ b/bfd/format.c @@ -47,7 +47,6 @@ SUBSECTION #include "bfd.h" #include "libbfd.h" #if BFD_SUPPORTS_PLUGINS -#include "plugin-api.h" #include "plugin.h" #endif diff --git a/bfd/plugin.c b/bfd/plugin.c index 43ca444..733e7f0 100644 --- a/bfd/plugin.c +++ b/bfd/plugin.c @@ -138,6 +138,14 @@ struct plugin_list_entry const char *plugin_name; }; +struct plugin_data_struct +{ + int nsyms; + const struct ld_plugin_symbol *syms; + int object_only_nsyms; + asymbol **object_only_syms; +}; + static const char *plugin_program_name; void @@ -336,9 +344,8 @@ add_symbols (void * handle, const struct ld_plugin_symbol * syms) { bfd *abfd = handle; - struct plugin_data_struct *plugin_data = - bfd_alloc (abfd, sizeof (plugin_data_struct)); - + struct plugin_data_struct *plugin_data = bfd_alloc (abfd, + sizeof (*plugin_data)); if (!plugin_data) return LDPS_ERR; diff --git a/bfd/plugin.h b/bfd/plugin.h index 6acb5fa..d981c51 100644 --- a/bfd/plugin.h +++ b/bfd/plugin.h @@ -21,6 +21,8 @@ #ifndef _PLUGIN_H_ #define _PLUGIN_H_ +struct ld_plugin_input_file; + void bfd_plugin_set_program_name (const char *); int bfd_plugin_open_input (bfd *, struct ld_plugin_input_file *); void bfd_plugin_set_plugin (const char *); @@ -29,13 +31,4 @@ bool bfd_link_plugin_object_p (bfd *); void register_ld_plugin_object_p (bfd_cleanup (*object_p) (bfd *, bool)); void bfd_plugin_close_file_descriptor (bfd *, int); -typedef struct plugin_data_struct -{ - int nsyms; - const struct ld_plugin_symbol *syms; - int object_only_nsyms; - asymbol **object_only_syms; -} -plugin_data_struct; - #endif diff --git a/bfd/version.h b/bfd/version.h index 89f11ee..0346dd5 100644 --- a/bfd/version.h +++ b/bfd/version.h @@ -16,7 +16,7 @@ In releases, the date is not included in either version strings or sonames. */ -#define BFD_VERSION_DATE 20250807 +#define BFD_VERSION_DATE 20250808 #define BFD_VERSION @bfd_version@ #define BFD_VERSION_STRING @bfd_version_package@ @bfd_version_string@ #define REPORT_BUGS_TO @report_bugs_to@ diff --git a/binutils/ar.c b/binutils/ar.c index de41c9e..3cac3f3 100644 --- a/binutils/ar.c +++ b/binutils/ar.c @@ -32,9 +32,9 @@ #include "arsup.h" #include "filenames.h" #include "binemul.h" -#include "plugin-api.h" +#if BFD_SUPPORTS_PLUGINS #include "plugin.h" -#include "ansidecl.h" +#endif #ifdef __GO32___ #define EXT_NAME_LEN 3 /* Bufflen of addition to name if it's MS-DOS. */ diff --git a/binutils/configure.ac b/binutils/configure.ac index a393036..93e8a4b 100644 --- a/binutils/configure.ac +++ b/binutils/configure.ac @@ -201,9 +201,9 @@ GCC_AC_FUNC_MMAP AC_CHECK_FUNCS(fseeko fseeko64 getc_unlocked mkdtemp mkstemp utimensat utimes) AC_MSG_CHECKING([for mbstate_t]) -AC_TRY_COMPILE([#include <wchar.h>], -[mbstate_t teststate;], -have_mbstate_t=yes, have_mbstate_t=no) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <wchar.h>]], +[[mbstate_t teststate;]])], +[have_mbstate_t=yes],[have_mbstate_t=no]) AC_MSG_RESULT($have_mbstate_t) if test x"$have_mbstate_t" = xyes; then AC_DEFINE(HAVE_MBSTATE_T,1,[Define if mbstate_t exists in wchar.h.]) diff --git a/binutils/nm.c b/binutils/nm.c index d44083d..a7f0e9d 100644 --- a/binutils/nm.c +++ b/binutils/nm.c @@ -36,9 +36,10 @@ #include "libcoff.h" #include "bucomm.h" #include "demanguse.h" -#include "plugin-api.h" -#include "plugin.h" #include "safe-ctype.h" +#if BFD_SUPPORTS_PLUGINS +#include "plugin.h" +#endif #ifndef streq #define streq(a,b) (strcmp ((a),(b)) == 0) diff --git a/binutils/objcopy.c b/binutils/objcopy.c index 3404bec..654d2b9 100644 --- a/binutils/objcopy.c +++ b/binutils/objcopy.c @@ -30,8 +30,9 @@ #include "coff/internal.h" #include "libcoff.h" #include "safe-ctype.h" -#include "plugin-api.h" +#if BFD_SUPPORTS_PLUGINS #include "plugin.h" +#endif /* FIXME: See bfd/peXXigen.c for why we include an architecture specific header in generic PE code. */ diff --git a/gas/acinclude.m4 b/gas/acinclude.m4 index bf6dba6..b6345d5 100644 --- a/gas/acinclude.m4 +++ b/gas/acinclude.m4 @@ -2,12 +2,12 @@ dnl GAS_CHECK_DECL_NEEDED(name, typedefname, typedef, headers) AC_DEFUN([GAS_CHECK_DECL_NEEDED],[ AC_MSG_CHECKING(whether declaration is required for $1) AC_CACHE_VAL(gas_cv_decl_needed_$1, -AC_TRY_LINK([$4], -[ +AC_LINK_IFELSE([AC_LANG_PROGRAM([[$4]], +[[ typedef $3; $2 x; x = ($2) $1; -], gas_cv_decl_needed_$1=no, gas_cv_decl_needed_$1=yes))dnl +]])],[gas_cv_decl_needed_$1=no], [gas_cv_decl_needed_$1=yes]))dnl AC_MSG_RESULT($gas_cv_decl_needed_$1) if test $gas_cv_decl_needed_$1 = yes; then AC_DEFINE([NEED_DECLARATION_]translit($1, [a-z], [A-Z]), 1, @@ -22,9 +22,9 @@ dnl GAS_WORKING_ASSERT AC_DEFUN([GAS_WORKING_ASSERT], [AC_MSG_CHECKING([for working assert macro]) AC_CACHE_VAL(gas_cv_assert_ok, -AC_TRY_LINK([#include <assert.h> +AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <assert.h> #include <string.h> -#include <stdio.h>], [ +#include <stdio.h>]], [[ /* check for requoting problems */ static int a, b, c, d; static char *s; @@ -32,7 +32,7 @@ assert (!strcmp(s, "foo bar baz quux")); /* check for newline handling */ assert (a == b || c == d); -], gas_cv_assert_ok=yes, gas_cv_assert_ok=no))dnl +]])],[gas_cv_assert_ok=yes], [gas_cv_assert_ok=no]))dnl AC_MSG_RESULT($gas_cv_assert_ok) test $gas_cv_assert_ok = yes || AC_DEFINE(BROKEN_ASSERT, 1, [assert broken?]) ])dnl @@ -61,12 +61,12 @@ dnl AC_DEFUN([GAS_HAVE_TIME_TYPE_MEMBER], [AC_MSG_CHECKING([for $1.$2 in time.h]) AC_CACHE_VAL(gas_cv_have_time_type_member_$2, - [AC_TRY_COMPILE([ + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #define _BSD_SOURCE 1 -#include <time.h>], - [$1 avar; void* aref = (void*) &avar.$2], - gas_cv_have_time_type_member_$2=yes, - gas_cv_have_time_type_member_$2=no +#include <time.h>]], + [[$1 avar; void* aref = (void*) &avar.$2]])], + [gas_cv_have_time_type_member_$2=yes], + [gas_cv_have_time_type_member_$2=no] )]) if test $gas_cv_have_time_type_member_$2 = yes; then AC_DEFINE([HAVE_]translit($2, [a-z], [A-Z]), 1, @@ -80,12 +80,12 @@ dnl AC_DEFUN([GAS_HAVE_SYS_STAT_TYPE_MEMBER], [AC_MSG_CHECKING([for $1.$2.$3 in sys/stat.h]) AC_CACHE_VAL(gas_cv_have_sys_stat_type_member_$2_$3, - [AC_TRY_COMPILE([ + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #define _BSD_SOURCE 1 -#include <sys/stat.h>], - [$1 avar; void* aref = (void*) &avar.$2.$3], - gas_cv_have_sys_stat_type_member_$2_$3=yes, - gas_cv_have_sys_stat_type_member_$2_$3=no +#include <sys/stat.h>]], + [[$1 avar; void* aref = (void*) &avar.$2.$3]])], + [gas_cv_have_sys_stat_type_member_$2_$3=yes], + [gas_cv_have_sys_stat_type_member_$2_$3=no] )]) if test $gas_cv_have_sys_stat_type_member_$2_$3 = yes; then AC_DEFINE([HAVE_]translit($2, [a-z], [A-Z])[_]translit($3, [a-z], [A-Z]), 1, diff --git a/gas/config/tc-arm.c b/gas/config/tc-arm.c index 99c07d4..217864b 100644 --- a/gas/config/tc-arm.c +++ b/gas/config/tc-arm.c @@ -1474,7 +1474,7 @@ parse_neon_type (struct neon_type *type, char **str) while (type->elems < NEON_MAX_TYPE_ELS) { enum neon_el_type thistype = NT_untyped; - unsigned thissize = -1u; + unsigned long thissize = -1ul; if (*ptr != '.') break; @@ -1505,14 +1505,17 @@ parse_neon_type (struct neon_type *type, char **str) return FAIL; } ptr += 1; + if (!ISDIGIT (*ptr) || *ptr == '0') + goto unexpected; thissize = strtoul (ptr, &ptr, 10); if (thissize != 16) { - as_bad (_("bad size %d in type specifier"), thissize); + as_bad (_("bad size %lu in type specifier"), thissize); return FAIL; } goto done; default: + unexpected: as_bad (_("unexpected character `%c' in type specifier"), *ptr); return FAIL; } @@ -1525,12 +1528,14 @@ parse_neon_type (struct neon_type *type, char **str) else { parsesize: + if (!ISDIGIT (*ptr) || *ptr == '0') + goto unexpected; thissize = strtoul (ptr, &ptr, 10); if (thissize != 8 && thissize != 16 && thissize != 32 && thissize != 64) { - as_bad (_("bad size %d in type specifier"), thissize); + as_bad (_("bad size %lu in type specifier"), thissize); return FAIL; } } @@ -22470,7 +22475,8 @@ opcode_lookup (char **str) if (parse_neon_type (&inst.vectype, str) == FAIL) return NULL; } - else if (end[offset] != '\0' && !is_whitespace (end[offset])) + + if (**str != '\0' && !is_whitespace (**str)) return NULL; } else diff --git a/gas/testsuite/gas/arm/neon-suffix-bad.d b/gas/testsuite/gas/arm/neon-suffix-bad.d index 7e3bdfe..3ffa493 100644 --- a/gas/testsuite/gas/arm/neon-suffix-bad.d +++ b/gas/testsuite/gas/arm/neon-suffix-bad.d @@ -1,3 +1,3 @@ -# name: Bad suffix for non-Neon mnemonic +# name: Bad suffix for (non-)Neon mnemonic # as: -mfpu=neon # error_output: neon-suffix-bad.l diff --git a/gas/testsuite/gas/arm/neon-suffix-bad.l b/gas/testsuite/gas/arm/neon-suffix-bad.l index 091429d..234d95f 100644 --- a/gas/testsuite/gas/arm/neon-suffix-bad.l +++ b/gas/testsuite/gas/arm/neon-suffix-bad.l @@ -7,3 +7,24 @@ [^:]*:10: Error: invalid neon suffix for non neon instruction [^:]*:11: Error: invalid neon suffix for non neon instruction [^:]*:12: Error: invalid instruction shape -- `vcvt.f64.s32 d0,s0,#11' +[^:]*:19: Error: unexpected character `0' .* +#?[^:]*:19: Error: .* +[^:]*:20: Error: unexpected character `0' .* +#?[^:]*:20: Error: .* +[^:]*:22: Error: unexpected character `-' .* +#?[^:]*:22: Error: .* +[^:]*:23: Error: bad instruction .* +[^:]*:25: Error: bad size .* +#?[^:]*:25: Error: .* +[^:]*:26: Error: bad size .* +#?[^:]*:26: Error: .* +[^:]*:28: Error: unexpected type character `b' .* +#?[^:]*:28: Error: .* +[^:]*:29: Error: unexpected character ` ' .* +#?[^:]*:29: Error: .* +[^:]*:30: Error: .* register expected .* +[^:]*:31: Error: unexpected character ` ' .* +#?[^:]*:31: Error: .* +[^:]*:32: Error: .* register expected .* +[^:]*:34: Error: bad instruction .* +[^:]*:35: Error: bad instruction .* diff --git a/gas/testsuite/gas/arm/neon-suffix-bad.s b/gas/testsuite/gas/arm/neon-suffix-bad.s index 20c60fe..50360f9 100644 --- a/gas/testsuite/gas/arm/neon-suffix-bad.s +++ b/gas/testsuite/gas/arm/neon-suffix-bad.s @@ -11,3 +11,25 @@ faddd.f32 d0, d0, d0 faddd.f64 d0, d0, d0 vcvt.f64.s32 d0, s0, #11 + .arm + .arch armv8.6-a + .arch_extension simd + vcvt.bf16.f32 d0, q0 @ good, for reference + + vcvt.bf016.f32 d0, q0 + vcvt.bf16.f032 d0, q0 + + vcvt.bf-4294967280.f32 d0, q0 + vcvt.bf16.f-4294967264 d0, q0 + + vcvt.bf4294967312.f32 d0, q0 + vcvt.bf16.f4294967328 d0, q0 + + vcvt.b f16.f32 d0, q0 + vcvt.bf 16.f32 d0, q0 + vcvt.bf16 .f32 d0, q0 + vcvt.bf16. f32 d0, q0 + vcvt.bf16.f 32 d0, q0 + + vcvt.bf16.f32d0, q0 + vcvt.bf16.fd0, q0 diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index f97c98e..21a5a28 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -8977,41 +8977,12 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) tdep->num_core_regs = I386_NUM_GREGS + I387_NUM_REGS; tdep->register_names = i386_register_names; - /* No upper YMM registers. */ - tdep->ymmh_register_names = NULL; - tdep->ymm0h_regnum = -1; - - /* No upper ZMM registers. */ - tdep->zmmh_register_names = NULL; - tdep->zmm0h_regnum = -1; - - /* No high XMM registers. */ - tdep->xmm_avx512_register_names = NULL; - tdep->xmm16_regnum = -1; - - /* No upper YMM16-31 registers. */ - tdep->ymm16h_register_names = NULL; - tdep->ymm16h_regnum = -1; - tdep->num_byte_regs = 8; tdep->num_word_regs = 8; tdep->num_dword_regs = 0; tdep->num_mmx_regs = 8; tdep->num_ymm_regs = 0; - /* No AVX512 registers. */ - tdep->k0_regnum = -1; - tdep->num_zmm_regs = 0; - tdep->num_ymm_avx512_regs = 0; - tdep->num_xmm_avx512_regs = 0; - - /* No PKEYS registers */ - tdep->pkru_regnum = -1; - tdep->num_pkeys_regs = 0; - - /* No segment base registers. */ - tdep->fsbase_regnum = -1; - tdesc_arch_data_up tdesc_data = tdesc_data_alloc (); set_gdbarch_relocate_instruction (gdbarch, i386_relocate_instruction); diff --git a/gdb/i386-tdep.h b/gdb/i386-tdep.h index e849b33..e4895b1 100644 --- a/gdb/i386-tdep.h +++ b/gdb/i386-tdep.h @@ -69,56 +69,57 @@ struct i386_gdbarch_tdep : gdbarch_tdep_base size_t sizeof_fpregset = 0; /* Register number for %st(0). The register numbers for the other - registers follow from this one. Set this to -1 to indicate the - absence of an FPU. */ - int st0_regnum = 0; + registers follow from this one. Set this to a value >= 0 if FPU is + present. */ + int st0_regnum = -1; /* Number of MMX registers. */ int num_mmx_regs = 0; - /* Register number for %mm0. Set this to -1 to indicate the absence - of MMX support. */ - int mm0_regnum = 0; + /* Register number for %mm0. Set this to a value >= 0 if MMX is + supported. */ + int mm0_regnum = -1; /* Number of pseudo YMM registers. */ int num_ymm_regs = 0; - /* Register number for %ymm0. Set this to -1 to indicate the absence - of pseudo YMM register support. */ - int ymm0_regnum = 0; + /* Register number for %ymm0. Set this to a value >= 0 if pseudo YMM + registers are supported. */ + int ymm0_regnum = -1; /* Number of AVX512 OpMask registers (K-registers) */ int num_k_regs = 0; - /* Register number for %k0. Set this to -1 to indicate the absence - of AVX512 OpMask register support. */ - int k0_regnum = 0; + /* Register number for %k0. Set this to a value >= 0 if AVX512 OpMask + is supported. */ + int k0_regnum = -1; /* Number of pseudo ZMM registers ($zmm0-$zmm31). */ int num_zmm_regs = 0; - /* Register number for %zmm0. Set this to -1 to indicate the absence - of pseudo ZMM register support. */ - int zmm0_regnum = 0; + /* Register number for %zmm0. Set this to a value >= 0 if pseudo ZMM + registers are supported. */ + int zmm0_regnum = -1; /* Number of byte registers. */ int num_byte_regs = 0; - /* Register pseudo number for %al. */ - int al_regnum = 0; + /* Register pseudo number for %al. If supported, set this to a + value >= 0. */ + int al_regnum = -1; /* Number of pseudo word registers. */ int num_word_regs = 0; - /* Register number for %ax. */ - int ax_regnum = 0; + /* Register number for %ax. If supported, set this to a value >= 0. */ + int ax_regnum = -1; /* Number of pseudo dword registers. */ int num_dword_regs = 0; - /* Register number for %eax. Set this to -1 to indicate the absence - of pseudo dword register support. */ - int eax_regnum = 0; + /* Register number for %eax. Set this to a value >= 0 if pseudo dword + registers are supported. */ + int eax_regnum = -1; /* Number of core registers. */ int num_core_regs = 0; @@ -129,14 +130,16 @@ struct i386_gdbarch_tdep : gdbarch_tdep_base /* Number of SSE registers added in AVX512. */ int num_xmm_avx512_regs = 0; - /* Register number of XMM16, the first XMM register added in AVX512. */ - int xmm16_regnum = 0; + /* Register number of XMM16, the first XMM register added in AVX512. + Set this to a value >= 0 if XMM registers are supported. */ + int xmm16_regnum = -1; /* Number of YMM registers added in AVX512. */ int num_ymm_avx512_regs = 0; - /* Register number of YMM16, the first YMM register added in AVX512. */ - int ymm16_regnum = 0; + /* Register number of YMM16, the first YMM register added in AVX512. + Set this to a value >= 0 if YMM registers are supported. */ + int ymm16_regnum = -1; /* Bits of the extended control register 0 (the XFEATURE_ENABLED_MASK register), excluding the x87 bit, which are supported by this GDB. */ @@ -152,23 +155,23 @@ struct i386_gdbarch_tdep : gdbarch_tdep_base /* Register names. */ const char * const *register_names = nullptr; - /* Register number for %ymm0h. Set this to -1 to indicate the absence - of upper YMM register support. */ - int ymm0h_regnum = 0; + /* Register number for %ymm0h. Set this to a value >= 0 if they are + supported. */ + int ymm0h_regnum = -1; /* Upper YMM register names. Only used for tdesc_numbered_register. */ const char * const *ymmh_register_names = nullptr; - /* Register number for %ymm16h. Set this to -1 to indicate the absence - of support for YMM16-31. */ - int ymm16h_regnum = 0; + /* Register number for %ymm16h. Set this to a value >= 0 if they are + supported. */ + int ymm16h_regnum = -1; /* YMM16-31 register names. Only used for tdesc_numbered_register. */ const char * const *ymm16h_register_names = nullptr; - /* Register number for %zmm0h. Set this to -1 to indicate the absence - of ZMM_HI256 register support. */ - int zmm0h_regnum = 0; + /* Register number for %zmm0h. Set this to a value >= 0 if ZMM_HI256 + registers are supported. */ + int zmm0h_regnum = -1; /* OpMask register names. */ const char * const *k_register_names = nullptr; @@ -185,15 +188,16 @@ struct i386_gdbarch_tdep : gdbarch_tdep_base /* Number of PKEYS registers. */ int num_pkeys_regs = 0; - /* Register number for PKRU register. */ - int pkru_regnum = 0; + /* Register number for PKRU register. If supported, set this to a value + >= 0. */ + int pkru_regnum = -1; /* PKEYS register names. */ const char * const *pkeys_register_names = nullptr; - /* Register number for %fsbase. Set this to -1 to indicate the - absence of segment base registers. */ - int fsbase_regnum = 0; + /* Register number for %fsbase. If supported, set this to a value + >= 0. */ + int fsbase_regnum = -1; /* Target description. */ const struct target_desc *tdesc = nullptr; diff --git a/gdb/ppc-sysv-tdep.c b/gdb/ppc-sysv-tdep.c index cae5aa6..f872f73 100644 --- a/gdb/ppc-sysv-tdep.c +++ b/gdb/ppc-sysv-tdep.c @@ -2060,10 +2060,12 @@ ppc64_sysv_abi_return_value (struct gdbarch *gdbarch, struct value *function, } /* Small character arrays are returned, right justified, in r3. */ - if (valtype->code () == TYPE_CODE_ARRAY + if (tdep->elf_abi == POWERPC_ELF_V1 + && valtype->code () == TYPE_CODE_ARRAY && !valtype->is_vector () && valtype->length () <= 8 - && valtype->target_type ()->code () == TYPE_CODE_INT + && (valtype->target_type ()->code () == TYPE_CODE_INT + || valtype->target_type ()->code () == TYPE_CODE_CHAR) && valtype->target_type ()->length () == 1) { int regnum = tdep->ppc_gp0_regnum + 3; diff --git a/gdb/printcmd.c b/gdb/printcmd.c index 19fbc20..d1cf72d 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -1290,7 +1290,9 @@ should_validate_memtags (gdbarch *gdbarch, struct value *value) return false; /* We do. Check whether it includes any tags. */ - return target_is_address_tagged (gdbarch, value_as_address (value)); + struct type *val_type = value->type (); + const gdb_byte *data = value->contents ().data (); + return target_is_address_tagged (gdbarch, unpack_pointer (val_type, data)); } /* Helper for parsing arguments for print_command_1. */ diff --git a/gdb/testsuite/gdb.ada/return-small-char-array.exp b/gdb/testsuite/gdb.ada/return-small-char-array.exp new file mode 100644 index 0000000..75c781e --- /dev/null +++ b/gdb/testsuite/gdb.ada/return-small-char-array.exp @@ -0,0 +1,40 @@ +# Copyright 2025 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +load_lib "ada.exp" + +require allow_ada_tests + +standard_ada_testfile proc + +if { [gdb_compile_ada $srcfile $binfile executable debug] != "" } { + return -1 +} + +clean_restart $testfile + +set bp_location [gdb_get_line_number "STOP" $testdir/proc.adb] +runto "proc.adb:$bp_location" + +gdb_test "print Value.Name(My_Value)" \ + { = "abcd"} + +# Step into the function. +gdb_test "step 2" \ + "return Of_Value;" + +# and finish. +gdb_test "finish" \ + { = "abcd"} diff --git a/gdb/testsuite/gdb.ada/return-small-char-array/proc.adb b/gdb/testsuite/gdb.ada/return-small-char-array/proc.adb new file mode 100644 index 0000000..b18d9fe --- /dev/null +++ b/gdb/testsuite/gdb.ada/return-small-char-array/proc.adb @@ -0,0 +1,22 @@ +-- Copyright 2025 Free Software Foundation, Inc. +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see <http://www.gnu.org/licenses/>. + +with Value; +procedure Proc is + My_Value : Value.T := "abcd"; +begin + null; -- STOP + My_Value := Value.Name(My_Value); +end; diff --git a/gdb/testsuite/gdb.ada/return-small-char-array/value.adb b/gdb/testsuite/gdb.ada/return-small-char-array/value.adb new file mode 100644 index 0000000..2dd9faa --- /dev/null +++ b/gdb/testsuite/gdb.ada/return-small-char-array/value.adb @@ -0,0 +1,21 @@ +-- Copyright 2025 Free Software Foundation, Inc. +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see <http://www.gnu.org/licenses/>. + +package body Value is + function Name (Of_Value : T) return T is + begin + return Of_Value; + end Name; +end Value; diff --git a/gdb/testsuite/gdb.ada/return-small-char-array/value.ads b/gdb/testsuite/gdb.ada/return-small-char-array/value.ads new file mode 100644 index 0000000..16b171e --- /dev/null +++ b/gdb/testsuite/gdb.ada/return-small-char-array/value.ads @@ -0,0 +1,20 @@ +-- Copyright 2025 Free Software Foundation, Inc. +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see <http://www.gnu.org/licenses/>. + +package Value is + type T is new String (1 .. 4); + + function Name (Of_Value : T) return T; +end; diff --git a/gdb/testsuite/gdb.base/color-prompt.exp b/gdb/testsuite/gdb.base/color-prompt.exp new file mode 100644 index 0000000..c037185 --- /dev/null +++ b/gdb/testsuite/gdb.base/color-prompt.exp @@ -0,0 +1,29 @@ +# Copyright 2025 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# Check using a prompt with color in CLI. + +# Using tuiterm requires setting TERM on host. +require {!is_remote host} + +# We use a tuiterm, which allows us to determine cursor position. +tuiterm_env +Term::clean_restart 8 80 + +# We start with an empty screen, to generate a visible prompt. +Term::gen_prompt + +set tui 0 +source $srcdir/$subdir/../gdb.tui/color-prompt.exp.tcl diff --git a/gdb/testsuite/gdb.base/exprs.exp b/gdb/testsuite/gdb.base/exprs.exp index f703c18..81f6f19 100644 --- a/gdb/testsuite/gdb.base/exprs.exp +++ b/gdb/testsuite/gdb.base/exprs.exp @@ -285,11 +285,14 @@ gdb_test "print v_short + " \ gdb_test "print v_short =}{= 3" \ "A syntax error in expression, near `\\}\\{= 3'\\." +set hs {[^\r\n]} +set re_debug [string cat $hs* {[Ss]hift} $hs*] + gdb_test_no_output "set debug parse 1" set saw_start 0 set saw_val 0 gdb_test_multiple "print 23" "print with debugging" -lbl { - -re "\r\nStarting parse(?=\r\n)" { + -re "\r\n${re_debug}(?=\r\n)" { set saw_start 1 exp_continue } diff --git a/gdb/testsuite/gdb.cp/method-ref-return.cc b/gdb/testsuite/gdb.cp/method-ref-return.cc new file mode 100644 index 0000000..4169bfe --- /dev/null +++ b/gdb/testsuite/gdb.cp/method-ref-return.cc @@ -0,0 +1,42 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2025 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +/* Test that we can access class method/data member via reference. */ + +struct foo +{ + foo () : m_a (42) {} + int get_a () const { return m_a; } + int m_a; +}; + +struct bar +{ + bar () : m_foo () {} + const foo &get_foo () const { return m_foo; } + foo m_foo; +}; + +int +main (int argc, char *argv[]) +{ + bar b; + const foo &ref = b.get_foo (); + int ret = ref.m_a; // breakpoint here + ret += ref.get_a (); + return ret; +}
\ No newline at end of file diff --git a/gdb/testsuite/gdb.cp/method-ref-return.exp b/gdb/testsuite/gdb.cp/method-ref-return.exp new file mode 100644 index 0000000..1ac5ac9 --- /dev/null +++ b/gdb/testsuite/gdb.cp/method-ref-return.exp @@ -0,0 +1,70 @@ +# Copyright 2025 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# Test calling methods and accessing members via reference. + +require allow_cplus_tests + +standard_testfile .cc + +if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} { + return -1 +} + +if {![runto_main]} { + return -1 +} + +# Set a breakpoint after the bar object is created and the reference is obtained. +gdb_breakpoint [gdb_get_line_number "breakpoint here"] +gdb_continue_to_breakpoint "after reference assignment" + +# Test that we can call the method through reference and get the expected result. +gdb_test_multiple "print b.get_foo()" "print method call returning reference" { + -re "\\$\[0-9\]+ = \\(const foo &\\) @$hex: \\{m_a = 42\\}\r\n$gdb_prompt $" { + pass $gdb_test_name + } + -re "Could not validate memory tag: Value can't be converted to integer\\." { + fail "$gdb_test_name" + } +} + +# Test accessing the member through the reference. +gdb_test "print b.get_foo ().m_a" \ + "\\$\[0-9\]+ = 42" \ + "print member access through reference" + +# Test calling method on the referenced object. +gdb_test "print b.get_foo ().get_a()" \ + "\\$\[0-9\]+ = 42" \ + "print method call on referenced object" + +# Test that the stored reference works correctly. +gdb_test_multiple "print ref" "print stored reference" { + -re "\\$\[0-9\]+ = \\(const foo &\\) @$hex: \\{m_a = 42\\}\r\n$gdb_prompt $" { + pass $gdb_test_name + } + -re "Could not validate memory tag: Value can't be converted to integer\\." { + fail "$gdb_test_name" + } +} + +gdb_test "print ref.m_a" \ + "\\$\[0-9\]+ = 42" \ + "print member through stored reference" + +gdb_test "print ref.get_a()" \ + "\\$\[0-9\]+ = 42" \ + "print method call through stored reference"
\ No newline at end of file diff --git a/gdb/testsuite/gdb.tui/basic.exp b/gdb/testsuite/gdb.tui/basic.exp index 35c99bd..48b90da 100644 --- a/gdb/testsuite/gdb.tui/basic.exp +++ b/gdb/testsuite/gdb.tui/basic.exp @@ -112,5 +112,9 @@ set re_noattr "\[^<\]" set status_window_line 15 set status [Term::get_line_with_attrs $status_window_line] -gdb_assert { [regexp "^<reverse:1>$re_noattr*<reverse:0>$" $status] == 1} \ +verbose -log "status line: '$status'" + +# The status line uses standout, which may translate to different attributes +# depending on the terminal settings. Just check for at least one attribute. +gdb_assert { [regexp "^<.*>exec" $status] == 1 } \ "status window: reverse" diff --git a/gdb/testsuite/gdb.tui/color-prompt.exp b/gdb/testsuite/gdb.tui/color-prompt.exp index a95b24a..af6e467 100644 --- a/gdb/testsuite/gdb.tui/color-prompt.exp +++ b/gdb/testsuite/gdb.tui/color-prompt.exp @@ -15,18 +15,16 @@ # Check using a prompt with color in TUI. +require allow_tui_tests + tuiterm_env Term::clean_restart 24 80 -# Set colored prompt. if {![Term::enter_tui]} { unsupported "TUI not supported" return } -Term::command "set prompt \\033\[31m(gdb) \\033\[0m" - -set line [Term::get_line_with_attrs $Term::_cur_row] -gdb_assert { [regexp "^<fg:red>$gdb_prompt <fg:default> *$" $line] } \ - "prompt with color" +set tui 1 +source $srcdir/$subdir/color-prompt.exp.tcl diff --git a/gdb/testsuite/gdb.tui/color-prompt.exp.tcl b/gdb/testsuite/gdb.tui/color-prompt.exp.tcl new file mode 100644 index 0000000..e6f4d3b --- /dev/null +++ b/gdb/testsuite/gdb.tui/color-prompt.exp.tcl @@ -0,0 +1,80 @@ +# Copyright 2025 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# Check using a prompt with color in TUI ($tui == 0) or CLI ($tui == 0). + +set csi [string cat {\033} "\["] +set rl_prompt_start_ignore {\001} +set rl_prompt_end_ignore {\002} + +foreach_with_prefix rl_prompt_start_end_ignore { 0 1 } { + set color_on [string cat $csi 31m] + set color_off [string cat $csi 0m] + + if { $rl_prompt_start_end_ignore } { + set color_on \ + [string cat \ + $rl_prompt_start_ignore \ + $color_on \ + $rl_prompt_end_ignore] + set color_off \ + [string cat \ + $rl_prompt_start_ignore \ + $color_off \ + $rl_prompt_end_ignore] + } + + # Set prompt with color. + set prompt "${color_on}(gdb) $color_off" + Term::command "set prompt $prompt" + + # Check the color. + set line [Term::get_line_with_attrs $Term::_cur_row] + gdb_assert { [regexp "^<fg:red>$gdb_prompt <fg:default> *$" $line] } \ + "prompt with color" + + # Type a string. + set cmd "some long command" + send_gdb $cmd + Term::wait_for_line ^[string_to_regexp "(gdb) $cmd"] 23 + + # Send ^A, aka C-a, trigger beginning-of-line. + send_gdb "\001" + if { $tui || $rl_prompt_start_end_ignore } { + Term::wait_for_line ^[string_to_regexp "(gdb) $cmd"] 6 + } else { + # Without the markers, readline may get the cursor position wrong, so + # match less strict. + Term::wait_for_line ^[string_to_regexp "(gdb) $cmd"] + } + Term::dump_screen + + # Type something else to flush out the effect of the ^A. + set prefix "A" + send_gdb $prefix + if { $tui || $rl_prompt_start_end_ignore } { + Term::wait_for_line ^[string_to_regexp "(gdb) $prefix$cmd"] 7 + } else { + # Without the markers, readline may get the cursor position wrong, so + # match less strict. + Term::wait_for_line [string_to_regexp "$prefix"] + } + + # Abort command line editing, and regenerate prompt. + send_gdb "\003" + + # Reset prompt to default prompt. + Term::command "set prompt (gdb) " +} diff --git a/gdb/testsuite/gdb.tui/main-2.exp b/gdb/testsuite/gdb.tui/main-2.exp index 71ad03b..14a7cb1 100644 --- a/gdb/testsuite/gdb.tui/main-2.exp +++ b/gdb/testsuite/gdb.tui/main-2.exp @@ -41,7 +41,7 @@ if {![Term::enter_tui]} { set line " return 0;" set nr [gdb_get_line_number $line] -set screen_line [Term::get_string_with_attrs 6 1 79] +set screen_line [Term::get_string_with_attrs 6 11 79] verbose -log "screen line 6: '$screen_line'" -gdb_assert { [regexp "$nr <reverse:1>$line<reverse:0>" $screen_line] } \ +gdb_assert { [regexp "<reverse:1>$line<reverse:0>" $screen_line] } \ "highlighted line in middle of source window" diff --git a/gdb/testsuite/gdb.tui/tui-layout-asm-short-prog.exp b/gdb/testsuite/gdb.tui/tui-layout-asm-short-prog.exp index 51623e8..47482a2 100644 --- a/gdb/testsuite/gdb.tui/tui-layout-asm-short-prog.exp +++ b/gdb/testsuite/gdb.tui/tui-layout-asm-short-prog.exp @@ -20,9 +20,13 @@ tuiterm_env standard_testfile tui-layout-asm-short-prog.S -if {[build_executable "failed to prepare" ${testfile} ${srcfile} \ - {debug additional_flags=-nostdlib \ - additional_flags=-nostartfiles}] == -1} { +set opts {} +lappend opts debug +lappend opts additional_flags=-static +lappend opts additional_flags=-nostdlib +lappend opts additional_flags=-nostartfiles + +if { [build_executable "failed to prepare" $testfile $srcfile $opts] == -1 } { return -1 } diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp index b83b8af..f4a8702 100644 --- a/gdb/testsuite/lib/tuiterm.exp +++ b/gdb/testsuite/lib/tuiterm.exp @@ -92,7 +92,9 @@ namespace eval Term { # Return 1 if tuiterm has the bw/auto_left_margin enabled. proc _have_bw {} { - return [string equal $Term::_TERM "ansiw"] + return [expr \ + [string equal $Term::_TERM "ansiw"] \ + || [string equal $Term::_TERM "ansis"]] } # Backspace. @@ -701,6 +703,14 @@ namespace eval Term { } } + # Request Terminal Parameters (DECREQTPARM) + # + # https://invisible-island.net/xterm/ctlseqs/ctlseqs.html + # https://vt100.net/docs/vt100-ug/chapter3.html + proc _csi_x {} { + # Ignore. + } + # Insert string at the cursor location. proc _insert {str} { _log_cur "Inserted string '$str'" { @@ -886,6 +896,31 @@ namespace eval Term { return 1 } + # Accept some output from gdb and update the screen. Wait for the current + # screen line to match REGEXP and cursor position POS, unless POS is empty. + # Return 0 on timeout, 1 on success. + proc wait_for_line { regexp {pos ""} } { + variable _cur_row + variable _cur_col + variable _cols + + while 1 { + if { [accept_gdb_output] == 0 } { + return 0 + } + + if { ![check_region_contents_p 0 $_cur_row $_cols 1 $regexp] } { + continue + } + + if { $pos == "" || $_cur_col == $pos } { + break + } + } + + return 1 + } + # Setup the terminal with dimensions ROWSxCOLS, TERM=ansi, and execute # BODY. proc with_tuiterm {rows cols body} { diff --git a/gprof/configure.ac b/gprof/configure.ac index 94486ed..85502ec 100644 --- a/gprof/configure.ac +++ b/gprof/configure.ac @@ -86,6 +86,7 @@ AC_CACHE_CHECK([whether gprof tests can run], fi]) AM_CONDITIONAL(NATIVE, test "$gprof_cv_sys_native" = "yes") -AC_OUTPUT(Makefile testsuite/Makefile po/Makefile.in:po/Make-in) +AC_CONFIG_FILES([Makefile testsuite/Makefile po/Makefile.in:po/Make-in]) +AC_OUTPUT GNU_MAKE_JOBSERVER diff --git a/ld/ldfile.c b/ld/ldfile.c index 75fd360..e642c7f 100644 --- a/ld/ldfile.c +++ b/ld/ldfile.c @@ -36,7 +36,6 @@ #include "filenames.h" #include <fnmatch.h> #if BFD_SUPPORTS_PLUGINS -#include "plugin-api.h" #include "plugin.h" #endif /* BFD_SUPPORTS_PLUGINS */ diff --git a/ld/ldlang.c b/ld/ldlang.c index 6e31c35..fc7a7d2 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -44,14 +44,10 @@ #include "elf-bfd.h" #include "bfdver.h" #include <errno.h> - #if BFD_SUPPORTS_PLUGINS #include "plugin.h" #endif -/* FIXME: Put it here to avoid NAME conflict from ldgram.h. */ -#include "elf-bfd.h" - #ifndef offsetof #define offsetof(TYPE, MEMBER) ((size_t) & (((TYPE*) 0)->MEMBER)) #endif diff --git a/ld/ldmain.c b/ld/ldmain.c index 67c60c3..13b8e3d 100644 --- a/ld/ldmain.c +++ b/ld/ldmain.c @@ -42,7 +42,6 @@ #include "ldctor.h" #if BFD_SUPPORTS_PLUGINS #include "plugin.h" -#include "plugin-api.h" #endif /* BFD_SUPPORTS_PLUGINS */ /* Somewhere above, sys/stat.h got included. */ diff --git a/ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp b/ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp index e23cdc8..a33727f 100644 --- a/ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp +++ b/ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp @@ -48,6 +48,8 @@ if [istarget "loongarch64-*-*"] { run_dump_test "relax-after-alignment" run_dump_test "relax-medium-call" run_dump_test "relax-medium-call-1" + run_dump_test "relax-sym-size-1" + run_dump_test "relax-sym-size-2" run_dump_test "check_got_relax" } diff --git a/ld/testsuite/ld-loongarch-elf/relax-sym-size-1.d b/ld/testsuite/ld-loongarch-elf/relax-sym-size-1.d new file mode 100644 index 0000000..eec989f --- /dev/null +++ b/ld/testsuite/ld-loongarch-elf/relax-sym-size-1.d @@ -0,0 +1,7 @@ +#source: relax-sym-size-1.s +#ld: +#readelf: -s + +#... + *[0-9]+: [0-9a-z]+ +8 .* _start +#... diff --git a/ld/testsuite/ld-loongarch-elf/relax-sym-size-1.s b/ld/testsuite/ld-loongarch-elf/relax-sym-size-1.s new file mode 100644 index 0000000..c70ac71 --- /dev/null +++ b/ld/testsuite/ld-loongarch-elf/relax-sym-size-1.s @@ -0,0 +1,8 @@ +.p2align 2 +bar: + nop +.globl _start +_start: + la.pcrel $a0, bar + ret +.size _start, . - _start diff --git a/ld/testsuite/ld-loongarch-elf/relax-sym-size-2.d b/ld/testsuite/ld-loongarch-elf/relax-sym-size-2.d new file mode 100644 index 0000000..1388099 --- /dev/null +++ b/ld/testsuite/ld-loongarch-elf/relax-sym-size-2.d @@ -0,0 +1,7 @@ +#source: relax-sym-size-2.s +#ld: +#readelf: -s + +#... + *[0-9]+: [0-9a-z]+ +64 .* _start +#... diff --git a/ld/testsuite/ld-loongarch-elf/relax-sym-size-2.s b/ld/testsuite/ld-loongarch-elf/relax-sym-size-2.s new file mode 100644 index 0000000..e02e16b --- /dev/null +++ b/ld/testsuite/ld-loongarch-elf/relax-sym-size-2.s @@ -0,0 +1,19 @@ +bar: + nop +.p2align 6 + +.reloc ., R_LARCH_ALIGN, 60 +.rept 15 + 1: nop +.endr + la.pcrel $a0, bar + ret + +.reloc ., R_LARCH_ALIGN, 60 +.rept 15 + 2: nop +.endr + +.globl _start +.set _start, 1b +.size _start, 2b - 1b diff --git a/ld/testsuite/ld-plugin/lto-binutils.exp b/ld/testsuite/ld-plugin/lto-binutils.exp index de017f0..4970e22 100644 --- a/ld/testsuite/ld-plugin/lto-binutils.exp +++ b/ld/testsuite/ld-plugin/lto-binutils.exp @@ -125,7 +125,7 @@ proc run_lto_binutils_test { lto_tests } { objdump { set dump_prog $objdump } nm - { set dump_prog $nm } + { set dump_prog "$nm $plug_opt" } readelf { set dump_prog $READELF } default diff --git a/libctf/configure.ac b/libctf/configure.ac index 40d00e8..62e6225 100644 --- a/libctf/configure.ac +++ b/libctf/configure.ac @@ -98,12 +98,12 @@ LDFLAGS="-L../bfd -L../libiberty $LDFLAGS" intl=`echo $LIBINTL | sed 's,${top_builddir}/,,g'` LIBS="-lbfd -liberty $intl $LIBS" AC_CACHE_CHECK([for ELF support in BFD], ac_cv_libctf_bfd_elf, -[AC_TRY_LINK([#include <stdlib.h> +[AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h> #include <string.h> #include "bfd.h" - #include "elf-bfd.h"], - [(void) bfd_section_from_elf_index (NULL, 0); - return 0;], + #include "elf-bfd.h"]], + [[(void) bfd_section_from_elf_index (NULL, 0); + return 0;]])], [ac_cv_libctf_bfd_elf=yes], [ac_cv_libctf_bfd_elf=no])]) CFLAGS=$OLD_CFLAGS diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog index 2ae5626..b072d0b 100644 --- a/libiberty/ChangeLog +++ b/libiberty/ChangeLog @@ -1,3 +1,14 @@ +2025-08-06 Matthieu Longo <matthieu.longo@arm.com> + + * testsuite/test-doubly-linked-list.c: disable debug logging on + stdout. + +2025-07-09 Matthieu Longo <matthieu.longo@arm.com> + + * Makefile.in: Add new header. + * testsuite/Makefile.in: Add new test. + * testsuite/test-doubly-linked-list.c: New test. + 2025-05-13 Andreas Schwab <schwab@suse.de> * regex.c (regex_compile): Don't write beyond array bounds when diff --git a/libiberty/testsuite/test-doubly-linked-list.c b/libiberty/testsuite/test-doubly-linked-list.c index 1e1fc63..93fe19a 100644 --- a/libiberty/testsuite/test-doubly-linked-list.c +++ b/libiberty/testsuite/test-doubly-linked-list.c @@ -155,19 +155,26 @@ bool check(const char *op, bool success = true; bool res; - l_print (wrapper->first); +#define DUMP_LIST 0 + + if (DUMP_LIST) + l_print (wrapper->first); + res = run_test (expect, wrapper, false); printf ("%s: test-linked-list::%s: check forward conformity\n", res ? "PASS": "FAIL", op); success &= res; - l_reverse_print (wrapper->last); + if (DUMP_LIST) + l_reverse_print (wrapper->last); + res = run_test (expect, wrapper, true); printf ("%s: test-linked-list::%s: check backward conformity\n", res ? "PASS": "FAIL", op); success &= res; - printf("\n"); + if (DUMP_LIST) + printf("\n"); return success; } diff --git a/opcodes/aarch64-asm.c b/opcodes/aarch64-asm.c index a9d0aeb..75216fd 100644 --- a/opcodes/aarch64-asm.c +++ b/opcodes/aarch64-asm.c @@ -40,7 +40,6 @@ static inline void insert_fields (aarch64_insn *code, aarch64_insn value, aarch64_insn mask, ...) { uint32_t num; - const aarch64_field *field; enum aarch64_field_kind kind; va_list va; @@ -50,9 +49,8 @@ insert_fields (aarch64_insn *code, aarch64_insn value, aarch64_insn mask, ...) while (num--) { kind = va_arg (va, enum aarch64_field_kind); - field = &fields[kind]; insert_field (kind, code, value, mask); - value >>= field->width; + value >>= aarch64_fields[kind].width; } va_end (va); } @@ -72,7 +70,7 @@ insert_all_fields_after (const aarch64_operand *self, unsigned int start, { kind = self->fields[i]; insert_field (kind, code, value, 0); - value >>= fields[kind].width; + value >>= aarch64_fields[kind].width; } } diff --git a/opcodes/aarch64-dis.c b/opcodes/aarch64-dis.c index 179addc..3ca22bb 100644 --- a/opcodes/aarch64-dis.c +++ b/opcodes/aarch64-dis.c @@ -149,7 +149,6 @@ aarch64_insn extract_fields (aarch64_insn code, aarch64_insn mask, ...) { uint32_t num; - const aarch64_field *field; enum aarch64_field_kind kind; va_list va; @@ -160,8 +159,7 @@ extract_fields (aarch64_insn code, aarch64_insn mask, ...) while (num--) { kind = va_arg (va, enum aarch64_field_kind); - field = &fields[kind]; - value <<= field->width; + value <<= aarch64_fields[kind].width; value |= extract_field (kind, code, mask); } va_end (va); @@ -184,7 +182,7 @@ extract_all_fields_after (const aarch64_operand *self, unsigned int start, i < ARRAY_SIZE (self->fields) && self->fields[i] != FLD_NIL; ++i) { kind = self->fields[i]; - value <<= fields[kind].width; + value <<= aarch64_fields[kind].width; value |= extract_field (kind, code, 0); } return value; @@ -503,21 +501,21 @@ aarch64_ext_ldst_reglist (const aarch64_operand *self ATTRIBUTE_UNUSED, static const struct { - unsigned is_reserved; - unsigned num_regs; - unsigned num_elements; + unsigned num_regs:8; + unsigned num_elements:8; + bool is_reserved:1; } data [] = - { {0, 4, 4}, - {1, 4, 4}, - {0, 4, 1}, - {0, 4, 2}, - {0, 3, 3}, - {1, 3, 3}, - {0, 3, 1}, - {0, 1, 1}, - {0, 2, 2}, - {1, 2, 2}, - {0, 2, 1}, + { {4, 4, false}, + {4, 4, true}, + {4, 1, false}, + {4, 2, false}, + {3, 3, false}, + {3, 3, true}, + {3, 1, false}, + {1, 1, false}, + {2, 2, false}, + {2, 2, true}, + {2, 1, false}, }; /* Rt */ @@ -1240,7 +1238,8 @@ aarch64_ext_addr_simm (const aarch64_operand *self, aarch64_opnd_info *info, info->addr.base_regno = extract_field (FLD_Rn, code, 0); /* simm (imm9 or imm7) */ imm = extract_field (self->fields[0], code, 0); - info->addr.offset.imm = sign_extend (imm, fields[self->fields[0]].width - 1); + info->addr.offset.imm + = sign_extend (imm, aarch64_fields[self->fields[0]].width - 1); if (self->fields[0] == FLD_imm7 || info->qualifier == AARCH64_OPND_QLF_imm_tag) /* scaled immediate in ld/st pair instructions. */ diff --git a/opcodes/aarch64-opc.c b/opcodes/aarch64-opc.c index f7dae4b..5980841 100644 --- a/opcodes/aarch64-opc.c +++ b/opcodes/aarch64-opc.c @@ -223,7 +223,7 @@ aarch64_select_operand_for_sizeq_field_coding (const aarch64_opcode *opcode) /* Instruction bit-fields. + Keep synced with 'enum aarch64_field_kind'. */ -const aarch64_field fields[] = +const aarch64_field aarch64_fields[] = { { 0, 0 }, /* NIL. */ { 8, 4 }, /* CRm: in the system instructions. */ diff --git a/opcodes/aarch64-opc.h b/opcodes/aarch64-opc.h index d46c56d..68e297f 100644 --- a/opcodes/aarch64-opc.h +++ b/opcodes/aarch64-opc.h @@ -251,7 +251,7 @@ struct aarch64_field typedef struct aarch64_field aarch64_field; -extern const aarch64_field fields[]; +extern const aarch64_field aarch64_fields[]; /* Operand description. */ @@ -427,7 +427,7 @@ static inline unsigned get_operand_field_width (const aarch64_operand *operand, unsigned n) { assert (operand->fields[n] != FLD_NIL); - return fields[operand->fields[n]].width; + return aarch64_fields[operand->fields[n]].width; } /* Return the total width of the operand *OPERAND. */ @@ -437,7 +437,7 @@ get_operand_fields_width (const aarch64_operand *operand) int i = 0; unsigned width = 0; while (operand->fields[i] != FLD_NIL) - width += fields[operand->fields[i++]].width; + width += aarch64_fields[operand->fields[i++]].width; assert (width > 0 && width < 32); return width; } @@ -482,7 +482,7 @@ gen_mask (int width) static inline int gen_sub_field (enum aarch64_field_kind kind, int lsb_rel, int width, aarch64_field *ret) { - const aarch64_field *field = &fields[kind]; + const aarch64_field *field = &aarch64_fields[kind]; if (lsb_rel < 0 || width <= 0 || lsb_rel + width > field->width) return 0; ret->lsb = field->lsb + lsb_rel; @@ -528,7 +528,7 @@ static inline void insert_field (enum aarch64_field_kind kind, aarch64_insn *code, aarch64_insn value, aarch64_insn mask) { - insert_field_2 (&fields[kind], code, value, mask); + insert_field_2 (&aarch64_fields[kind], code, value, mask); } /* Extract field KIND of CODE and return the value. MASK can be zero or the @@ -538,7 +538,7 @@ static inline aarch64_insn extract_field (enum aarch64_field_kind kind, aarch64_insn code, aarch64_insn mask) { - return extract_field_2 (&fields[kind], code, mask); + return extract_field_2 (&aarch64_fields[kind], code, mask); } extern aarch64_insn diff --git a/opcodes/configure.ac b/opcodes/configure.ac index 783ac2a..675f066 100644 --- a/opcodes/configure.ac +++ b/opcodes/configure.ac @@ -101,10 +101,10 @@ AC_CHECK_DECLS([basename, stpcpy]) # Check if sigsetjmp is available. Using AC_CHECK_FUNCS won't do # since sigsetjmp might only be defined as a macro. AC_CACHE_CHECK([for sigsetjmp], gdb_cv_func_sigsetjmp, -[AC_TRY_COMPILE([ +[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <setjmp.h> -], [sigjmp_buf env; while (! sigsetjmp (env, 1)) siglongjmp (env, 1);], -bfd_cv_func_sigsetjmp=yes, bfd_cv_func_sigsetjmp=no)]) +]], [[sigjmp_buf env; while (! sigsetjmp (env, 1)) siglongjmp (env, 1);]])], +[bfd_cv_func_sigsetjmp=yes], [bfd_cv_func_sigsetjmp=no])]) if test $bfd_cv_func_sigsetjmp = yes; then AC_DEFINE(HAVE_SIGSETJMP, 1, [Define if sigsetjmp is available. ]) fi |