diff options
168 files changed, 1349 insertions, 637 deletions
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 88288e0..488e781 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -69,7 +69,7 @@ repos: rev: v2.4.1 hooks: - id: codespell - files: '^(gdbsupport|gdbserver)/' + files: '^(gdbsupport|gdbserver|gdb/(tui|target|data-directory|po|system-gdbinit|mi|syscalls|arch|regformats|compile|python|guile))/' args: [--config, gdb/contrib/setup.cfg] - repo: local hooks: diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index 7a8318e..ec60f23 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -2913,6 +2913,18 @@ const char *bfd_format_string (bfd_format format); && bfd_is_abs_section ((H)->u.def.section) \ && !(H)->rel_from_abs) +bool _bfd_generic_link_add_one_symbol + (struct bfd_link_info *info, + bfd *abfd, + const char *name, + flagword flags, + asection *section, + bfd_vma value, + const char *string, + bool copy, + bool collect, + struct bfd_link_hash_entry **hashp); + bool bfd_link_align_section (asection *, unsigned int); bool bfd_link_split_section (bfd *abfd, asection *sec); diff --git a/bfd/coff-alpha.c b/bfd/coff-alpha.c index 2798efd..e2f1a4d 100644 --- a/bfd/coff-alpha.c +++ b/bfd/coff-alpha.c @@ -2359,7 +2359,7 @@ static const struct ecoff_backend_data alpha_ecoff_backend_data = alpha_ecoff_mkobject_hook, _bfd_ecoff_styp_to_sec_flags, _bfd_ecoff_set_alignment_hook, _bfd_ecoff_slurp_symbol_table, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL + NULL, NULL, NULL, }, /* Supported architecture. */ bfd_arch_alpha, diff --git a/bfd/coff-arm.c b/bfd/coff-arm.c index ab5f7b0..ee57451 100644 --- a/bfd/coff-arm.c +++ b/bfd/coff-arm.c @@ -1876,8 +1876,8 @@ record_arm_to_thumb_glue (struct bfd_link_info * info, it. */ bh = NULL; val = globals->arm_glue_size + 1; - bfd_coff_link_add_one_symbol (info, globals->bfd_of_glue_owner, tmp_name, - BSF_GLOBAL, s, val, NULL, true, false, &bh); + _bfd_generic_link_add_one_symbol (info, globals->bfd_of_glue_owner, tmp_name, + BSF_GLOBAL, s, val, NULL, true, false, &bh); free (tmp_name); @@ -1929,8 +1929,8 @@ record_thumb_to_arm_glue (struct bfd_link_info * info, bh = NULL; val = globals->thumb_glue_size + 1; - bfd_coff_link_add_one_symbol (info, globals->bfd_of_glue_owner, tmp_name, - BSF_GLOBAL, s, val, NULL, true, false, &bh); + _bfd_generic_link_add_one_symbol (info, globals->bfd_of_glue_owner, tmp_name, + BSF_GLOBAL, s, val, NULL, true, false, &bh); /* If we mark it 'thumb', the disassembler will do a better job. */ myh = (struct coff_link_hash_entry *) bh; @@ -1952,8 +1952,8 @@ record_thumb_to_arm_glue (struct bfd_link_info * info, bh = NULL; val = globals->thumb_glue_size + (globals->support_old_code ? 8 : 4); - bfd_coff_link_add_one_symbol (info, globals->bfd_of_glue_owner, tmp_name, - BSF_LOCAL, s, val, NULL, true, false, &bh); + _bfd_generic_link_add_one_symbol (info, globals->bfd_of_glue_owner, tmp_name, + BSF_LOCAL, s, val, NULL, true, false, &bh); free (tmp_name); diff --git a/bfd/coff-mips.c b/bfd/coff-mips.c index e2c632c..8c4d4f7 100644 --- a/bfd/coff-mips.c +++ b/bfd/coff-mips.c @@ -1316,7 +1316,7 @@ static const struct ecoff_backend_data mips_ecoff_backend_data = _bfd_ecoff_mkobject_hook, _bfd_ecoff_styp_to_sec_flags, _bfd_ecoff_set_alignment_hook, _bfd_ecoff_slurp_symbol_table, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL + NULL, NULL, }, /* Supported architecture. */ bfd_arch_mips, diff --git a/bfd/coff-rs6000.c b/bfd/coff-rs6000.c index 7a20dba..ae9a0f6 100644 --- a/bfd/coff-rs6000.c +++ b/bfd/coff-rs6000.c @@ -4584,7 +4584,6 @@ static const struct xcoff_backend_data_rec bfd_xcoff_backend_data = xcoff_ppc_relocate_section, coff_rtype_to_howto, NULL, /* _bfd_coff_adjust_symndx */ - _bfd_generic_link_add_one_symbol, coff_link_output_has_begun, coff_final_link_postscript, NULL /* print_pdata. */ @@ -4774,7 +4773,6 @@ static const struct xcoff_backend_data_rec bfd_pmac_xcoff_backend_data = xcoff_ppc_relocate_section, coff_rtype_to_howto, NULL, /* _bfd_coff_adjust_symndx */ - _bfd_generic_link_add_one_symbol, coff_link_output_has_begun, coff_final_link_postscript, NULL /* print_pdata. */ diff --git a/bfd/coff-sh.c b/bfd/coff-sh.c index 275c4f5..c3e0e42 100644 --- a/bfd/coff-sh.c +++ b/bfd/coff-sh.c @@ -3108,7 +3108,7 @@ static const bfd_coff_backend_data bfd_coff_small_swap_table = coff_print_aux, coff_reloc16_extra_cases, coff_reloc16_estimate, coff_classify_symbol, coff_compute_section_file_positions, coff_start_final_link, coff_relocate_section, coff_rtype_to_howto, - coff_adjust_symndx, coff_link_add_one_symbol, + coff_adjust_symndx, coff_link_output_has_begun, coff_final_link_postscript, bfd_pe_print_pdata }; diff --git a/bfd/coff64-rs6000.c b/bfd/coff64-rs6000.c index 5a4bcbf..ec7ed08 100644 --- a/bfd/coff64-rs6000.c +++ b/bfd/coff64-rs6000.c @@ -2495,7 +2495,6 @@ static const struct xcoff_backend_data_rec bfd_xcoff_backend_data = xcoff64_ppc_relocate_section, coff_rtype_to_howto, NULL, /* _bfd_coff_adjust_symndx */ - _bfd_generic_link_add_one_symbol, coff_link_output_has_begun, coff_final_link_postscript, NULL /* print_pdata. */ @@ -2768,7 +2767,6 @@ static const struct xcoff_backend_data_rec bfd_xcoff_aix5_backend_data = xcoff64_ppc_relocate_section, coff_rtype_to_howto, NULL, /* _bfd_coff_adjust_symndx */ - _bfd_generic_link_add_one_symbol, coff_link_output_has_begun, coff_final_link_postscript, NULL /* print_pdata. */ diff --git a/bfd/coffcode.h b/bfd/coffcode.h index 325a8ab..bd0374f 100644 --- a/bfd/coffcode.h +++ b/bfd/coffcode.h @@ -1516,11 +1516,6 @@ CODE_FRAGMENT . (bfd *, struct bfd_link_info *, bfd *, asection *, . struct internal_reloc *, bool *); . -. bool (*_bfd_coff_link_add_one_symbol) -. (struct bfd_link_info *, bfd *, const char *, flagword, -. asection *, bfd_vma, const char *, bool, bool, -. struct bfd_link_hash_entry **); -. . bool (*_bfd_coff_link_output_has_begun) . (bfd *, struct coff_final_link_info *); . @@ -1659,10 +1654,6 @@ INTERNAL .#define bfd_coff_adjust_symndx(obfd, info, ibfd, sec, rel, adjustedp)\ . ((coff_backend_info (abfd)->_bfd_coff_adjust_symndx)\ . (obfd, info, ibfd, sec, rel, adjustedp)) -.#define bfd_coff_link_add_one_symbol(info, abfd, name, flags, section,\ -. value, string, cp, coll, hashp)\ -. ((coff_backend_info (abfd)->_bfd_coff_link_add_one_symbol)\ -. (info, abfd, name, flags, section, value, string, cp, coll, hashp)) . .#define bfd_coff_link_output_has_begun(a,p) \ . ((coff_backend_info (a)->_bfd_coff_link_output_has_begun) (a, p)) @@ -5513,10 +5504,6 @@ dummy_reloc16_extra_cases (bfd *abfd ATTRIBUTE_UNUSED, #define coff_adjust_symndx NULL #endif -#ifndef coff_link_add_one_symbol -#define coff_link_add_one_symbol _bfd_generic_link_add_one_symbol -#endif - #ifndef coff_link_output_has_begun static bool @@ -5615,7 +5602,7 @@ static const bfd_coff_backend_data bfd_coff_std_swap_table ATTRIBUTE_UNUSED = coff_print_aux, coff_reloc16_extra_cases, coff_reloc16_estimate, coff_classify_symbol, coff_compute_section_file_positions, coff_start_final_link, coff_relocate_section, coff_rtype_to_howto, - coff_adjust_symndx, coff_link_add_one_symbol, + coff_adjust_symndx, coff_link_output_has_begun, coff_final_link_postscript, bfd_pe_print_pdata }; @@ -5656,7 +5643,7 @@ static const bfd_coff_backend_data ticoff0_swap_table = coff_print_aux, coff_reloc16_extra_cases, coff_reloc16_estimate, coff_classify_symbol, coff_compute_section_file_positions, coff_start_final_link, coff_relocate_section, coff_rtype_to_howto, - coff_adjust_symndx, coff_link_add_one_symbol, + coff_adjust_symndx, coff_link_output_has_begun, coff_final_link_postscript, bfd_pe_print_pdata }; @@ -5698,7 +5685,7 @@ static const bfd_coff_backend_data ticoff1_swap_table = coff_print_aux, coff_reloc16_extra_cases, coff_reloc16_estimate, coff_classify_symbol, coff_compute_section_file_positions, coff_start_final_link, coff_relocate_section, coff_rtype_to_howto, - coff_adjust_symndx, coff_link_add_one_symbol, + coff_adjust_symndx, coff_link_output_has_begun, coff_final_link_postscript, bfd_pe_print_pdata /* huh */ }; @@ -5941,7 +5928,7 @@ static const bfd_coff_backend_data bigobj_swap_table = coff_print_aux, coff_reloc16_extra_cases, coff_reloc16_estimate, coff_classify_symbol, coff_compute_section_file_positions, coff_start_final_link, coff_relocate_section, coff_rtype_to_howto, - coff_adjust_symndx, coff_link_add_one_symbol, + coff_adjust_symndx, coff_link_output_has_begun, coff_final_link_postscript, bfd_pe_print_pdata /* huh */ }; diff --git a/bfd/cofflink.c b/bfd/cofflink.c index 876aed7..501731b 100644 --- a/bfd/cofflink.c +++ b/bfd/cofflink.c @@ -445,7 +445,7 @@ coff_link_add_symbols (bfd *abfd, if (addit) { - if (! (bfd_coff_link_add_one_symbol + if (! (_bfd_generic_link_add_one_symbol (info, abfd, name, flags, section, value, (const char *) NULL, copy, false, (struct bfd_link_hash_entry **) sym_hash))) diff --git a/bfd/elf32-nds32.c b/bfd/elf32-nds32.c index 1aff60a..3627b30 100644 --- a/bfd/elf32-nds32.c +++ b/bfd/elf32-nds32.c @@ -2697,7 +2697,8 @@ nds32_elf_do_9_pcrel_reloc (bfd * abfd, bfd_reloc_status_type status; /* Sanity check the address (offset in section). */ - if (offset > bfd_get_section_limit (abfd, input_section)) + bfd_vma octet = offset * bfd_octets_per_byte (abfd, input_section); + if (!bfd_reloc_offset_in_range (howto, abfd, input_section, octet)) return bfd_reloc_outofrange; relocation = symbol_value + addend; @@ -2751,7 +2752,7 @@ struct nds32_hi20 static struct nds32_hi20 *nds32_hi20_list; static bfd_reloc_status_type -nds32_elf_hi20_reloc (bfd *abfd ATTRIBUTE_UNUSED, +nds32_elf_hi20_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol, void *data, @@ -2774,7 +2775,10 @@ nds32_elf_hi20_reloc (bfd *abfd ATTRIBUTE_UNUSED, } /* Sanity check the address (offset in section). */ - if (reloc_entry->address > bfd_get_section_limit (abfd, input_section)) + bfd_vma octet = (reloc_entry->address + * bfd_octets_per_byte (abfd, input_section)); + if (!bfd_reloc_offset_in_range (reloc_entry->howto, + abfd, input_section, octet)) return bfd_reloc_outofrange; ret = bfd_reloc_ok; @@ -2938,7 +2942,10 @@ nds32_elf_generic_reloc (bfd *input_bfd, arelent *reloc_entry, a section relative addend which is wrong. */ /* Sanity check the address (offset in section). */ - if (reloc_entry->address > bfd_get_section_limit (input_bfd, input_section)) + bfd_vma octet = (reloc_entry->address + * bfd_octets_per_byte (input_bfd, input_section)); + if (!bfd_reloc_offset_in_range (reloc_entry->howto, input_bfd, input_section, + octet)) return bfd_reloc_outofrange; ret = bfd_reloc_ok; @@ -4698,7 +4705,8 @@ nds32_elf_final_link_relocate (reloc_howto_type *howto, bfd *input_bfd, bfd_vma relocation; /* Sanity check the address. */ - if (address > bfd_get_section_limit (input_bfd, input_section)) + bfd_vma octet = address * bfd_octets_per_byte (input_bfd, input_section); + if (!bfd_reloc_offset_in_range (howto, input_bfd, input_section, octet)) return bfd_reloc_outofrange; /* This function assumes that we are dealing with a basic relocation diff --git a/bfd/elflink.c b/bfd/elflink.c index 1399352..a76e8e3 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -4965,6 +4965,7 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info) asection *sec, *new_sec; flagword flags; const char *name; + const char *defvername; bool must_copy_name = false; struct elf_link_hash_entry *h; struct elf_link_hash_entry *hi; @@ -5141,6 +5142,7 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info) old_alignment = 0; old_bfd = NULL; new_sec = sec; + defvername = NULL; if (is_elf_hash_table (&htab->root)) { @@ -5259,7 +5261,7 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info) default version of the symbol. */ if ((iver.vs_vers & VERSYM_HIDDEN) == 0 && isym->st_shndx != SHN_UNDEF) - *p++ = ELF_VER_CHR; + *p++ = ELF_VER_CHR, defvername = name; memcpy (p, verstr, verlen + 1); name = newname; @@ -5709,9 +5711,15 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info) } else if (dynamic && h->root.u.def.section->owner == abfd) - /* Add this symbol to first hash if this shared - object has the first definition. */ - elf_link_add_to_first_hash (abfd, info, name, must_copy_name); + { + /* Add this symbol to first hash if this shared + object has the first definition. */ + elf_link_add_to_first_hash (abfd, info, name, must_copy_name); + /* And if it was the default symbol version definition, + also add the short name. */ + if (defvername) + elf_link_add_to_first_hash (abfd, info, defvername, false); + } } } } @@ -6273,12 +6281,28 @@ elf_link_add_archive_symbols (bfd *abfd, struct bfd_link_info *info) if (h->type == bfd_link_hash_undefined) { - /* If the archive element has already been loaded then one - of the symbols defined by that element might have been - made undefined due to being in a discarded section. */ - if (is_elf_hash_table (info->hash) - && ((struct elf_link_hash_entry *) h)->indx == -3) - continue; + if (is_elf_hash_table (info->hash)) + { + /* If the archive element has already been loaded then one + of the symbols defined by that element might have been + made undefined due to being in a discarded section. */ + if (((struct elf_link_hash_entry *) h)->indx == -3) + continue; + + /* In the pre-LTO-plugin pass we must not mistakenly + include this archive member if an earlier BFD + defined this symbol. */ + struct elf_link_hash_table *htab = elf_hash_table (info); + if (htab->first_hash) + { + struct elf_link_first_hash_entry *e + = ((struct elf_link_first_hash_entry *) + bfd_hash_lookup (htab->first_hash, symdef->name, + false, false)); + if (e && e->abfd != abfd) + continue; + } + } } else if (h->type == bfd_link_hash_common) { diff --git a/bfd/libbfd-in.h b/bfd/libbfd-in.h index b2f70fb..ae6d303 100644 --- a/bfd/libbfd-in.h +++ b/bfd/libbfd-in.h @@ -645,12 +645,6 @@ extern bool _bfd_generic_link_add_archive_symbols /* Forward declaration to avoid prototype errors. */ typedef struct bfd_link_hash_entry _bfd_link_hash_entry; -/* Generic routine to add a single symbol. */ -extern bool _bfd_generic_link_add_one_symbol - (struct bfd_link_info *, bfd *, const char *name, flagword, - asection *, bfd_vma, const char *, bool copy, - bool constructor, struct bfd_link_hash_entry **) ATTRIBUTE_HIDDEN; - /* Generic routine to mark section as supplying symbols only. */ extern void _bfd_generic_link_just_syms (asection *, struct bfd_link_info *) ATTRIBUTE_HIDDEN; diff --git a/bfd/libbfd.h b/bfd/libbfd.h index 4f6f5ea..d367fea 100644 --- a/bfd/libbfd.h +++ b/bfd/libbfd.h @@ -651,12 +651,6 @@ extern bool _bfd_generic_link_add_archive_symbols /* Forward declaration to avoid prototype errors. */ typedef struct bfd_link_hash_entry _bfd_link_hash_entry; -/* Generic routine to add a single symbol. */ -extern bool _bfd_generic_link_add_one_symbol - (struct bfd_link_info *, bfd *, const char *name, flagword, - asection *, bfd_vma, const char *, bool copy, - bool constructor, struct bfd_link_hash_entry **) ATTRIBUTE_HIDDEN; - /* Generic routine to mark section as supplying symbols only. */ extern void _bfd_generic_link_just_syms (asection *, struct bfd_link_info *) ATTRIBUTE_HIDDEN; diff --git a/bfd/libcoff.h b/bfd/libcoff.h index d0cfd09..05ebe35 100644 --- a/bfd/libcoff.h +++ b/bfd/libcoff.h @@ -864,11 +864,6 @@ typedef struct (bfd *, struct bfd_link_info *, bfd *, asection *, struct internal_reloc *, bool *); - bool (*_bfd_coff_link_add_one_symbol) - (struct bfd_link_info *, bfd *, const char *, flagword, - asection *, bfd_vma, const char *, bool, bool, - struct bfd_link_hash_entry **); - bool (*_bfd_coff_link_output_has_begun) (bfd *, struct coff_final_link_info *); @@ -1005,10 +1000,6 @@ typedef struct #define bfd_coff_adjust_symndx(obfd, info, ibfd, sec, rel, adjustedp)\ ((coff_backend_info (abfd)->_bfd_coff_adjust_symndx)\ (obfd, info, ibfd, sec, rel, adjustedp)) -#define bfd_coff_link_add_one_symbol(info, abfd, name, flags, section,\ - value, string, cp, coll, hashp)\ - ((coff_backend_info (abfd)->_bfd_coff_link_add_one_symbol)\ - (info, abfd, name, flags, section, value, string, cp, coll, hashp)) #define bfd_coff_link_output_has_begun(a,p) \ ((coff_backend_info (a)->_bfd_coff_link_output_has_begun) (a, p)) diff --git a/bfd/linker.c b/bfd/linker.c index 2a4b8f0..a9a23e5 100644 --- a/bfd/linker.c +++ b/bfd/linker.c @@ -1378,7 +1378,25 @@ hash_entry_bfd (struct bfd_link_hash_entry *h) /*NOTREACHED*/ } -/* Add a symbol to the global hash table. +/* +FUNCTION + _bfd_generic_link_add_one_symbol + +SYNOPSIS + bool _bfd_generic_link_add_one_symbol + (struct bfd_link_info *info, + bfd *abfd, + const char *name, + flagword flags, + asection *section, + bfd_vma value, + const char *string, + bool copy, + bool collect, + struct bfd_link_hash_entry **hashp); + +DESCRIPTION + Add a symbol to the global hash table. ABFD is the BFD the symbol comes from. NAME is the name of the symbol. FLAGS is the BSF_* bits associated with the symbol. diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c index 2901268..9938108 100644 --- a/bfd/peXXigen.c +++ b/bfd/peXXigen.c @@ -593,7 +593,7 @@ _bfd_XXi_swap_aouthdr_out (bfd * abfd, void * in, void * out) struct internal_extra_pe_aouthdr *extra = &pe->pe_opthdr; PEAOUTHDR *aouthdr_out = (PEAOUTHDR *) out; bfd_vma sa, fa, ib; - IMAGE_DATA_DIRECTORY idata2, idata5, tls; + IMAGE_DATA_DIRECTORY idata2, idata5, tls, loadcfg; sa = extra->SectionAlignment; fa = extra->FileAlignment; @@ -602,6 +602,7 @@ _bfd_XXi_swap_aouthdr_out (bfd * abfd, void * in, void * out) idata2 = pe->pe_opthdr.DataDirectory[PE_IMPORT_TABLE]; idata5 = pe->pe_opthdr.DataDirectory[PE_IMPORT_ADDRESS_TABLE]; tls = pe->pe_opthdr.DataDirectory[PE_TLS_TABLE]; + loadcfg = pe->pe_opthdr.DataDirectory[PE_LOAD_CONFIG_TABLE]; if (aouthdr_in->tsize) { @@ -651,6 +652,7 @@ _bfd_XXi_swap_aouthdr_out (bfd * abfd, void * in, void * out) extra->DataDirectory[PE_IMPORT_TABLE] = idata2; extra->DataDirectory[PE_IMPORT_ADDRESS_TABLE] = idata5; extra->DataDirectory[PE_TLS_TABLE] = tls; + extra->DataDirectory[PE_LOAD_CONFIG_TABLE] = loadcfg; if (extra->DataDirectory[PE_IMPORT_TABLE].VirtualAddress == 0) /* Until other .idata fixes are made (pending patch), the entry for @@ -4403,6 +4405,7 @@ _bfd_XXi_final_link_postscript (bfd * abfd, struct coff_final_link_info *pfinfo) struct coff_link_hash_entry *h1; struct bfd_link_info *info = pfinfo->info; bool result = true; + char name[20]; /* There are a few fields that need to be filled in now while we have symbol table access. @@ -4430,8 +4433,8 @@ _bfd_XXi_final_link_postscript (bfd * abfd, struct coff_final_link_info *pfinfo) else { _bfd_error_handler - (_("%pB: unable to fill in DataDictionary[1] because .idata$2 is missing"), - abfd); + (_("%pB: unable to fill in DataDirectory[%d]: %s is missing"), + abfd, PE_IMPORT_TABLE, ".idata$2"); result = false; } @@ -4450,8 +4453,8 @@ _bfd_XXi_final_link_postscript (bfd * abfd, struct coff_final_link_info *pfinfo) else { _bfd_error_handler - (_("%pB: unable to fill in DataDictionary[1] because .idata$4 is missing"), - abfd); + (_("%pB: unable to fill in DataDirectory[%d]: %s is missing"), + abfd, PE_IMPORT_TABLE, ".idata$4"); result = false; } @@ -4471,8 +4474,8 @@ _bfd_XXi_final_link_postscript (bfd * abfd, struct coff_final_link_info *pfinfo) else { _bfd_error_handler - (_("%pB: unable to fill in DataDictionary[12] because .idata$5 is missing"), - abfd); + (_("%pB: unable to fill in DataDirectory[%d]: %s is missing"), + abfd, PE_IMPORT_ADDRESS_TABLE, ".idata$5"); result = false; } @@ -4491,8 +4494,8 @@ _bfd_XXi_final_link_postscript (bfd * abfd, struct coff_final_link_info *pfinfo) else { _bfd_error_handler - (_("%pB: unable to fill in DataDictionary[PE_IMPORT_ADDRESS_TABLE (12)] because .idata$6 is missing"), - abfd); + (_("%pB: unable to fill in DataDirectory[%d]: %s is missing"), + abfd, PE_IMPORT_ADDRESS_TABLE, ".idata$6"); result = false; } } @@ -4533,17 +4536,16 @@ _bfd_XXi_final_link_postscript (bfd * abfd, struct coff_final_link_info *pfinfo) else { _bfd_error_handler - (_("%pB: unable to fill in DataDictionary[PE_IMPORT_ADDRESS_TABLE(12)]" - " because .idata$6 is missing"), abfd); + (_("%pB: unable to fill in DataDirectory[%d]: %s not defined correctly"), + abfd, PE_IMPORT_ADDRESS_TABLE, "__IAT_end__"); result = false; } } } - h1 = coff_link_hash_lookup (coff_hash_table (info), - (bfd_get_symbol_leading_char (abfd) != 0 - ? "__tls_used" : "_tls_used"), - false, false, true); + name[0] = bfd_get_symbol_leading_char (abfd); + strcpy (name + !!name[0], "_tls_used"); + h1 = coff_link_hash_lookup (coff_hash_table (info), name, false, false, true); if (h1 != NULL) { if ((h1->root.type == bfd_link_hash_defined @@ -4558,8 +4560,8 @@ _bfd_XXi_final_link_postscript (bfd * abfd, struct coff_final_link_info *pfinfo) else { _bfd_error_handler - (_("%pB: unable to fill in DataDictionary[9] because __tls_used is missing"), - abfd); + (_("%pB: unable to fill in DataDirectory[%d]: %s not defined correctly"), + abfd, PE_TLS_TABLE, name); result = false; } /* According to PECOFF sepcifications by Microsoft version 8.2 @@ -4573,6 +4575,81 @@ _bfd_XXi_final_link_postscript (bfd * abfd, struct coff_final_link_info *pfinfo) #endif } + name[0] = bfd_get_symbol_leading_char (abfd); + strcpy (name + !!name[0], "_load_config_used"); + h1 = coff_link_hash_lookup (coff_hash_table (info), name, false, false, true); + if (h1 != NULL) + { + char data[4]; + if ((h1->root.type == bfd_link_hash_defined + || h1->root.type == bfd_link_hash_defweak) + && h1->root.u.def.section != NULL + && h1->root.u.def.section->output_section != NULL) + { + pe_data (abfd)->pe_opthdr.DataDirectory[PE_LOAD_CONFIG_TABLE].VirtualAddress = + (h1->root.u.def.value + + h1->root.u.def.section->output_section->vma + + h1->root.u.def.section->output_offset + - pe_data (abfd)->pe_opthdr.ImageBase); + + if (pe_data (abfd)->pe_opthdr.DataDirectory[PE_LOAD_CONFIG_TABLE].VirtualAddress + & (bfd_arch_bits_per_address (abfd) / bfd_arch_bits_per_byte (abfd) + - 1)) + { + _bfd_error_handler + (_("%pB: unable to fill in DataDirectory[%d]: %s not properly aligned"), + abfd, PE_LOAD_CONFIG_TABLE, name); + result = false; + } + + /* The size is stored as the first 4 bytes at _load_config_used. */ + if (bfd_get_section_contents (abfd, + h1->root.u.def.section->output_section, data, + h1->root.u.def.section->output_offset + h1->root.u.def.value, + 4)) + { + uint32_t size = bfd_get_32 (abfd, data); + /* The Microsoft PE format documentation says for compatibility + with Windows XP and earlier, the size must be 64 for x86 + images. */ + pe_data (abfd)->pe_opthdr.DataDirectory[PE_LOAD_CONFIG_TABLE].Size + = (bfd_get_arch (abfd) == bfd_arch_i386 + && ((bfd_get_mach (abfd) & ~bfd_mach_i386_intel_syntax) + == bfd_mach_i386_i386) + && ((pe_data (abfd)->pe_opthdr.Subsystem + == IMAGE_SUBSYSTEM_WINDOWS_GUI) + || (pe_data (abfd)->pe_opthdr.Subsystem + == IMAGE_SUBSYSTEM_WINDOWS_CUI)) + && (pe_data (abfd)->pe_opthdr.MajorSubsystemVersion * 256 + + pe_data (abfd)->pe_opthdr.MinorSubsystemVersion + <= 0x0501)) + ? 64 : size; + + if (size > h1->root.u.def.section->size - h1->root.u.def.value) + { + _bfd_error_handler + (_("%pB: unable to fill in DataDirectory[%d]: size too large for the containing section"), + abfd, PE_LOAD_CONFIG_TABLE); + result = false; + } + } + else + { + _bfd_error_handler + (_("%pB: unable to fill in DataDirectory[%d]: size can't be read from %s"), + abfd, PE_LOAD_CONFIG_TABLE, name); + result = false; + } + } + else + { + _bfd_error_handler + (_("%pB: unable to fill in DataDirectory[%d]: %s not defined correctly"), + abfd, PE_LOAD_CONFIG_TABLE, name); + result = false; + } + } + /* If there is a .pdata section and we have linked pdata finally, we need to sort the entries ascending. */ #if !defined(COFF_WITH_pep) && (defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) || defined(COFF_WITH_peLoongArch64) || defined (COFF_WITH_peRiscV64)) diff --git a/bfd/version.h b/bfd/version.h index 8cb9007..5bd4a9d 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 20250403 +#define BFD_VERSION_DATE 20250408 #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/bfd/xcofflink.c b/bfd/xcofflink.c index 446fa5a..b50b17f 100644 --- a/bfd/xcofflink.c +++ b/bfd/xcofflink.c @@ -243,6 +243,55 @@ xcoff_get_section_contents (bfd *abfd, asection *sec) return contents; } +/* Read .loader and swap in the header. Sanity check to prevent + buffer overflows. Don't bother to check for overlap as that sort + of insanity shouldn't lead to incorrect program behaviour. */ + +static bfd_byte * +xcoff_get_ldhdr (bfd *abfd, asection *lsec, struct internal_ldhdr *ldhdr) +{ + bfd_byte *contents = xcoff_get_section_contents (abfd, lsec); + if (contents) + { + bfd_xcoff_swap_ldhdr_in (abfd, contents, ldhdr); + if (ldhdr->l_nsyms != 0) + { + bfd_vma symoff = bfd_xcoff_loader_symbol_offset (abfd, ldhdr); + if (symoff > lsec->size) + goto fail; + bfd_size_type onesym = bfd_xcoff_ldsymsz (abfd); + bfd_size_type syms; + if (_bfd_mul_overflow (ldhdr->l_nsyms, onesym, &syms) + || syms > lsec->size - symoff) + goto fail; + } + if (ldhdr->l_stlen != 0 + && (ldhdr->l_stoff > lsec->size + || ldhdr->l_stlen > lsec->size - ldhdr->l_stoff)) + goto fail; + if (ldhdr->l_nreloc != 0) + { + bfd_vma reloff = bfd_xcoff_loader_reloc_offset (abfd, ldhdr); + if (reloff > lsec->size) + goto fail; + bfd_size_type onerel = bfd_xcoff_ldrelsz (abfd); + bfd_size_type rels; + if (_bfd_mul_overflow (ldhdr->l_nreloc, onerel, &rels) + || rels > lsec->size - reloff) + goto fail; + } + if (ldhdr->l_nimpid != 0 + && (ldhdr->l_impoff > lsec->size + || ldhdr->l_istlen > lsec->size - ldhdr->l_impoff)) + goto fail; + } + return contents; + + fail: + bfd_set_error (bfd_error_file_truncated); + return NULL; +} + /* Get the size required to hold the dynamic symbols. */ long @@ -265,12 +314,10 @@ _bfd_xcoff_get_dynamic_symtab_upper_bound (bfd *abfd) return -1; } - contents = xcoff_get_section_contents (abfd, lsec); + contents = xcoff_get_ldhdr (abfd, lsec, &ldhdr); if (!contents) return -1; - bfd_xcoff_swap_ldhdr_in (abfd, (void *) contents, &ldhdr); - return (ldhdr.l_nsyms + 1) * sizeof (asymbol *); } @@ -299,12 +346,10 @@ _bfd_xcoff_canonicalize_dynamic_symtab (bfd *abfd, asymbol **psyms) return -1; } - contents = xcoff_get_section_contents (abfd, lsec); + contents = xcoff_get_ldhdr (abfd, lsec, &ldhdr); if (!contents) return -1; - bfd_xcoff_swap_ldhdr_in (abfd, contents, &ldhdr); - strings = (char *) contents + ldhdr.l_stoff; symbuf = bfd_zalloc (abfd, ldhdr.l_nsyms * sizeof (* symbuf)); @@ -322,9 +367,7 @@ _bfd_xcoff_canonicalize_dynamic_symtab (bfd *abfd, asymbol **psyms) symbuf->symbol.the_bfd = abfd; - if (ldsym._l._l_l._l_zeroes == 0) - symbuf->symbol.name = strings + ldsym._l._l_l._l_offset; - else + if (ldsym._l._l_l._l_zeroes != 0) { char *c; @@ -335,6 +378,10 @@ _bfd_xcoff_canonicalize_dynamic_symtab (bfd *abfd, asymbol **psyms) c[SYMNMLEN] = '\0'; symbuf->symbol.name = c; } + else if (ldsym._l._l_l._l_offset < ldhdr.l_stlen) + symbuf->symbol.name = strings + ldsym._l._l_l._l_offset; + else + symbuf->symbol.name = _("<corrupt>"); if (ldsym.l_smclas == XMC_XO) symbuf->symbol.section = bfd_abs_section_ptr; @@ -384,12 +431,10 @@ _bfd_xcoff_get_dynamic_reloc_upper_bound (bfd *abfd) return -1; } - contents = xcoff_get_section_contents (abfd, lsec); + contents = xcoff_get_ldhdr (abfd, lsec, &ldhdr); if (!contents) return -1; - bfd_xcoff_swap_ldhdr_in (abfd, (struct external_ldhdr *) contents, &ldhdr); - return (ldhdr.l_nreloc + 1) * sizeof (arelent *); } @@ -419,12 +464,10 @@ _bfd_xcoff_canonicalize_dynamic_reloc (bfd *abfd, return -1; } - contents = xcoff_get_section_contents (abfd, lsec); + contents = xcoff_get_ldhdr (abfd, lsec, &ldhdr); if (!contents) return -1; - bfd_xcoff_swap_ldhdr_in (abfd, contents, &ldhdr); - relbuf = bfd_alloc (abfd, ldhdr.l_nreloc * sizeof (arelent)); if (relbuf == NULL) return -1; @@ -905,7 +948,7 @@ xcoff_link_add_dynamic_symbols (bfd *abfd, struct bfd_link_info *info) return false; } - contents = xcoff_get_section_contents (abfd, lsec); + contents = xcoff_get_ldhdr (abfd, lsec, &ldhdr); if (!contents) return false; @@ -913,8 +956,6 @@ xcoff_link_add_dynamic_symbols (bfd *abfd, struct bfd_link_info *info) included in the link. */ bfd_section_list_clear (abfd); - bfd_xcoff_swap_ldhdr_in (abfd, contents, &ldhdr); - strings = (char *) contents + ldhdr.l_stoff; elsym = contents + bfd_xcoff_loader_symbol_offset(abfd, &ldhdr); @@ -934,14 +975,16 @@ xcoff_link_add_dynamic_symbols (bfd *abfd, struct bfd_link_info *info) if ((ldsym.l_smtype & L_EXPORT) == 0) continue; - if (ldsym._l._l_l._l_zeroes == 0) - name = strings + ldsym._l._l_l._l_offset; - else + if (ldsym._l._l_l._l_zeroes != 0) { memcpy (nambuf, ldsym._l._l_name, SYMNMLEN); nambuf[SYMNMLEN] = '\0'; name = nambuf; } + else if (ldsym._l._l_l._l_offset < ldhdr.l_stlen) + name = strings + ldsym._l._l_l._l_offset; + else + continue; /* Normally we could not call xcoff_link_hash_lookup in an add symbols routine, since we might not be using an XCOFF hash @@ -2368,12 +2411,10 @@ xcoff_link_check_dynamic_ar_symbols (bfd *abfd, /* There are no symbols, so don't try to include it. */ return true; - contents = xcoff_get_section_contents (abfd, lsec); + contents = xcoff_get_ldhdr (abfd, lsec, &ldhdr); if (!contents) return false; - bfd_xcoff_swap_ldhdr_in (abfd, contents, &ldhdr); - strings = (char *) contents + ldhdr.l_stoff; elsym = contents + bfd_xcoff_loader_symbol_offset (abfd, &ldhdr); @@ -2392,14 +2433,16 @@ xcoff_link_check_dynamic_ar_symbols (bfd *abfd, if ((ldsym.l_smtype & L_EXPORT) == 0) continue; - if (ldsym._l._l_l._l_zeroes == 0) - name = strings + ldsym._l._l_l._l_offset; - else + if (ldsym._l._l_l._l_zeroes != 0) { memcpy (nambuf, ldsym._l._l_name, SYMNMLEN); nambuf[SYMNMLEN] = '\0'; name = nambuf; } + else if (ldsym._l._l_l._l_offset < ldhdr.l_stlen) + name = strings + ldsym._l._l_l._l_offset; + else + continue; h = bfd_link_hash_lookup (info->hash, name, false, false, true); diff --git a/binutils/Makefile.am b/binutils/Makefile.am index 20c711a..1528302 100644 --- a/binutils/Makefile.am +++ b/binutils/Makefile.am @@ -255,7 +255,7 @@ LDADD = $(BFDLIB) $(LIBIBERTY) $(LIBINTL) size_SOURCES = size.c $(BULIBS) -objcopy_SOURCES = objcopy.c not-strip.c rename.c $(WRITE_DEBUG_SRCS) $(BULIBS) +objcopy_SOURCES = not-strip.c rename.c $(WRITE_DEBUG_SRCS) $(BULIBS) strings_SOURCES = strings.c $(BULIBS) @@ -265,7 +265,7 @@ readelf_LDADD = $(LIBCTF_NOBFD) $(LIBINTL) $(LIBIBERTY) $(ZLIB) $(ZSTD_LIBS) $ elfedit_SOURCES = elfedit.c version.c $(ELFLIBS) elfedit_LDADD = $(LIBINTL) $(LIBIBERTY) -strip_new_SOURCES = objcopy.c is-strip.c rename.c $(WRITE_DEBUG_SRCS) $(BULIBS) +strip_new_SOURCES = is-strip.c rename.c $(WRITE_DEBUG_SRCS) $(BULIBS) nm_new_SOURCES = nm.c demanguse.c $(BULIBS) @@ -287,13 +287,13 @@ endif cxxfilt_SOURCES = cxxfilt.c $(BULIBS) -ar_SOURCES = arparse.y arlex.l ar.c not-ranlib.c arsup.c rename.c binemul.c \ +ar_SOURCES = arparse.y arlex.l not-ranlib.c arsup.c rename.c binemul.c \ emul_$(EMULATION).c $(BULIBS) EXTRA_ar_SOURCES = $(CFILES) ar_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL) -ranlib_SOURCES = ar.c is-ranlib.c arparse.y arlex.l arsup.c rename.c \ - binemul.c emul_$(EMULATION).c $(BULIBS) +ranlib_SOURCES = arparse.y arlex.l is-ranlib.c arsup.c rename.c binemul.c \ + emul_$(EMULATION).c $(BULIBS) ranlib_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL) addr2line_SOURCES = addr2line.c $(BULIBS) diff --git a/binutils/Makefile.in b/binutils/Makefile.in index 8029bc2..549b5a3 100644 --- a/binutils/Makefile.in +++ b/binutils/Makefile.in @@ -208,9 +208,9 @@ AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = -am_ar_OBJECTS = arparse.$(OBJEXT) arlex.$(OBJEXT) ar.$(OBJEXT) \ - not-ranlib.$(OBJEXT) arsup.$(OBJEXT) rename.$(OBJEXT) \ - binemul.$(OBJEXT) emul_$(EMULATION).$(OBJEXT) $(am__objects_1) +am_ar_OBJECTS = arparse.$(OBJEXT) arlex.$(OBJEXT) not-ranlib.$(OBJEXT) \ + arsup.$(OBJEXT) rename.$(OBJEXT) binemul.$(OBJEXT) \ + emul_$(EMULATION).$(OBJEXT) $(am__objects_1) ar_OBJECTS = $(am_ar_OBJECTS) bfdtest1_SOURCES = bfdtest1.c bfdtest1_OBJECTS = bfdtest1.$(OBJEXT) @@ -240,8 +240,8 @@ nm_new_LDADD = $(LDADD) am__objects_3 = rddbg.$(OBJEXT) debug.$(OBJEXT) stabs.$(OBJEXT) \ rdcoff.$(OBJEXT) am__objects_4 = $(am__objects_3) wrstabs.$(OBJEXT) -am_objcopy_OBJECTS = objcopy.$(OBJEXT) not-strip.$(OBJEXT) \ - rename.$(OBJEXT) $(am__objects_4) $(am__objects_1) +am_objcopy_OBJECTS = not-strip.$(OBJEXT) rename.$(OBJEXT) \ + $(am__objects_4) $(am__objects_1) objcopy_OBJECTS = $(am_objcopy_OBJECTS) objcopy_LDADD = $(LDADD) am_objdump_OBJECTS = objdump.$(OBJEXT) dwarf.$(OBJEXT) prdbg.$(OBJEXT) \ @@ -249,8 +249,8 @@ am_objdump_OBJECTS = objdump.$(OBJEXT) dwarf.$(OBJEXT) prdbg.$(OBJEXT) \ $(am__objects_2) objdump_OBJECTS = $(am_objdump_OBJECTS) @ENABLE_LIBCTF_TRUE@am__DEPENDENCIES_2 = ../libctf/libctf.la -am_ranlib_OBJECTS = ar.$(OBJEXT) is-ranlib.$(OBJEXT) arparse.$(OBJEXT) \ - arlex.$(OBJEXT) arsup.$(OBJEXT) rename.$(OBJEXT) \ +am_ranlib_OBJECTS = arparse.$(OBJEXT) arlex.$(OBJEXT) \ + is-ranlib.$(OBJEXT) arsup.$(OBJEXT) rename.$(OBJEXT) \ binemul.$(OBJEXT) emul_$(EMULATION).$(OBJEXT) $(am__objects_1) ranlib_OBJECTS = $(am_ranlib_OBJECTS) am_readelf_OBJECTS = readelf.$(OBJEXT) version.$(OBJEXT) \ @@ -268,8 +268,8 @@ srconv_LDADD = $(LDADD) am_strings_OBJECTS = strings.$(OBJEXT) $(am__objects_1) strings_OBJECTS = $(am_strings_OBJECTS) strings_LDADD = $(LDADD) -am_strip_new_OBJECTS = objcopy.$(OBJEXT) is-strip.$(OBJEXT) \ - rename.$(OBJEXT) $(am__objects_4) $(am__objects_1) +am_strip_new_OBJECTS = is-strip.$(OBJEXT) rename.$(OBJEXT) \ + $(am__objects_4) $(am__objects_1) strip_new_OBJECTS = $(am_strip_new_OBJECTS) strip_new_LDADD = $(LDADD) am_sysdump_OBJECTS = sysdump.$(OBJEXT) $(am__objects_1) @@ -793,25 +793,25 @@ bfdtest1_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) bfdtest2_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB) LDADD = $(BFDLIB) $(LIBIBERTY) $(LIBINTL) size_SOURCES = size.c $(BULIBS) -objcopy_SOURCES = objcopy.c not-strip.c rename.c $(WRITE_DEBUG_SRCS) $(BULIBS) +objcopy_SOURCES = not-strip.c rename.c $(WRITE_DEBUG_SRCS) $(BULIBS) strings_SOURCES = strings.c $(BULIBS) readelf_SOURCES = readelf.c version.c unwind-ia64.c dwarf.c demanguse.c $(ELFLIBS) readelf_LDADD = $(LIBCTF_NOBFD) $(LIBINTL) $(LIBIBERTY) $(ZLIB) $(ZSTD_LIBS) $(DEBUGINFOD_LIBS) $(MSGPACK_LIBS) $(LIBSFRAME) elfedit_SOURCES = elfedit.c version.c $(ELFLIBS) elfedit_LDADD = $(LIBINTL) $(LIBIBERTY) -strip_new_SOURCES = objcopy.c is-strip.c rename.c $(WRITE_DEBUG_SRCS) $(BULIBS) +strip_new_SOURCES = is-strip.c rename.c $(WRITE_DEBUG_SRCS) $(BULIBS) nm_new_SOURCES = nm.c demanguse.c $(BULIBS) objdump_SOURCES = objdump.c dwarf.c prdbg.c demanguse.c $(DEBUG_SRCS) $(BULIBS) $(ELFLIBS) EXTRA_objdump_SOURCES = od-elf32_avr.c od-macho.c od-xcoff.c od-pe.c objdump_LDADD = $(OBJDUMP_PRIVATE_OFILES) $(OPCODES) $(LIBCTF) $(BFDLIB) $(LIBIBERTY) $(LIBINTL) $(DEBUGINFOD_LIBS) $(LIBSFRAME) cxxfilt_SOURCES = cxxfilt.c $(BULIBS) -ar_SOURCES = arparse.y arlex.l ar.c not-ranlib.c arsup.c rename.c binemul.c \ +ar_SOURCES = arparse.y arlex.l not-ranlib.c arsup.c rename.c binemul.c \ emul_$(EMULATION).c $(BULIBS) EXTRA_ar_SOURCES = $(CFILES) ar_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL) -ranlib_SOURCES = ar.c is-ranlib.c arparse.y arlex.l arsup.c rename.c \ - binemul.c emul_$(EMULATION).c $(BULIBS) +ranlib_SOURCES = arparse.y arlex.l is-ranlib.c arsup.c rename.c binemul.c \ + emul_$(EMULATION).c $(BULIBS) ranlib_LDADD = $(BFDLIB) $(LIBIBERTY) $(LEXLIB) $(LIBINTL) addr2line_SOURCES = addr2line.c $(BULIBS) diff --git a/binutils/ar.c b/binutils/ar.c index 40cad57..de41c9e 100644 --- a/binutils/ar.c +++ b/binutils/ar.c @@ -67,7 +67,9 @@ static int mri_mode; /* This flag distinguishes between ar and ranlib: 1 means this is 'ranlib'; 0 means this is 'ar'. -1 means if we should use argv[0] to decide. */ +#ifndef is_ranlib extern int is_ranlib; +#endif /* Nonzero means don't warn about creating the archive file if necessary. */ int silent_create = 0; @@ -735,16 +737,23 @@ main (int argc, char **argv) expandargv (&argc, &argv); +#ifndef is_ranlib if (is_ranlib < 0) { - const char *temp = lbasename (program_name); + size_t l = strlen (program_name); - if (strlen (temp) >= 6 - && FILENAME_CMP (temp + strlen (temp) - 6, "ranlib") == 0) - is_ranlib = 1; - else - is_ranlib = 0; +#ifdef HAVE_DOS_BASED_FILE_SYSTEM + /* Drop the .exe suffix, if any. */ + if (l > 4 && FILENAME_CMP (program_name + l - 4, ".exe") == 0) + { + l -= 4; + program_name[l] = '\0'; + } +#endif + is_ranlib = (l >= 6 && + FILENAME_CMP (program_name + l - 6, "ranlib") == 0); } +#endif if (bfd_init () != BFD_INIT_MAGIC) fatal (_("fatal error: libbfd ABI mismatch")); diff --git a/binutils/doc/binutils.texi b/binutils/doc/binutils.texi index 5bf5d80..b291670 100644 --- a/binutils/doc/binutils.texi +++ b/binutils/doc/binutils.texi @@ -2146,9 +2146,6 @@ Sets the section alignment field in the PE header - if one is present in the binary. Sections in memory will always begin at addresses which are a multiple of this number. Defaults to 0x1000. -Note - this option will also set the alignment field in each section's -flags. - Note - if a section's LMA or VMA addresses are no longer aligned, and those addresses have not been set via the @option{--set-section-lma} or @option{--set-section-vma} options, and the file has been fully diff --git a/binutils/is-ranlib.c b/binutils/is-ranlib.c index 4a04adb..47296eb 100644 --- a/binutils/is-ranlib.c +++ b/binutils/is-ranlib.c @@ -17,6 +17,5 @@ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ -/* Linked with ar.o to flag that this program is 'ranlib' (not 'ar'). */ - -int is_ranlib = 1; +#define is_ranlib 1 +#include "ar.c" diff --git a/binutils/is-strip.c b/binutils/is-strip.c index 26aeaf0..4ac1035 100644 --- a/binutils/is-strip.c +++ b/binutils/is-strip.c @@ -17,7 +17,5 @@ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ -/* Linked with objcopy.o to flag that this program is 'strip' (not - 'objcopy'). */ - -int is_strip = 1; +#define is_strip 1 +#include "objcopy.c" diff --git a/binutils/nm.c b/binutils/nm.c index 4e86057..7ef5d61 100644 --- a/binutils/nm.c +++ b/binutils/nm.c @@ -79,7 +79,15 @@ struct extended_symbol_info #define SYM_STAB_DESC(sym) (sym->sinfo->stab_desc) #define SYM_STAB_OTHER(sym) (sym->sinfo->stab_other) #define SYM_SIZE(sym) \ - (sym->elfinfo ? sym->elfinfo->internal_elf_sym.st_size: sym->ssize) + (sym->elfinfo \ + && sym->elfinfo->internal_elf_sym.st_size \ + ? sym->elfinfo->internal_elf_sym.st_size \ + : sym->coffinfo \ + && ISFCN (sym->coffinfo->native->u.syment.n_type) \ + && sym->coffinfo->native->u.syment.n_numaux \ + && sym->coffinfo->native[1].u.auxent.x_sym.x_misc.x_fsize \ + ? sym->coffinfo->native[1].u.auxent.x_sym.x_misc.x_fsize \ + : sym->ssize) /* The output formatting functions. */ static void print_object_filename_bsd (const char *); @@ -1036,9 +1044,9 @@ size_forward2 (const void *P_x, const void *P_y) return sorters[0][reverse_sort] (x->minisym, y->minisym); } -/* Sort the symbols by size. ELF provides a size but for other formats - we have to make a guess by assuming that the difference between the - address of a symbol and the address of the next higher symbol is the +/* Sort the symbols by size. ELF and COFF may provide a size but for other + formats we have to make a guess by assuming that the difference between + the address of a symbol and the address of the next higher symbol is the size. */ static long @@ -1081,6 +1089,8 @@ sort_symbols_by_size (bfd *abfd, bool is_dynamic, void *minisyms, asection *sec; bfd_vma sz; asymbol *temp; + const elf_symbol_type *elfsym; + const coff_symbol_type *coffsym; if (from + size < fromend) { @@ -1100,8 +1110,15 @@ sort_symbols_by_size (bfd *abfd, bool is_dynamic, void *minisyms, we can't rely on that information for the symbol size. Ditto for bfd/section.c:global_syms like *ABS*. */ if ((sym->flags & (BSF_SECTION_SYM | BSF_SYNTHETIC)) == 0 - && bfd_get_flavour (abfd) == bfd_target_elf_flavour) - sz = ((elf_symbol_type *) sym)->internal_elf_sym.st_size; + && (elfsym = elf_symbol_from (sym)) != NULL + && elfsym->internal_elf_sym.st_size != 0) + sz = elfsym->internal_elf_sym.st_size; + else if ((sym->flags & (BSF_SECTION_SYM | BSF_SYNTHETIC)) == 0 + && (coffsym = coff_symbol_from (sym)) != NULL + && ISFCN (coffsym->native->u.syment.n_type) + && coffsym->native->u.syment.n_numaux != 0 + && coffsym->native[1].u.auxent.x_sym.x_misc.x_fsize != 0) + sz = coffsym->native[1].u.auxent.x_sym.x_misc.x_fsize; else if ((sym->flags & (BSF_SECTION_SYM | BSF_SYNTHETIC)) == 0 && bfd_is_com_section (sec)) sz = sym->value; diff --git a/binutils/not-ranlib.c b/binutils/not-ranlib.c index 5fc0d6a..17da296 100644 --- a/binutils/not-ranlib.c +++ b/binutils/not-ranlib.c @@ -17,6 +17,5 @@ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ -/* Linked with ar.o to flag that this program is 'ar' (not 'ranlib'). */ - -int is_ranlib = 0; +#define is_ranlib 0 +#include "ar.c" diff --git a/binutils/not-strip.c b/binutils/not-strip.c index 5c72848..9e39da4 100644 --- a/binutils/not-strip.c +++ b/binutils/not-strip.c @@ -17,7 +17,5 @@ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ -/* Linked with objcopy.o to flag that this program is 'objcopy' (not - 'strip'). */ - -int is_strip = 0; +#define is_strip 0 +#include "objcopy.c" diff --git a/binutils/objcopy.c b/binutils/objcopy.c index 572f22c..31933e1 100644 --- a/binutils/objcopy.c +++ b/binutils/objcopy.c @@ -533,7 +533,9 @@ extern char *program_name; /* This flag distinguishes between strip and objcopy: 1 means this is 'strip'; 0 means this is 'objcopy'. -1 means if we should use argv[0] to decide. */ +#ifndef is_strip extern int is_strip; +#endif /* The maximum length of an S record. This variable is defined in srec.c and can be modified by the --srec-len parameter. */ @@ -4112,29 +4114,6 @@ power_of_two (bfd_vma val) return result; } -static unsigned int -image_scn_align (unsigned int alignment) -{ - switch (alignment) - { - case 8192: return IMAGE_SCN_ALIGN_8192BYTES; - case 4096: return IMAGE_SCN_ALIGN_4096BYTES; - case 2048: return IMAGE_SCN_ALIGN_2048BYTES; - case 1024: return IMAGE_SCN_ALIGN_1024BYTES; - case 512: return IMAGE_SCN_ALIGN_512BYTES; - case 256: return IMAGE_SCN_ALIGN_256BYTES; - case 128: return IMAGE_SCN_ALIGN_128BYTES; - case 64: return IMAGE_SCN_ALIGN_64BYTES; - case 32: return IMAGE_SCN_ALIGN_32BYTES; - case 16: return IMAGE_SCN_ALIGN_16BYTES; - case 8: return IMAGE_SCN_ALIGN_8BYTES; - case 4: return IMAGE_SCN_ALIGN_4BYTES; - case 2: return IMAGE_SCN_ALIGN_2BYTES; - case 1: return IMAGE_SCN_ALIGN_1BYTES; - default: return 0; - } -} - /* Create a section in OBFD with the same name and attributes as ISECTION in IBFD. */ @@ -4300,24 +4279,9 @@ setup_section (bfd *ibfd, sec_ptr isection, bfd *obfd) if (p != NULL) alignment = p->alignment; else if (pe_section_alignment != (bfd_vma) -1 - && bfd_get_flavour (ibfd) == bfd_target_coff_flavour - && bfd_get_flavour (obfd) == bfd_target_coff_flavour) - { - alignment = power_of_two (pe_section_alignment); - - if (coff_section_data (ibfd, isection)) - { - struct pei_section_tdata * pei_data = pei_section_data (ibfd, isection); - - if (pei_data != NULL) - { - /* Set the alignment flag of the input section, which will - be copied to the output section later on. */ - pei_data->pe_flags &= ~IMAGE_SCN_ALIGN_POWER_BIT_MASK; - pei_data->pe_flags |= image_scn_align (pe_section_alignment); - } - } - } + && bfd_get_flavour (obfd) == bfd_target_coff_flavour + && bfd_pei_p (obfd)) + alignment = power_of_two (pe_section_alignment); else alignment = bfd_section_alignment (isection); @@ -5979,6 +5943,11 @@ copy_main (int argc, char *argv[]) case OPTION_FILE_ALIGNMENT: pe_file_alignment = parse_vma (optarg, "--file-alignment"); + if (power_of_two (pe_file_alignment) == -1) + { + non_fatal (_("--file-alignment argument is not a power of two: %s - ignoring"), optarg); + pe_file_alignment = (bfd_vma) -1; + } break; case OPTION_HEAP: @@ -6222,9 +6191,11 @@ main (int argc, char *argv[]) fatal (_("fatal error: libbfd ABI mismatch")); set_default_bfd_target (); +#ifndef is_strip if (is_strip < 0) { - int i = strlen (program_name); + size_t i = strlen (program_name); + #ifdef HAVE_DOS_BASED_FILE_SYSTEM /* Drop the .exe suffix, if any. */ if (i > 4 && FILENAME_CMP (program_name + i - 4, ".exe") == 0) @@ -6235,6 +6206,7 @@ main (int argc, char *argv[]) #endif is_strip = (i >= 5 && FILENAME_CMP (program_name + i - 5, "strip") == 0); } +#endif /* is_strip */ create_symbol_htabs (); xatexit (delete_symbol_htabs); diff --git a/binutils/testsuite/binutils-all/nm-coff-1.s b/binutils/testsuite/binutils-all/nm-coff-1.s new file mode 100644 index 0000000..3efc10e --- /dev/null +++ b/binutils/testsuite/binutils-all/nm-coff-1.s @@ -0,0 +1,26 @@ + .globl text_symbol1 + .globl text_symbol2 + .globl text_symbol3 + .macro ENDFN name:req + .def \name + .type 0x20 /* DT_FUNC */ + .scl 2 /* C_EXT */ + .endef + .def \name + .scl 0xff /* C_EFCN */ + .val . + .endef + .endm + .text +text_symbol1: + .long 0 + .long 0 + .long 0 + ENDFN text_symbol1 +text_symbol2: + .long 0 + .long 0 + ENDFN text_symbol2 +text_symbol3: + .long 0 + ENDFN text_symbol3 diff --git a/binutils/testsuite/binutils-all/nm-coff-sdef-1.s b/binutils/testsuite/binutils-all/nm-coff-sdef-1.s new file mode 100644 index 0000000..f1a10bb --- /dev/null +++ b/binutils/testsuite/binutils-all/nm-coff-sdef-1.s @@ -0,0 +1,26 @@ + .globl text_symbol1 + .globl text_symbol2 + .globl text_symbol3 + .macro ENDFN name:req + .sdef \name + .type 0x20 /* DT_FUNC */ + .scl 2 /* C_EXT */ + .endef + .sdef \name + .scl 0xff /* C_EFCN */ + .val . + .endef + .endm + .text +text_symbol1: + .byte 0,0,0,0 + .byte 0,0,0,0 + .byte 0,0,0,0 + ENDFN text_symbol1 +text_symbol2: + .byte 0,0,0,0 + .byte 0,0,0,0 + ENDFN text_symbol2 +text_symbol3: + .byte 0,0,0,0 + ENDFN text_symbol3 diff --git a/binutils/testsuite/binutils-all/nm.exp b/binutils/testsuite/binutils-all/nm.exp index e1b2d16..b81126b 100644 --- a/binutils/testsuite/binutils-all/nm.exp +++ b/binutils/testsuite/binutils-all/nm.exp @@ -163,6 +163,12 @@ if { [is_elf_format] || [istarget wasm32-*-*] || [istarget bpf-*-*]} { set nm_1_src "nm-elf-1.s" +} elseif {[is_coff_format] && ![istarget arm*-*-*]} { + if {[istarget *c4x-*-*] || [istarget *c54x-*-*]} { + set nm_1_src "nm-coff-sdef-1.s" + } else { + set nm_1_src "nm-coff-1.s" + } } else { set nm_1_src "nm-1.s" } diff --git a/binutils/testsuite/binutils-all/objcopy.exp b/binutils/testsuite/binutils-all/objcopy.exp index a706efb..ff93fea 100644 --- a/binutils/testsuite/binutils-all/objcopy.exp +++ b/binutils/testsuite/binutils-all/objcopy.exp @@ -1463,7 +1463,6 @@ if [is_elf_format] { run_dump_test "pr23633" run_dump_test "set-section-alignment" -run_dump_test "section-alignment" setup_xfail "hppa*-*-*" setup_xfail "spu-*-*" diff --git a/binutils/testsuite/binutils-all/section-alignment.d b/binutils/testsuite/binutils-all/section-alignment.d deleted file mode 100644 index d62528c..0000000 --- a/binutils/testsuite/binutils-all/section-alignment.d +++ /dev/null @@ -1,9 +0,0 @@ -#source: pr23633.s -#PROG: objcopy -#objcopy: --section-alignment=512 -#objdump: -P sections -#target: [is_pecoff_format] - -#... -.* Align: 512.* -#pass diff --git a/binutils/testsuite/binutils-all/set-section-alignment.d b/binutils/testsuite/binutils-all/set-section-alignment.d index a193bb7..2f6379a 100644 --- a/binutils/testsuite/binutils-all/set-section-alignment.d +++ b/binutils/testsuite/binutils-all/set-section-alignment.d @@ -2,8 +2,8 @@ #PROG: objcopy #objcopy: --set-section-alignment .text=16 #objdump: --section-headers -#target: [is_elf_format] -#xfail: rx-*-* +#target: [is_elf_format] || [is_coff_format] +#xfail: rx-*-* *c30-*-* z8k-*-* #... .*\.text.*2\*\*4 diff --git a/gas/config/loongarch-parse.y b/gas/config/loongarch-parse.y index ac35dee..97055fe 100644 --- a/gas/config/loongarch-parse.y +++ b/gas/config/loongarch-parse.y @@ -225,6 +225,9 @@ emit_bin (int op) opr1 = opr1 << opr2; break; case RIGHT_OP: + if (opr1 < 0) + as_warn(_("Right shift of negative numbers may be changed " + "from arithmetic right shift to logical right shift!")); /* Algorithm right shift. */ opr1 = (offsetT)opr1 >> (offsetT)opr2; break; diff --git a/gas/config/obj-coff.c b/gas/config/obj-coff.c index 19759cd..eb5784e 100644 --- a/gas/config/obj-coff.c +++ b/gas/config/obj-coff.c @@ -1887,8 +1887,8 @@ static const pseudo_typeS coff_pseudo_table[] = {"loc", obj_coff_loc, 0}, {"optim", s_ignore, 0}, /* For sun386i cc (?) */ {"weak", obj_coff_weak, 0}, -#if defined TC_TIC4X - /* The tic4x uses sdef instead of def. */ +#if defined (TC_TIC4X) || defined (TC_TIC54X) + /* The tic4x and tic54x use sdef instead of def. */ {"sdef", obj_coff_def, 0}, #endif #if defined(SEH_CMDS) diff --git a/gas/testsuite/gas/loongarch/loongarch.exp b/gas/testsuite/gas/loongarch/loongarch.exp index 87595b9..0e836f7 100644 --- a/gas/testsuite/gas/loongarch/loongarch.exp +++ b/gas/testsuite/gas/loongarch/loongarch.exp @@ -36,5 +36,6 @@ if [istarget loongarch*-*-*] { if [istarget loongarch64-*-*] { run_list_test "illegal-operand" run_list_test "pseudo_op_option_fail" + run_list_test "negative_right_shift" } } diff --git a/gas/testsuite/gas/loongarch/negative_right_shift.d b/gas/testsuite/gas/loongarch/negative_right_shift.d new file mode 100644 index 0000000..4237710 --- /dev/null +++ b/gas/testsuite/gas/loongarch/negative_right_shift.d @@ -0,0 +1,40 @@ +#as: +#objdump: -d +#skip: loongarch32-*-* +#warning_output: negative_right_shift.l + +.*: file format .* + + +Disassembly of section \.text: + +0+ <directives>: + 0: 03400000 nop + 4: 00000001 \.word 0x00000001 + 8: 00000001 \.word 0x00000001 + +0+c <insns>: + c: 02bff9ac addi.w \$t0, \$t1, -2 + 10: 02fff9ac addi.d \$t0, \$t1, -2 + 14: 13fff9ac addu16i.d \$t0, \$t1, -2 + 18: 15ffffcc lu12i.w \$t0, -2 + 1c: 17ffffcc lu32i.d \$t0, -2 + 20: 033ff9ac lu52i.d \$t0, \$t1, -2 + 24: 023ff9ac slti \$t0, \$t1, -2 + 28: 027ff9ac sltui \$t0, \$t1, -2 + 2c: 19ffffcc pcaddi \$t0, -2 + 30: 1dffffcc pcaddu12i \$t0, -2 + 34: 1fffffcc pcaddu18i \$t0, -2 + 38: 1bffffcc pcalau12i \$t0, -2 + 3c: 02bffdac addi.w \$t0, \$t1, -1 + 40: 02fffdac addi.d \$t0, \$t1, -1 + 44: 13fffdac addu16i.d \$t0, \$t1, -1 + 48: 15ffffec lu12i.w \$t0, -1 + 4c: 17ffffec lu32i.d \$t0, -1 + 50: 033ffdac lu52i.d \$t0, \$t1, -1 + 54: 023ffdac slti \$t0, \$t1, -1 + 58: 027ffdac sltui \$t0, \$t1, -1 + 5c: 19ffffec pcaddi \$t0, -1 + 60: 1dffffec pcaddu12i \$t0, -1 + 64: 1fffffec pcaddu18i \$t0, -1 + 68: 1bffffec pcalau12i \$t0, -1 diff --git a/gas/testsuite/gas/loongarch/negative_right_shift.l b/gas/testsuite/gas/loongarch/negative_right_shift.l new file mode 100644 index 0000000..6edb2a5 --- /dev/null +++ b/gas/testsuite/gas/loongarch/negative_right_shift.l @@ -0,0 +1,13 @@ +.*: Assembler messages: +.*: Warning: Right shift of negative numbers may be changed from arithmetic right shift to logical right shift! +.*: Warning: Right shift of negative numbers may be changed from arithmetic right shift to logical right shift! +.*: Warning: Right shift of negative numbers may be changed from arithmetic right shift to logical right shift! +.*: Warning: Right shift of negative numbers may be changed from arithmetic right shift to logical right shift! +.*: Warning: Right shift of negative numbers may be changed from arithmetic right shift to logical right shift! +.*: Warning: Right shift of negative numbers may be changed from arithmetic right shift to logical right shift! +.*: Warning: Right shift of negative numbers may be changed from arithmetic right shift to logical right shift! +.*: Warning: Right shift of negative numbers may be changed from arithmetic right shift to logical right shift! +.*: Warning: Right shift of negative numbers may be changed from arithmetic right shift to logical right shift! +.*: Warning: Right shift of negative numbers may be changed from arithmetic right shift to logical right shift! +.*: Warning: Right shift of negative numbers may be changed from arithmetic right shift to logical right shift! +.*: Warning: Right shift of negative numbers may be changed from arithmetic right shift to logical right shift! diff --git a/gas/testsuite/gas/loongarch/negative_right_shift.s b/gas/testsuite/gas/loongarch/negative_right_shift.s new file mode 100644 index 0000000..c6a8a1e --- /dev/null +++ b/gas/testsuite/gas/loongarch/negative_right_shift.s @@ -0,0 +1,32 @@ +directives: +.align -1>>62 +.word -1>>63 +.4byte -1>>63 + +insns: +addi.w $t0, $t1, -1<<1 +addi.d $t0, $t1, -1<<1 +addu16i.d $t0, $t1, -1<<1 +lu12i.w $t0, -1<<1 +lu32i.d $t0, -1<<1 +lu52i.d $t0, $t1, -1<<1 +slti $t0, $t1, -1<<1 +sltui $t0, $t1, -1<<1 +pcaddi $t0, -1<<1 +pcaddu12i $t0, -1<<1 +pcaddu18i $t0, -1<<1 +pcalau12i $t0, -1<<1 + +# warn +addi.w $t0, $t1, -1>>63 +addi.d $t0, $t1, -1>>63 +addu16i.d $t0, $t1, -1>>63 +lu12i.w $t0, -1>>63 +lu32i.d $t0, -1>>63 +lu52i.d $t0, $t1, -1>>63 +slti $t0, $t1, -1>>63 +sltui $t0, $t1, -1>>63 +pcaddi $t0, -1>>63 +pcaddu12i $t0, -1>>63 +pcaddu18i $t0, -1>>63 +pcalau12i $t0, -1>>63 @@ -35,6 +35,11 @@ a -h or --help option, which prints each options and a brief description. +* On systems that support linkage namespaces, the output of the command + "info sharedlibraries" may add one more column, NS, which identifies the + namespace into which the library was loaded, if more than one namespace + is active. + * New commands maintenance check psymtabs diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index bd107b8..0561c93 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -2696,7 +2696,7 @@ aarch64_store_return_value (struct type *type, struct regcache *regs, { /* Integral values greater than one word are stored in consecutive registers starting with r0. This will always - be a multiple of the regiser size. */ + be a multiple of the register size. */ int len = type->length (); int regno = AARCH64_X0_REGNUM; @@ -4344,7 +4344,7 @@ aarch64_initialize_sme_pseudo_names (struct gdbarch *gdbarch, } /* Initialize the current architecture based on INFO. If possible, - re-use an architecture from ARCHES, which is a list of + reuse an architecture from ARCHES, which is a list of architectures already created during this debugging session. Called e.g. at program startup, when reading a core file, and when diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index a55ee12..041024a 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -1532,7 +1532,7 @@ ada_decode (const char *encoded, bool wrap, bool operators, bool wide) { /* This is a X[bn]* sequence not separated from the previous part of the name with a non-alpha-numeric character (in other - words, immediately following an alpha-numeric character), then + words, immediately following an alphanumeric character), then verify that it is placed at the end of the encoded name. If not, then the encoding is not valid and we should abort the decoding. Otherwise, just skip it, it is used in body-nested @@ -3047,7 +3047,7 @@ ada_value_subscript (struct value *arr, int arity, struct value **ind) Note: Unlike what one would expect, this function is used instead of ada_value_subscript for basically all non-packed array types. The reason - for this is that a side effect of doing our own pointer arithmetics instead + for this is that a side effect of doing our own pointer arithmetic instead of relying on value_subscript is that there is no implicit typedef peeling. This is important for arrays of array accesses, where it allows us to preserve the fact that the array's element is an array access, where the @@ -5435,7 +5435,7 @@ ada_add_block_renamings (std::vector<struct block_symbol> &result, better in this case since, in DWARF, DW_AT_import is a DIE reference, not a simple name. But in order to do this, we would need to enhance the DWARF reader to associate a symbol to this renaming, instead of a - name. So, for now, we do something simpler: re-use the C++/Fortran + name. So, for now, we do something simpler: reuse the C++/Fortran namespace machinery. */ r_name = (renaming->alias != NULL ? renaming->alias @@ -9802,7 +9802,7 @@ ada_value_cast (struct type *type, struct value *arg2) The following description is a general guide as to what should be done (and what should NOT be done) in order to evaluate an expression involving such types, and when. This does not cover how the semantic - information is encoded by GNAT as this is covered separatly. For the + information is encoded by GNAT as this is covered separately. For the document used as the reference for the GNAT encoding, see exp_dbug.ads in the GNAT sources. @@ -11780,14 +11780,14 @@ ada_exception_support_info_sniffer (void) return; } - /* Try the v0 exception suport info. */ + /* Try the v0 exception support info. */ if (ada_has_this_exception_support (&exception_support_info_v0)) { data->exception_info = &exception_support_info_v0; return; } - /* Try our fallback exception suport info. */ + /* Try our fallback exception support info. */ if (ada_has_this_exception_support (&exception_support_info_fallback)) { data->exception_info = &exception_support_info_fallback; diff --git a/gdb/ada-varobj.c b/gdb/ada-varobj.c index 21412db..b188ea6 100644 --- a/gdb/ada-varobj.c +++ b/gdb/ada-varobj.c @@ -612,7 +612,7 @@ ada_varobj_describe_simple_array_child (struct value *parent_value, { std::string index_img = ada_varobj_scalar_image (index_type, real_index); - /* Enumeration litterals by themselves are potentially ambiguous. + /* Enumeration literals by themselves are potentially ambiguous. For instance, consider the following package spec: package Pck is @@ -620,10 +620,10 @@ ada_varobj_describe_simple_array_child (struct value *parent_value, type Blood_Cells is (White, Red); end Pck; - In this case, the litteral "red" for instance, or even - the fully-qualified litteral "pck.red" cannot be resolved + In this case, the literal "red" for instance, or even + the fully-qualified literal "pck.red" cannot be resolved by itself. Type qualification is needed to determine which - enumeration litterals should be used. + enumeration literals should be used. The following variable will be used to contain the name of the array index type when such type qualification is diff --git a/gdb/alpha-tdep.c b/gdb/alpha-tdep.c index 7201b72..bf3e8fc3 100644 --- a/gdb/alpha-tdep.c +++ b/gdb/alpha-tdep.c @@ -1705,7 +1705,7 @@ alpha_software_single_step (struct regcache *regcache) } -/* Initialize the current architecture based on INFO. If possible, re-use an +/* Initialize the current architecture based on INFO. If possible, reuse an architecture from ARCHES, which is a list of architectures already created during this debugging session. diff --git a/gdb/amd64-fbsd-nat.c b/gdb/amd64-fbsd-nat.c index 6ce7c45..613f275 100644 --- a/gdb/amd64-fbsd-nat.c +++ b/gdb/amd64-fbsd-nat.c @@ -137,7 +137,7 @@ amd64_fbsd_nat_target::fetch_registers (struct regcache *regcache, int regnum) /* There is no amd64_fxsave_supplies or amd64_xsave_supplies. Instead, the earlier register sets return early if the request - was for a specific register that was already satisified to avoid + was for a specific register that was already satisfied to avoid fetching the FPU/XSAVE state unnecessarily. */ #ifdef PT_GETXSTATE_INFO @@ -214,7 +214,7 @@ amd64_fbsd_nat_target::store_registers (struct regcache *regcache, int regnum) /* There is no amd64_fxsave_supplies or amd64_xsave_supplies. Instead, the earlier register sets return early if the request - was for a specific register that was already satisified to avoid + was for a specific register that was already satisfied to avoid fetching the FPU/XSAVE state unnecessarily. */ #ifdef PT_GETXSTATE_INFO diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c index bebfd0d..3c58b85 100644 --- a/gdb/amd64-tdep.c +++ b/gdb/amd64-tdep.c @@ -2608,7 +2608,7 @@ amd64_skip_xmm_prologue (CORE_ADDR pc, CORE_ADDR start_pc) if (next_sal.line != start_pc_sal.line) return pc; - /* START_PC can be from overlayed memory, ignored here. */ + /* START_PC can be from overlay memory, ignored here. */ if (target_read_code (next_sal.pc - 4, buf, sizeof (buf)) != 0) return pc; diff --git a/gdb/arm-linux-nat.c b/gdb/arm-linux-nat.c index 7b4faac..1aa591a 100644 --- a/gdb/arm-linux-nat.c +++ b/gdb/arm-linux-nat.c @@ -714,7 +714,7 @@ struct arm_linux_hw_breakpoint The Linux ptrace interface to hardware break-/watch-points presents the values in a vector centred around 0 (which is used fo generic information). - Positive indicies refer to breakpoint addresses/control registers, negative + Positive indices refer to breakpoint addresses/control registers, negative indices to watchpoint addresses/control registers. The Linux vector is indexed as follows: diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index 879f5cf..b985ca8 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -9202,7 +9202,7 @@ arm_store_return_value (struct type *type, struct regcache *regs, { /* Integral values greater than one word are stored in consecutive registers starting with r0. This will always be a multiple of - the regiser size. */ + the register size. */ int len = type->length (); int regno = ARM_A1_REGNUM; @@ -10103,7 +10103,7 @@ arm_get_pc_address_flags (const frame_info_ptr &frame, CORE_ADDR pc) } /* Initialize the current architecture based on INFO. If possible, - re-use an architecture from ARCHES, which is a list of + reuse an architecture from ARCHES, which is a list of architectures already created during this debugging session. Called e.g. at program startup, when reading a core file, and when diff --git a/gdb/bcache.c b/gdb/bcache.c index a9aab28..fe2c76d 100644 --- a/gdb/bcache.c +++ b/gdb/bcache.c @@ -250,7 +250,7 @@ print_percentage (int portion, int total) } -/* Print statistics on BCACHE's memory usage and efficacity at +/* Print statistics on BCACHE's memory usage and efficacy at eliminating duplication. NAME should describe the kind of data BCACHE holds. Statistics are printed using `gdb_printf' and its ilk. */ diff --git a/gdb/bcache.h b/gdb/bcache.h index 82cdd13..2e05a15 100644 --- a/gdb/bcache.h +++ b/gdb/bcache.h @@ -173,7 +173,7 @@ struct bcache added); } - /* Print statistics on this bcache's memory usage and efficacity at + /* Print statistics on this bcache's memory usage and efficacy at eliminating duplication. TYPE should be a string describing the kind of data this bcache holds. Statistics are printed using `gdb_printf' and its ilk. */ diff --git a/gdb/bfin-tdep.c b/gdb/bfin-tdep.c index 78ade80..f8294ed 100644 --- a/gdb/bfin-tdep.c +++ b/gdb/bfin-tdep.c @@ -769,7 +769,7 @@ bfin_abi (struct gdbarch *gdbarch) } /* Initialize the current architecture based on INFO. If possible, - re-use an architecture from ARCHES, which is a list of + reuse an architecture from ARCHES, which is a list of architectures already created during this debugging session. Called e.g. at program startup, when reading a core file, and when diff --git a/gdb/bpf-tdep.c b/gdb/bpf-tdep.c index 8f3e50d..41c9738 100644 --- a/gdb/bpf-tdep.c +++ b/gdb/bpf-tdep.c @@ -307,7 +307,7 @@ bpf_return_value (struct gdbarch *gdbarch, struct value *function, } -/* Initialize the current architecture based on INFO. If possible, re-use an +/* Initialize the current architecture based on INFO. If possible, reuse an architecture from ARCHES, which is a list of architectures already created during this debugging session. */ diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h index 94fba1c..ec3a128 100644 --- a/gdb/breakpoint.h +++ b/gdb/breakpoint.h @@ -1740,7 +1740,7 @@ extern void disable_overlay_breakpoints (void); extern void set_std_terminate_breakpoint (void); extern void delete_std_terminate_breakpoint (void); -/* These functions respectively disable or reenable all currently +/* These functions respectively disable or re-enable all currently enabled watchpoints. When disabled, the watchpoints are marked call_disabled. When re-enabled, they are marked enabled. diff --git a/gdb/btrace.c b/gdb/btrace.c index 152f6f2..4a056d2 100644 --- a/gdb/btrace.c +++ b/gdb/btrace.c @@ -1531,23 +1531,23 @@ handle_pt_insn_events (struct btrace_thread_info *btinfo, if (event.variant.vmexit.has_vmxr != 0) { - std::string seperator = aux_string.back () == ':' ? "" : ","; - aux_string += seperator + std::string (" vmxr = ") + std::string separator = aux_string.back () == ':' ? "" : ","; + aux_string += separator + std::string (" vmxr = ") + hex_string (event.variant.vmexit.vmxr); } if (event.variant.vmexit.has_vmxq != 0) { - std::string seperator = aux_string.back () == ':' ? "" : ","; - aux_string += seperator + std::string (" vmxq = ") + std::string separator = aux_string.back () == ':' ? "" : ","; + aux_string += separator + std::string (" vmxq = ") + hex_string (event.variant.vmexit.vmxq); } if (event.ip_suppressed == 0) { pc = event.variant.vmexit.ip; - std::string seperator = aux_string.back () == ':' ? "" : ","; - aux_string += seperator + std::string (" ip = ") + std::string separator = aux_string.back () == ':' ? "" : ","; + aux_string += separator + std::string (" ip = ") + hex_string (*pc); } @@ -2136,7 +2136,7 @@ btrace_stitch_bts (struct btrace_data_bts *btrace, struct thread_info *tp) /* Adjust the block trace in order to stitch old and new trace together. BTRACE is the new delta trace between the last and the current stop. TP is the traced thread. - May modifx BTRACE as well as the existing trace in TP. + May modify BTRACE as well as the existing trace in TP. Return 0 on success, -1 otherwise. */ static int diff --git a/gdb/buildsym.h b/gdb/buildsym.h index 1d30f55..49e44a8 100644 --- a/gdb/buildsym.h +++ b/gdb/buildsym.h @@ -55,7 +55,7 @@ struct subfile struct subfile *next = nullptr; std::string name; - /* This field is analoguous in function to symtab::filename_for_id. + /* This field is analogous in function to symtab::filename_for_id. It is used to look up existing subfiles in calls to start_subfile. */ std::string name_for_id; diff --git a/gdb/coffread.c b/gdb/coffread.c index c470668..e580f8c 100644 --- a/gdb/coffread.c +++ b/gdb/coffread.c @@ -903,7 +903,7 @@ coff_symtab_read (minimal_symbol_reader &reader, symnum = 0; while (symnum < nsyms) { - QUIT; /* Make this command interruptable. */ + QUIT; /* Make this command interruptible. */ read_one_sym (cs, &main_sym, &main_aux); diff --git a/gdb/command.h b/gdb/command.h index 37c7ddf..7e6761d 100644 --- a/gdb/command.h +++ b/gdb/command.h @@ -558,7 +558,7 @@ extern struct cmd_list_element *lookup_cmd (const char **, the section of text it matched, set *RESULT_LIST to point to the list in which the last word was matched, and will return a pointer to the cmd list element which the text matches. It will return NULL if no match at - all was possible. It will return -1 (cast appropriately, ick) if ambigous + all was possible. It will return -1 (cast appropriately, ick) if ambiguous matches are possible; in this case *RESULT_LIST will be set to point to the list in which there are ambiguous choices (and *TEXT will be set to the ambiguous text string). diff --git a/gdb/completer.c b/gdb/completer.c index 4735aa5..0a8409b 100644 --- a/gdb/completer.c +++ b/gdb/completer.c @@ -356,7 +356,7 @@ gdb_completer_file_name_quote_1 (const char *text, char quote_char) if (quote_char == '\'') { /* There is no backslash escaping permitted within a single quoted - string, so in this case we can just return the input sting. */ + string, so in this case we can just return the input string. */ str = text; } else if (quote_char == '"') diff --git a/gdb/completer.h b/gdb/completer.h index 07953f1..22d85a8 100644 --- a/gdb/completer.h +++ b/gdb/completer.h @@ -722,7 +722,7 @@ extern void complete_nested_command_line (completion_tracker &tracker, This function is designed so that trying to complete '/' will offer no completions, the user needs to insert the format specification themselves. Trying to complete '/FMT' (where FMT is any non-empty set - of alpha-numeric characters) will cause readline to insert a single + of alphanumeric characters) will cause readline to insert a single space, setting the user up to enter the expression. */ extern bool skip_over_slash_fmt (completion_tracker &tracker, diff --git a/gdb/contrib/setup.cfg b/gdb/contrib/setup.cfg index dbff165..670a850 100644 --- a/gdb/contrib/setup.cfg +++ b/gdb/contrib/setup.cfg @@ -4,3 +4,6 @@ skip = */ChangeLog*,*/configure,gdbsupport/Makefile.in,*.dat,*.eps,gdb/features/*.c,gdb/ada-casefold.h,gdb/copying.c,gdb/gdbarch-gen.h,gdb/gdbarch-gen.c,gdb/target-delegates-gen.c ignore-words = gdb/contrib/codespell-ignore-words.txt + +# Ignore all URLs. +uri-ignore-words-list = * diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c index 370cb36..46cefc6 100644 --- a/gdb/cp-namespace.c +++ b/gdb/cp-namespace.c @@ -926,7 +926,7 @@ cp_lookup_nested_symbol (struct type *parent_type, case TYPE_CODE_NAMESPACE: case TYPE_CODE_UNION: case TYPE_CODE_ENUM: - /* NOTE: Handle modules here as well, because Fortran is re-using the C++ + /* NOTE: Handle modules here as well, because Fortran is reusing the C++ specific code to lookup nested symbols in modules, by calling the method lookup_symbol_nonlocal, which ends up here. */ case TYPE_CODE_MODULE: diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c index 2634c1e..2077fa3 100644 --- a/gdb/cp-valprint.c +++ b/gdb/cp-valprint.c @@ -100,7 +100,7 @@ cp_is_vtbl_member (struct type *type) /* The type name of the thunk pointer is NULL when using dwarf2. We could test for a pointer to a function, but there is no type info for the virtual table either, so it - wont help. */ + won't help. */ return cp_is_vtbl_ptr_type (type); } } diff --git a/gdb/cris-tdep.c b/gdb/cris-tdep.c index f531b4c..519ea43 100644 --- a/gdb/cris-tdep.c +++ b/gdb/cris-tdep.c @@ -1467,7 +1467,7 @@ cris_register_size (struct gdbarch *gdbarch, int regno) } /* Nonzero if regno should not be fetched from the target. This is the case - for unimplemented (size 0) and non-existant registers. */ + for unimplemented (size 0) and non-existent registers. */ static int cris_cannot_fetch_register (struct gdbarch *gdbarch, int regno) @@ -1508,7 +1508,7 @@ cris_cannot_store_register (struct gdbarch *gdbarch, int regno) } /* Nonzero if regno should not be fetched from the target. This is the case - for unimplemented (size 0) and non-existant registers. */ + for unimplemented (size 0) and non-existent registers. */ static int crisv32_cannot_fetch_register (struct gdbarch *gdbarch, int regno) diff --git a/gdb/csky-tdep.c b/gdb/csky-tdep.c index 4f41a51..4f3d9d8 100644 --- a/gdb/csky-tdep.c +++ b/gdb/csky-tdep.c @@ -1072,7 +1072,7 @@ csky_analyze_prologue (struct gdbarch *gdbarch, } else if (CSKY_32_IS_MOV_FP_SP (insn)) { - /* SP is saved to FP reg, means code afer prologue may + /* SP is saved to FP reg, means code after prologue may modify SP. */ is_fp_saved = 1; adjust_fp = stacksize; @@ -2667,7 +2667,7 @@ csky_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache, } /* Initialize the current architecture based on INFO. If possible, - re-use an architecture from ARCHES, which is a list of + reuse an architecture from ARCHES, which is a list of architectures already created during this debugging session. Called at program startup, when reading a core file, and when diff --git a/gdb/displaced-stepping.h b/gdb/displaced-stepping.h index 7949e5d..2806107 100644 --- a/gdb/displaced-stepping.h +++ b/gdb/displaced-stepping.h @@ -246,7 +246,7 @@ private: std::vector<displaced_step_buffer> m_buffers; }; -/* Default implemention of target_ops::supports_displaced_step. +/* Default implementation of target_ops::supports_displaced_step. Forwards the call to the architecture of THREAD. */ diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index e034ac5..4e4509a 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -22172,6 +22172,11 @@ be determined then the address range for the @code{.text} section from the library will be listed. If the @code{.text} section cannot be found then no addresses will be listed. +On systems that support linkage namespaces, the output includes an +additional column @code{NS} if the inferior has more than one active +namespace when the command is used. This column the linkage namespace +that the shared library was loaded into. + @kindex info dll @item info dll @var{regex} This is an alias of @code{info sharedlibrary}. diff --git a/gdb/dtrace-probe.c b/gdb/dtrace-probe.c index ac1b1c5..a5bc9d8 100644 --- a/gdb/dtrace-probe.c +++ b/gdb/dtrace-probe.c @@ -424,7 +424,7 @@ dtrace_process_dof_probe (struct objfile *objfile, It follows that if there are DTrace is-enabled probes defined for some provider/name but no DTrace regular probes defined then the - GDB user wont be able to enable/disable these conditionals. */ + GDB user won't be able to enable/disable these conditionals. */ num_probes = DOF_UINT (dof, probe->dofpr_noffs); if (num_probes == 0) diff --git a/gdb/dwarf2/aranges.c b/gdb/dwarf2/aranges.c index 7016eee..ac530ab 100644 --- a/gdb/dwarf2/aranges.c +++ b/gdb/dwarf2/aranges.c @@ -59,6 +59,7 @@ read_addrmap_from_aranges (dwarf2_per_objfile *per_objfile, gdb::unordered_set<sect_offset> debug_info_offset_seen; const bfd_endian dwarf5_byte_order = gdbarch_byte_order (gdbarch); + const int signed_addr_p = bfd_get_sign_extend_vma (abfd); const gdb_byte *addr = section->buffer; while (addr < section->buffer + section->size) { @@ -167,8 +168,13 @@ read_addrmap_from_aranges (dwarf2_per_objfile *per_objfile, plongest (entry_addr - section->buffer)); return false; } - ULONGEST start = extract_unsigned_integer (addr, address_size, - dwarf5_byte_order); + ULONGEST start; + if (signed_addr_p) + start = extract_signed_integer (addr, address_size, + dwarf5_byte_order); + else + start = extract_unsigned_integer (addr, address_size, + dwarf5_byte_order); addr += address_size; ULONGEST length = extract_unsigned_integer (addr, address_size, dwarf5_byte_order); diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 17f06ff..71fd352 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -2970,7 +2970,7 @@ cutu_reader::cutu_reader (dwarf2_per_cu &this_cu, dwarf2_cu *existing_cu, bool skip_partial, enum language pretend_language, - const abbrev_table_cache *cache) + const abbrev_table_cache *abbrev_cache) { struct objfile *objfile = per_objfile.objfile; struct dwarf2_section_info *section = this_cu.section; @@ -3030,7 +3030,7 @@ cutu_reader::cutu_reader (dwarf2_per_cu &this_cu, indexer. This assert is avoided in this case because (1) it is irrelevant, and (2) the get_cu method is not thread-safe. */ - gdb_assert (cache != nullptr + gdb_assert (abbrev_cache != nullptr || per_objfile.get_cu (&this_cu) == nullptr); m_new_cu = std::make_unique<dwarf2_cu> (&this_cu, &per_objfile); cu = m_new_cu.get (); @@ -3092,9 +3092,9 @@ cutu_reader::cutu_reader (dwarf2_per_cu &this_cu, gdb_assert (cu->header.abbrev_sect_off == abbrev_table->sect_off); else { - if (cache != nullptr) - abbrev_table = cache->find (abbrev_section, - cu->header.abbrev_sect_off); + if (abbrev_cache != nullptr) + abbrev_table = abbrev_cache->find (abbrev_section, + cu->header.abbrev_sect_off); if (abbrev_table == nullptr) { abbrev_section->read (objfile); diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h index 7f56dac..b13e42d 100644 --- a/gdb/dwarf2/read.h +++ b/gdb/dwarf2/read.h @@ -927,7 +927,7 @@ public: dwarf2_cu *existing_cu, bool skip_partial, enum language pretend_language, - const abbrev_table_cache *cache = nullptr); + const abbrev_table_cache *abbrev_cache = nullptr); cutu_reader (dwarf2_per_cu &this_cu, dwarf2_per_objfile &per_objfile, diff --git a/gdb/elfread.c b/gdb/elfread.c index 3756fa3..ed664bc 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -898,7 +898,7 @@ elf_gnu_ifunc_resolve_name (const char *name, CORE_ADDR *addr_p) return false; } -/* Call STT_GNU_IFUNC - a function returning addresss of a real function to +/* Call STT_GNU_IFUNC - a function returning address of a real function to call. PC is theSTT_GNU_IFUNC resolving function entry. The value returned is the entry point of the resolved STT_GNU_IFUNC target function to call. */ diff --git a/gdb/extension-priv.h b/gdb/extension-priv.h index a38f104..4bec129 100644 --- a/gdb/extension-priv.h +++ b/gdb/extension-priv.h @@ -262,12 +262,13 @@ struct extension_language_ops const char *method_name, std::vector<xmethod_worker_up> *dm_vec); - /* Colorize a source file. NAME is the source file's name, and - CONTENTS is the contents of the file. This should either return - colorized (using ANSI terminal escapes) version of the contents, + /* Colorize a source file. NAME is the source file's name, CONTENTS is the + contents of the file, and LANG is the language. This should either + return colorized (using ANSI terminal escapes) version of the contents, or an empty option. */ std::optional<std::string> (*colorize) (const std::string &name, - const std::string &contents); + const std::string &contents, + enum language lang); /* Colorize a single line of disassembler output, CONTENT. This should either return colorized (using ANSI terminal escapes) version of the diff --git a/gdb/extension.c b/gdb/extension.c index b78ea4f..f8fef0c 100644 --- a/gdb/extension.c +++ b/gdb/extension.c @@ -974,7 +974,8 @@ xmethod_worker::get_result_type (value *object, gdb::array_view<value *> args) /* See extension.h. */ std::optional<std::string> -ext_lang_colorize (const std::string &filename, const std::string &contents) +ext_lang_colorize (const std::string &filename, const std::string &contents, + enum language lang) { std::optional<std::string> result; @@ -983,7 +984,7 @@ ext_lang_colorize (const std::string &filename, const std::string &contents) if (extlang->ops == nullptr || extlang->ops->colorize == nullptr) continue; - result = extlang->ops->colorize (filename, contents); + result = extlang->ops->colorize (filename, contents, lang); if (result.has_value ()) return result; } diff --git a/gdb/extension.h b/gdb/extension.h index 957642a..5763e41 100644 --- a/gdb/extension.h +++ b/gdb/extension.h @@ -325,12 +325,14 @@ extern void get_matching_xmethod_workers std::vector<xmethod_worker_up> *workers); /* Try to colorize some source code. FILENAME is the name of the file - holding the code. CONTENTS is the source code itself. This will - either a colorized (using ANSI terminal escapes) version of the - source code, or an empty value if colorizing could not be done. */ + holding the code. CONTENTS is the source code itself. LANG is the + language of the CONTENTS. This will either a colorized (using ANSI + terminal escapes) version of the source code, or an empty value if + colorizing could not be done. */ extern std::optional<std::string> ext_lang_colorize - (const std::string &filename, const std::string &contents); + (const std::string &filename, const std::string &contents, + enum language lang); /* Try to colorize a single line of disassembler output, CONTENT for GDBARCH. This will return either a colorized (using ANSI terminal diff --git a/gdb/frame-base.h b/gdb/frame-base.h index 8436929..ba12c70 100644 --- a/gdb/frame-base.h +++ b/gdb/frame-base.h @@ -32,7 +32,7 @@ struct regcache; the NEXT frame's register unwind method, to determine the address of THIS frame's `base'. - The exact meaning of `base' is highly dependant on the type of the + The exact meaning of `base' is highly dependent on the type of the debug info. It is assumed that dwarf2, stabs, ... will each provide their own methods. diff --git a/gdb/frame.h b/gdb/frame.h index e207c71..5dd0d16 100644 --- a/gdb/frame.h +++ b/gdb/frame.h @@ -586,7 +586,7 @@ void set_current_sal_from_frame (const frame_info_ptr &); the old get_frame_base method was not sufficient. get_frame_base_address: get_frame_locals_address: - get_frame_args_address: A set of high-level debug-info dependant + get_frame_args_address: A set of high-level debug-info dependent addresses that fall within the frame. These addresses almost certainly will not match the stack address part of a frame ID (as returned by get_frame_base). diff --git a/gdb/ft32-tdep.c b/gdb/ft32-tdep.c index 2ef77a2..8b8b661 100644 --- a/gdb/ft32-tdep.c +++ b/gdb/ft32-tdep.c @@ -310,7 +310,7 @@ ft32_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) return sal.end; } } - /* No useable line symbol. Use result of prologue parsing method. */ + /* No usable line symbol. Use result of prologue parsing method. */ return plg_end; } } diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h index 786b720..f179151 100644 --- a/gdb/gdbarch.h +++ b/gdb/gdbarch.h @@ -210,7 +210,7 @@ gdbarch_tdep (struct gdbarch *gdbarch) information obtained from INFO.ABFD or the global defaults. The ARCHES parameter is a linked list (sorted most recently used) - of all the previously created architures for this architecture + of all the previously created architectures for this architecture family. The (possibly NULL) ARCHES->gdbarch can used to access values from the previously selected architecture for this architecture family. diff --git a/gdb/gdbthread.h b/gdb/gdbthread.h index 6cffd86..ff1cdc6 100644 --- a/gdb/gdbthread.h +++ b/gdb/gdbthread.h @@ -70,10 +70,10 @@ extern bool debug_threads; you want. */ enum thread_state { - /* In the frontend's perpective, the thread is stopped. */ + /* In the frontend's perspective, the thread is stopped. */ THREAD_STOPPED, - /* In the frontend's perpective, the thread is running. */ + /* In the frontend's perspective, the thread is running. */ THREAD_RUNNING, /* The thread is listed, but known to have exited. We keep it diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c index b51c4d2..70d66a5 100644 --- a/gdb/gnu-v3-abi.c +++ b/gdb/gnu-v3-abi.c @@ -1178,7 +1178,7 @@ gnuv3_get_type_from_type_info (struct value *type_info_ptr) { /* We have to parse the type name, since in general there is not a symbol for a type. This is somewhat bogus since there may be a - mis-parse. Another approach might be to re-use the demangler's + mis-parse. Another approach might be to reuse the demangler's internal form to reconstruct the type somehow. */ std::string type_name = gnuv3_get_typename_from_type_info (type_info_ptr); expression_up expr (parse_expression (type_name.c_str ())); diff --git a/gdb/guile/scm-value.c b/gdb/guile/scm-value.c index 0f4a6a4..88132e0 100644 --- a/gdb/guile/scm-value.c +++ b/gdb/guile/scm-value.c @@ -604,7 +604,7 @@ gdbscm_value_dynamic_type (SCM self) type = value_rtti_type (value, NULL, NULL, NULL); else { - /* Re-use object's static type. */ + /* Reuse object's static type. */ type = NULL; } } diff --git a/gdb/h8300-tdep.c b/gdb/h8300-tdep.c index a845900..6cffd06 100644 --- a/gdb/h8300-tdep.c +++ b/gdb/h8300-tdep.c @@ -541,7 +541,7 @@ h8300_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) /* Found a line number, use it as end of prologue. */ return sal.end; - /* No useable line symbol. Use prologue parsing method. */ + /* No usable line symbol. Use prologue parsing method. */ h8300_init_frame_cache (gdbarch, &cache); return h8300_analyze_prologue (gdbarch, func_addr, func_end, &cache); } diff --git a/gdb/hppa-linux-tdep.c b/gdb/hppa-linux-tdep.c index f43a5e7..f9723ce 100644 --- a/gdb/hppa-linux-tdep.c +++ b/gdb/hppa-linux-tdep.c @@ -322,7 +322,7 @@ static const struct frame_unwind_legacy hppa_linux_sigtramp_frame_unwind ( /* Attempt to find (and return) the global pointer for the given function. - This is a rather nasty bit of code searchs for the .dynamic section + This rather nasty bit of code searches for the .dynamic section in the objfile corresponding to the pc of the function we're trying to call. Once it finds the addresses at which the .dynamic section lives in the child process, it scans the Elf32_Dyn entries for a diff --git a/gdb/i386-fbsd-nat.c b/gdb/i386-fbsd-nat.c index d9f4067..3b3ca49 100644 --- a/gdb/i386-fbsd-nat.c +++ b/gdb/i386-fbsd-nat.c @@ -92,7 +92,7 @@ i386_fbsd_nat_target::fetch_registers (struct regcache *regcache, int regnum) /* There is no i386_fxsave_supplies or i386_xsave_supplies. Instead, the earlier register sets return early if the request - was for a specific register that was already satisified to avoid + was for a specific register that was already satisfied to avoid fetching the FPU/XSAVE state unnecessarily. */ #ifdef PT_GETXSTATE_INFO @@ -171,7 +171,7 @@ i386_fbsd_nat_target::store_registers (struct regcache *regcache, int regnum) /* There is no i386_fxsave_supplies or i386_xsave_supplies. Instead, the earlier register sets return early if the request - was for a specific register that was already satisified to avoid + was for a specific register that was already satisfied to avoid fetching the FPU/XSAVE state unnecessarily. */ #ifdef PT_GETXSTATE_INFO diff --git a/gdb/i386-sol2-nat.c b/gdb/i386-sol2-nat.c index 20ca9d6..665756a 100644 --- a/gdb/i386-sol2-nat.c +++ b/gdb/i386-sol2-nat.c @@ -25,7 +25,7 @@ #include "target.h" #include "procfs.h" -/* This file provids the (temporary) glue between the Solaris x86 +/* This file provides the (temporary) glue between the Solaris x86 target dependent code and the machine independent SVR4 /proc support. */ diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index 1d6d592..f14a0d3 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -2322,7 +2322,7 @@ static const struct frame_unwind_legacy i386_epilogue_frame_unwind ( /* These trampolines are used on cross x86 targets, when taking the address of a nested function. When executing these trampolines, no stack frame is set up, so we are in a similar situation as in - epilogues and i386_epilogue_frame_this_id can be re-used. */ + epilogues and i386_epilogue_frame_this_id can be reused. */ /* Static chain passed in register. */ @@ -5015,7 +5015,7 @@ i386_record_vex (struct i386_record_s *ir, uint8_t vex_w, uint8_t vex_r, case 0x5e: /* VDIV[P|S][S|D] */ case 0x5f: /* VMAX[P|S][S|D] */ { - /* vpbroadcast and arithmethic operations are differentiated + /* vpbroadcast and arithmetic operations are differentiated by map_select, but it doesn't change the recording mechanics. */ i386_record_modrm (ir); int reg_offset = ir->reg + vex_r * 8; diff --git a/gdb/ia64-tdep.c b/gdb/ia64-tdep.c index 11375d5..00b48af 100644 --- a/gdb/ia64-tdep.c +++ b/gdb/ia64-tdep.c @@ -596,7 +596,7 @@ fetch_instruction (CORE_ADDR addr, ia64_instruction_type *it, long long *instr) If we would like to store the whole bundle to SHADOW_CONTENTS we would have to store already the base address (`address & ~0x0f') into PLACED_ADDRESS. In such case there is no other place where to store - SLOTNUM (`adress & 0x0f', value in the range <0..2>). We need to know + SLOTNUM (`address & 0x0f', value in the range <0..2>). We need to know SLOTNUM in ia64_memory_remove_breakpoint. There is one special case where we need to be extra careful: @@ -3111,7 +3111,7 @@ static const struct frame_unwind_legacy ia64_libunwind_sigtramp_frame_unwind ( ia64_libunwind_sigtramp_frame_sniffer ); -/* Set of libunwind callback acccessor functions. */ +/* Set of libunwind callback accessor functions. */ unw_accessors_t ia64_unw_accessors = { ia64_find_proc_info_x, @@ -3124,7 +3124,7 @@ unw_accessors_t ia64_unw_accessors = /* get_proc_name */ }; -/* Set of special libunwind callback acccessor functions specific for accessing +/* Set of special libunwind callback accessor functions specific for accessing the rse registers. At the top of the stack, we want libunwind to figure out how to read r32 - r127. Though usually they are found sequentially in memory starting from $bof, this is not always true. */ @@ -3415,7 +3415,7 @@ slot_alignment_is_next_even (struct type *t) /* Attempt to find (and return) the global pointer for the given function. - This is a rather nasty bit of code searchs for the .dynamic section + This rather nasty bit of code searches for the .dynamic section in the objfile corresponding to the pc of the function we're trying to call. Once it finds the addresses at which the .dynamic section lives in the child process, it scans the Elf64_Dyn entries for a diff --git a/gdb/ia64-vms-tdep.c b/gdb/ia64-vms-tdep.c index 20308c7..ef8f42d 100644 --- a/gdb/ia64-vms-tdep.c +++ b/gdb/ia64-vms-tdep.c @@ -118,7 +118,7 @@ ia64_vms_get_dyn_info_list (unw_addr_space_t as, return -UNW_ENOINFO; } -/* Set of libunwind callback acccessor functions. */ +/* Set of libunwind callback accessor functions. */ static unw_accessors_t ia64_vms_unw_accessors; static unw_accessors_t ia64_vms_unw_rse_accessors; diff --git a/gdb/inf-loop.c b/gdb/inf-loop.c index ec0c059..565acca 100644 --- a/gdb/inf-loop.c +++ b/gdb/inf-loop.c @@ -74,7 +74,7 @@ inferior_event_handler (enum inferior_event_type event_type) { /* If the user was running a foreground execution command, then propagate the error so that the prompt - can be reenabled. Otherwise, the user already has + can be re-enabled. Otherwise, the user already has the prompt and is typing some unrelated command, so just inform the user and swallow the exception. */ if (current_ui->prompt_state == PROMPT_BLOCKED) diff --git a/gdb/infcall.c b/gdb/infcall.c index 6399278..af3ad0a 100644 --- a/gdb/infcall.c +++ b/gdb/infcall.c @@ -1276,7 +1276,7 @@ call_function_by_hand_dummy (struct value *function, /* A call dummy always consists of just a single breakpoint, so its address is the same as the address of the dummy. - The actual breakpoint is inserted separatly so there is no need to + The actual breakpoint is inserted separately so there is no need to write that out. */ bp_addr = dummy_addr; break; diff --git a/gdb/infrun.c b/gdb/infrun.c index 9f5b3d4..e03942d 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -9444,7 +9444,7 @@ struct stop_context ptid_t ptid; - /* If stopp for a thread event, this is the thread that caused the + /* If stopped for a thread event, this is the thread that caused the stop. */ thread_info_ref thread; diff --git a/gdb/iq2000-tdep.c b/gdb/iq2000-tdep.c index 094f627..6ec37fc 100644 --- a/gdb/iq2000-tdep.c +++ b/gdb/iq2000-tdep.c @@ -348,7 +348,7 @@ iq2000_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) /* Found a line number, use it as end of prologue. */ return sal.end; - /* No useable line symbol. Use prologue parsing method. */ + /* No usable line symbol. Use prologue parsing method. */ iq2000_init_frame_cache (&cache); return iq2000_scan_prologue (gdbarch, func_addr, func_end, NULL, &cache); } diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c index 1727a06..e58fd66 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -133,7 +133,7 @@ process things as in sync mode, except that the we never block in sigsuspend. While processing an event, we may end up momentarily blocked in -waitpid calls. Those waitpid calls, while blocking, are guarantied to +waitpid calls. Those waitpid calls, while blocking, are guaranteed to return quickly. E.g., in all-stop mode, before reporting to the core that an LWP hit a breakpoint, all LWPs are stopped by sending them SIGSTOP, and synchronously waiting for the SIGSTOP to be reported. @@ -702,7 +702,7 @@ lwp_lwpid_htab_add_lwp (struct lwp_info *lp) /* Head of doubly-linked list of known LWPs. Sorted by reverse creation order. This order is assumed in some cases. E.g., - reaping status after killing alls lwps of a process: the leader LWP + reaping status after killing all lwps of a process: the leader LWP must be reaped last. */ static intrusive_list<lwp_info> lwp_list; diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c index fec6a63..852fea7 100644 --- a/gdb/linux-tdep.c +++ b/gdb/linux-tdep.c @@ -1073,7 +1073,7 @@ linux_info_proc (struct gdbarch *gdbarch, const char *args, gdb_printf (_("Ignored signals bitmap: %s\n"), hex_string (strtoulst (p, &p, 10))); if (*p) - gdb_printf (_("Catched signals bitmap: %s\n"), + gdb_printf (_("Caught signals bitmap: %s\n"), hex_string (strtoulst (p, &p, 10))); if (*p) gdb_printf (_("wchan (system call): %s\n"), @@ -2749,7 +2749,7 @@ linux_vsyscall_range_raw (struct gdbarch *gdbarch, struct mem_range *range) in the output, which requires scanning every thread in the thread group to check whether a VMA is actually a thread's stack. With Linux 4.4 on an Intel i7-4810MQ @ 2.80GHz, with an inferior with - a few thousand threads, (1) takes a few miliseconds, while (2) + a few thousand threads, (1) takes a few milliseconds, while (2) takes several seconds. Also note that "smaps", what we read for determining core dump mappings, is even slower than "maps". */ xsnprintf (filename, sizeof filename, "/proc/%ld/task/%ld/maps", pid, pid); diff --git a/gdb/loongarch-linux-tdep.c b/gdb/loongarch-linux-tdep.c index 031031b..14d1887 100644 --- a/gdb/loongarch-linux-tdep.c +++ b/gdb/loongarch-linux-tdep.c @@ -938,7 +938,7 @@ loongarch_record_all_but_pc_registers (struct regcache *regcache) return 0; } -/* Handler for LoongArch architechture system call instruction recording. */ +/* Handler for LoongArch architecture system call instruction recording. */ static int loongarch_linux_syscall_record (struct regcache *regcache, diff --git a/gdb/machoread.c b/gdb/machoread.c index ac764c0..a9b1bea 100644 --- a/gdb/machoread.c +++ b/gdb/machoread.c @@ -164,7 +164,7 @@ macho_symtab_read (minimal_symbol_reader &reader, S_NO_SO, /* First SO read. Introduce an SO section, and may be followed by a second - SO. The SO section should contain onl debugging symbols. */ + SO. The SO section should contain only debugging symbols. */ S_FIRST_SO, /* Second non-null SO found, just after the first one. Means that the first @@ -1124,7 +1124,7 @@ captured_main_1 (struct captured_main_args *context) /* Do these (and anything which might call wrap_here or *_filtered) after initialize_all_files() but before the interpreter has been - installed. Otherwize the help/version messages will be eaten by + installed. Otherwise the help/version messages will be eaten by the interpreter's output handler. */ if (print_version) diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index d5a0740..cdfac15 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -1119,7 +1119,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend, case_stBlock_code: found_ecoff_debugging_info = 1; - /* Beginnning of (code) block. Value of symbol + /* Beginning of (code) block. Value of symbol is the displacement from procedure start. */ push_parse_stack (); @@ -2122,7 +2122,7 @@ parse_external (EXTR *es, int bigend, const section_offsets §ion_offsets, /* There is no need to parse the external procedure symbols. If they are from objects compiled without -g, their index will be indexNil, and the symbol definition from the minimal symbol - is preferrable (yielding a function returning int instead of int). + is preferable (yielding a function returning int instead of int). If the index points to a local procedure symbol, the local symbol already provides the correct type. Note that the index of the external procedure symbol points @@ -2488,7 +2488,7 @@ parse_partial_symbols (minimal_symbol_reader &reader, switch (ext_in->asym.st) { case stProc: - /* Beginnning of Procedure */ + /* Beginning of Procedure */ break; case stStaticProc: /* Load time only static procs */ @@ -2938,7 +2938,7 @@ parse_partial_symbols (minimal_symbol_reader &reader, name SOs. */ /* Some other compilers (C++ ones in particular) emit - useless SOs for non-existant .c files. We ignore + useless SOs for non-existent .c files. We ignore all subsequent SOs that immediately follow the first. */ diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c index 3613f9b..331ef70 100644 --- a/gdb/mips-tdep.c +++ b/gdb/mips-tdep.c @@ -7027,7 +7027,7 @@ gdb_print_insn_mips (bfd_vma memaddr, struct disassemble_info *info) /* FIXME: cagney/2003-06-26: Is this even necessary? The disassembler needs to be able to locally determine the ISA, and - not rely on GDB. Otherwize the stand-alone 'objdump -d' will not + not rely on GDB. Otherwise the stand-alone 'objdump -d' will not work. */ if (mips_pc_is_mips16 (gdbarch, memaddr)) info->mach = bfd_mach_mips16; diff --git a/gdb/moxie-tdep.c b/gdb/moxie-tdep.c index f69810f..ad73be2 100644 --- a/gdb/moxie-tdep.c +++ b/gdb/moxie-tdep.c @@ -240,7 +240,7 @@ moxie_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) return sal.end; } } - /* No useable line symbol. Use result of prologue parsing + /* No usable line symbol. Use result of prologue parsing method. */ return plg_end; } diff --git a/gdb/nds32-tdep.c b/gdb/nds32-tdep.c index e08ead2..ed4e460 100644 --- a/gdb/nds32-tdep.c +++ b/gdb/nds32-tdep.c @@ -1935,7 +1935,7 @@ nds32_validate_tdesc_p (const struct target_desc *tdesc, } /* Initialize the current architecture based on INFO. If possible, - re-use an architecture from ARCHES, which is a list of + reuse an architecture from ARCHES, which is a list of architectures already created during this debugging session. Called e.g. at program startup, when reading a core file, and when diff --git a/gdb/p-exp.y b/gdb/p-exp.y index 938d3cf..1128f24 100644 --- a/gdb/p-exp.y +++ b/gdb/p-exp.y @@ -765,7 +765,7 @@ typebase /* Implements (approximately): (type-qualifier)* type-specifier */ = lookup_struct (copy_name ($2).c_str (), pstate->expression_context_block); } - /* "const" and "volatile" are curently ignored. A type qualifier + /* "const" and "volatile" are currently ignored. A type qualifier after the type is handled in the ptype rule. I think these could be too. */ ; diff --git a/gdb/python/lib/gdb/dap/scopes.py b/gdb/python/lib/gdb/dap/scopes.py index 1b98c4f..3ac7368 100644 --- a/gdb/python/lib/gdb/dap/scopes.py +++ b/gdb/python/lib/gdb/dap/scopes.py @@ -22,7 +22,7 @@ from .sources import make_source from .startup import in_gdb_thread from .varref import BaseReference -# Map DAP frame IDs to scopes. This ensures that scopes are re-used. +# Map DAP frame IDs to scopes. This ensures that scopes are reused. frame_to_scope = {} diff --git a/gdb/python/lib/gdb/styling.py b/gdb/python/lib/gdb/styling.py index 1c5394e..2efaf4c 100644 --- a/gdb/python/lib/gdb/styling.py +++ b/gdb/python/lib/gdb/styling.py @@ -22,6 +22,7 @@ try: from pygments import formatters, highlight, lexers from pygments.filters import TokenMergeFilter from pygments.token import Comment, Error, Text + from pygments.util import ClassNotFound _formatter = None @@ -31,10 +32,13 @@ try: _formatter = formatters.TerminalFormatter() return _formatter - def colorize(filename, contents): + def colorize(filename, contents, lang): # Don't want any errors. try: - lexer = lexers.get_lexer_for_filename(filename, stripnl=False) + try: + lexer = lexers.get_lexer_by_name(lang, stripnl=False) + except ClassNotFound: + lexer = lexers.get_lexer_for_filename(filename, stripnl=False) formatter = get_formatter() return highlight(contents, lexer, formatter).encode( gdb.host_charset(), "backslashreplace" @@ -94,7 +98,7 @@ try: except ImportError: - def colorize(filename, contents): + def colorize(filename, contents, lang): return None def colorize_disasm(content, gdbarch): diff --git a/gdb/python/python.c b/gdb/python/python.c index 2aaa30c..e32b776 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -128,7 +128,8 @@ static bool gdbpy_check_quit_flag (const struct extension_language_defn *); static enum ext_lang_rc gdbpy_before_prompt_hook (const struct extension_language_defn *, const char *current_gdb_prompt); static std::optional<std::string> gdbpy_colorize - (const std::string &filename, const std::string &contents); + (const std::string &filename, const std::string &contents, + enum language lang); static std::optional<std::string> gdbpy_colorize_disasm (const std::string &content, gdbarch *gdbarch); static ext_lang_missing_file_result gdbpy_handle_missing_debuginfo @@ -1295,7 +1296,8 @@ gdbpy_before_prompt_hook (const struct extension_language_defn *extlang, /* This is the extension_language_ops.colorize "method". */ static std::optional<std::string> -gdbpy_colorize (const std::string &filename, const std::string &contents) +gdbpy_colorize (const std::string &filename, const std::string &contents, + enum language lang) { if (!gdb_python_initialized) return {}; @@ -1329,6 +1331,13 @@ gdbpy_colorize (const std::string &filename, const std::string &contents) return {}; } + gdbpy_ref<> lang_arg (PyUnicode_FromString (language_str (lang))); + if (lang_arg == nullptr) + { + gdbpy_print_stack (); + return {}; + } + /* The pygments library, which is what we currently use for applying styling, is happy to take input as a bytes object, and to figure out the encoding for itself. This removes the need for us to figure out @@ -1349,6 +1358,7 @@ gdbpy_colorize (const std::string &filename, const std::string &contents) gdbpy_ref<> result (PyObject_CallFunctionObjArgs (hook.get (), fname_arg.get (), contents_arg.get (), + lang_arg.get (), nullptr)); if (result == nullptr) { diff --git a/gdb/record-full.c b/gdb/record-full.c index 6d05651..09f0e94 100644 --- a/gdb/record-full.c +++ b/gdb/record-full.c @@ -1647,7 +1647,7 @@ record_full_target::store_registers (struct regcache *regcache, int regno) /* "xfer_partial" method. Behavior is conditional on RECORD_FULL_IS_REPLAY. - In replay mode, we cannot write memory unles we are willing to + In replay mode, we cannot write memory unless we are willing to invalidate the record/replay log from this point forward. */ enum target_xfer_status @@ -2368,7 +2368,7 @@ record_full_restore (void) bfdcore_read (current_program_space->core_bfd (), osec, &magic, sizeof (magic), &bfd_offset); if (magic != RECORD_FULL_FILE_MAGIC) - error (_("Version mis-match or file format error in core file %s."), + error (_("Version mismatch or file format error in core file %s."), bfd_get_filename (current_program_space->core_bfd ())); if (record_debug) gdb_printf (gdb_stdlog, diff --git a/gdb/remote.c b/gdb/remote.c index 66c58c8..8456750 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -9035,7 +9035,7 @@ remote_target::process_g_packet (struct regcache *regcache) /* Reply describes registers byte by byte, each byte encoded as two hex characters. Suck them all up, then supply them to the - register cacheing/storage mechanism. */ + register caching/storage mechanism. */ p = rs->buf.data (); for (i = 0; i < rsa->sizeof_g_packet; i++) diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c index 6eeb1c1..4c18f14 100644 --- a/gdb/riscv-tdep.c +++ b/gdb/riscv-tdep.c @@ -4188,7 +4188,7 @@ static const char *const stap_register_indirection_suffixes[] = }; /* Initialize the current architecture based on INFO. If possible, - re-use an architecture from ARCHES, which is a list of + reuse an architecture from ARCHES, which is a list of architectures already created during this debugging session. Called e.g. at program startup, when reading a core file, and when diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c index 0d1c89b..5fdabeb 100644 --- a/gdb/rs6000-tdep.c +++ b/gdb/rs6000-tdep.c @@ -6951,7 +6951,7 @@ ppc_process_record_prefix_store_vsx_ds_form (struct gdbarch *gdbarch, } /* Record the prefixed VSX, form D, instructions. The arguments are the - instruction address for PC-relative addresss (addr), the first 32-bits of + instruction address for PC-relative address (addr), the first 32-bits of the instruction (insn_prefix) and the following 32-bits of the instruction (insn_suffix). Return 0 on success. */ @@ -7583,7 +7583,7 @@ ppc64_update_call_site_pc (struct gdbarch *gdbarch, CORE_ADDR pc) return pc + 4; } -/* Initialize the current architecture based on INFO. If possible, re-use an +/* Initialize the current architecture based on INFO. If possible, reuse an architecture from ARCHES, which is a list of architectures already created during this debugging session. diff --git a/gdb/run-on-main-thread.c b/gdb/run-on-main-thread.c index 746ea35..50efe07 100644 --- a/gdb/run-on-main-thread.c +++ b/gdb/run-on-main-thread.c @@ -83,7 +83,7 @@ run_events (int error, gdb_client_data client_data) } catch (const gdb_exception_quit &e) { - /* Should cancelation of a runnable event cancel the execution of + /* Should cancellation of a runnable event cancel the execution of the following one? The answer is not clear, so keep doing what we've done so far: ignore this exception. */ } diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index 8bec934..adcec63 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -116,7 +116,8 @@ rust_tuple_type_p (struct type *type) } /* Return true if all non-static fields of a structlike type are in a - sequence like __0, __1, __2. */ + sequence like 0, 1, 2. "__" prefixes are also accepted -- rustc + emits "__0" but gccrs emits "0". */ static bool rust_underscore_fields (struct type *type) @@ -131,8 +132,12 @@ rust_underscore_fields (struct type *type) { char buf[20]; - xsnprintf (buf, sizeof (buf), "__%d", field_number); - if (strcmp (buf, type->field (i).name ()) != 0) + xsnprintf (buf, sizeof (buf), "%d", field_number); + + const char *field_name = type->field (i).name (); + if (startswith (field_name, "__")) + field_name += 2; + if (strcmp (buf, field_name) != 0) return false; field_number++; } @@ -1476,7 +1481,7 @@ rust_struct_anon::evaluate (struct type *expect_type, value *lhs = std::get<1> (m_storage)->evaluate (nullptr, exp, noside); int field_number = std::get<0> (m_storage); - struct type *type = lhs->type (); + struct type *type = check_typedef (lhs->type ()); if (type->code () == TYPE_CODE_STRUCT) { diff --git a/gdb/s390-tdep.c b/gdb/s390-tdep.c index 41faf93..bb204fe 100644 --- a/gdb/s390-tdep.c +++ b/gdb/s390-tdep.c @@ -2488,7 +2488,7 @@ s390_prologue_frame_unwind_cache (const frame_info_ptr &this_frame, size zero. This is only possible if the next frame is a sentinel frame, a dummy frame, or a signal trampoline frame. */ /* FIXME: cagney/2004-05-01: This sanity check shouldn't be - needed, instead the code should simpliy rely on its + needed, instead the code should simply rely on its analysis. */ next_frame = get_next_frame (this_frame); while (next_frame && get_frame_type (next_frame) == INLINE_FRAME) @@ -2537,7 +2537,7 @@ s390_prologue_frame_unwind_cache (const frame_info_ptr &this_frame, code at a point where the frame pointer has already been restored. This can only happen in an innermost frame. */ /* FIXME: cagney/2004-05-01: This sanity check shouldn't be needed, - instead the code should simpliy rely on its analysis. */ + instead the code should simply rely on its analysis. */ next_frame = get_next_frame (this_frame); while (next_frame && get_frame_type (next_frame) == INLINE_FRAME) next_frame = get_next_frame (next_frame); diff --git a/gdb/ser-mingw.c b/gdb/ser-mingw.c index 2603bb8..a1a59ee 100644 --- a/gdb/ser-mingw.c +++ b/gdb/ser-mingw.c @@ -281,10 +281,10 @@ ser_windows_wait_handle (struct serial *scb, HANDLE *read, HANDLE *except) cleared, and we get a duplicated event, if the last batch of characters included at least two arriving close together. */ if (!SetCommMask (h, 0)) - warning (_("ser_windows_wait_handle: reseting mask failed")); + warning (_("ser_windows_wait_handle: resetting mask failed")); if (!SetCommMask (h, EV_RXCHAR)) - warning (_("ser_windows_wait_handle: reseting mask failed (2)")); + warning (_("ser_windows_wait_handle: resetting mask failed (2)")); /* There's a potential race condition here; we must check cbInQue and not wait if that's nonzero. */ diff --git a/gdb/ser-unix.c b/gdb/ser-unix.c index 02845aa..1913309 100644 --- a/gdb/ser-unix.c +++ b/gdb/ser-unix.c @@ -404,7 +404,7 @@ rate_to_code (int rate) for (i = 0; baudtab[i].rate != -1; i++) { - /* test for perfect macth. */ + /* test for perfect match. */ if (rate == baudtab[i].rate) return baudtab[i].code; else diff --git a/gdb/solib-rocm.c b/gdb/solib-rocm.c index 156b36a..b49f529 100644 --- a/gdb/solib-rocm.c +++ b/gdb/solib-rocm.c @@ -403,7 +403,7 @@ protected: /* Snapshot of the original ELF image taken during load. This is done to support the situation where an inferior uses an in-memory image, and - releases or re-uses this memory before GDB is done using it. */ + releases or reuses this memory before GDB is done using it. */ gdb::byte_vector m_objfile_image; LONGEST size () override diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c index 398123f..2f839bd 100644 --- a/gdb/solib-svr4.c +++ b/gdb/solib-svr4.c @@ -405,11 +405,54 @@ struct svr4_info The special entry zero is reserved for a linear list to support gdbstubs that do not support namespaces. */ std::map<CORE_ADDR, std::vector<svr4_so>> solib_lists; + + /* Mapping between r_debug[_ext] addresses and a user-friendly + identifier for the namespace. A vector is used to make it + easy to assign new internal IDs to namespaces. + + For gdbservers that don't support namespaces, the first (and only) + entry of the vector will be 0. + + A note on consistency. We can't make the IDs be consistent before + and after the initial relocation of the inferior (when the global + _r_debug is relocated, as mentioned in the previous comment). It is + likely that this is a non-issue, since the inferior can't have called + dlmopen yet, but I think it is worth noting. + + The only issue I am aware at this point is that, if when parsing an + XML file, we read an LMID that given by an XML file (and read in + library_list_start_library) is the identifier obtained with dlinfo + instead of the address of r_debug[_ext], and after attaching the + inferior adds another SO to that namespace, we might double-count it + since we won't have access to the LMID later on. However, this is + already a problem with the existing solib_lists code. */ + std::vector<CORE_ADDR> namespace_id; + + /* This identifies which namespaces are active. A namespace is considered + active when there is at least one shared object loaded into it. */ + std::set<size_t> active_namespaces; }; /* Per-program-space data key. */ static const registry<program_space>::key<svr4_info> solib_svr4_pspace_data; +/* Check if the lmid address is already assigned an ID in the svr4_info, + and if not, assign it one and add it to the list of known namespaces. */ +static void +svr4_maybe_add_namespace (svr4_info *info, CORE_ADDR lmid) +{ + int i; + for (i = 0; i < info->namespace_id.size (); i++) + { + if (info->namespace_id[i] == lmid) + break; + } + if (i == info->namespace_id.size ()) + info->namespace_id.push_back (lmid); + + info->active_namespaces.insert (i); +} + /* Return whether DEBUG_BASE is the default namespace of INFO. */ static bool @@ -1041,14 +1084,18 @@ library_list_start_library (struct gdb_xml_parser *parser, /* Older versions did not supply lmid. Put the element into the flat list of the special namespace zero in that case. */ gdb_xml_value *at_lmid = xml_find_attribute (attributes, "lmid"); + svr4_info *info = get_svr4_info (current_program_space); if (at_lmid == nullptr) - solist = list->cur_list; + { + solist = list->cur_list; + svr4_maybe_add_namespace (info, 0); + } else { ULONGEST lmid = *(ULONGEST *) at_lmid->value.get (); solist = &list->solib_lists[lmid]; + svr4_maybe_add_namespace (info, lmid); } - solist->emplace_back (name, std::move (li)); } @@ -1286,6 +1333,8 @@ svr4_current_sos_direct (struct svr4_info *info) /* Remove any old libraries. We're going to read them back in again. */ info->solib_lists.clear (); + info->active_namespaces.clear (); + /* Fall back to manual examination of the target if the packet is not supported or gdbserver failed to find DT_DEBUG. gdb.server/solib-list.exp tests a case where gdbserver cannot find the shared libraries list while @@ -1333,7 +1382,10 @@ svr4_current_sos_direct (struct svr4_info *info) ignore_first = true; auto cleanup = make_scope_exit ([info] () - { info->solib_lists.clear (); }); + { + info->solib_lists.clear (); + info->active_namespaces.clear (); + }); /* Collect the sos in each namespace. */ CORE_ADDR debug_base = info->debug_base; @@ -1343,8 +1395,11 @@ svr4_current_sos_direct (struct svr4_info *info) /* Walk the inferior's link map list, and build our so_list list. */ lm = solib_svr4_r_map (debug_base); if (lm != 0) - svr4_read_so_list (info, lm, 0, info->solib_lists[debug_base], - ignore_first); + { + svr4_maybe_add_namespace (info, debug_base); + svr4_read_so_list (info, lm, 0, info->solib_lists[debug_base], + ignore_first); + } } /* On Solaris, the dynamic linker is not in the normal list of @@ -1361,8 +1416,11 @@ svr4_current_sos_direct (struct svr4_info *info) { /* Add the dynamic linker's namespace unless we already did. */ if (info->solib_lists.find (debug_base) == info->solib_lists.end ()) - svr4_read_so_list (info, debug_base, 0, info->solib_lists[debug_base], - 0); + { + svr4_maybe_add_namespace (info, debug_base); + svr4_read_so_list (info, debug_base, 0, info->solib_lists[debug_base], + 0); + } } cleanup.release (); @@ -1778,6 +1836,10 @@ solist_update_incremental (svr4_info *info, CORE_ADDR debug_base, return 0; prev_lm = 0; + + /* If the list is empty, we are seeing a new namespace for the + first time, so assign it an internal ID. */ + svr4_maybe_add_namespace (info, debug_base); } else prev_lm = solist.back ().lm_info->lm_addr; @@ -1845,6 +1907,8 @@ disable_probes_interface (svr4_info *info) free_probes_table (info); info->solib_lists.clear (); + info->namespace_id.clear (); + info->active_namespaces.clear (); } /* Update the solib list as appropriate when using the @@ -3042,6 +3106,8 @@ svr4_solib_create_inferior_hook (int from_tty) /* Clear the probes-based interface's state. */ free_probes_table (info); info->solib_lists.clear (); + info->namespace_id.clear (); + info->active_namespaces.clear (); /* Relocate the main executable if necessary. */ svr4_relocate_main_executable (); @@ -3460,6 +3526,32 @@ svr4_find_solib_addr (solib &so) return li->l_addr_inferior; } +/* See solib_ops::find_solib_ns in solist.h. */ + +static int +svr4_find_solib_ns (const solib &so) +{ + CORE_ADDR debug_base = find_debug_base_for_solib (&so); + svr4_info *info = get_svr4_info (current_program_space); + for (int i = 0; i < info->namespace_id.size (); i++) + { + if (info->namespace_id[i] == debug_base) + { + gdb_assert (info->active_namespaces.count (i) == 1); + return i; + } + } + error (_("No namespace found")); +} + +/* see solib_ops::num_active_namespaces in solist.h. */ +static int +svr4_num_active_namespaces () +{ + svr4_info *info = get_svr4_info (current_program_space); + return info->active_namespaces.size (); +} + const struct solib_ops svr4_so_ops = { svr4_relocate_section_addresses, @@ -3475,6 +3567,8 @@ const struct solib_ops svr4_so_ops = svr4_update_solib_event_breakpoints, svr4_handle_solib_event, svr4_find_solib_addr, + svr4_find_solib_ns, + svr4_num_active_namespaces, }; void _initialize_svr4_solib (); diff --git a/gdb/solib.c b/gdb/solib.c index 0bbcb02..3ddd4f9 100644 --- a/gdb/solib.c +++ b/gdb/solib.c @@ -68,7 +68,7 @@ show_solib_search_path (struct ui_file *file, int from_tty, value); } -/* Same as HAVE_DOS_BASED_FILE_SYSTEM, but useable as an rvalue. */ +/* Same as HAVE_DOS_BASED_FILE_SYSTEM, but usable as an rvalue. */ #if (HAVE_DOS_BASED_FILE_SYSTEM) #define DOS_BASED_FILE_SYSTEM 1 #else @@ -1051,12 +1051,24 @@ info_sharedlibrary_command (const char *pattern, int from_tty) } } + /* How many columns the table should have. If the inferior has + more than one namespace active, we need a column to show that. */ + int num_cols = 4; + const solib_ops *ops = gdbarch_so_ops (gdbarch); + if (ops->num_active_namespaces != nullptr + && ops->num_active_namespaces () > 1) + num_cols++; + { - ui_out_emit_table table_emitter (uiout, 4, nr_libs, "SharedLibraryTable"); + ui_out_emit_table table_emitter (uiout, num_cols, nr_libs, + "SharedLibraryTable"); /* The "- 1" is because ui_out adds one space between columns. */ uiout->table_header (addr_width - 1, ui_left, "from", "From"); uiout->table_header (addr_width - 1, ui_left, "to", "To"); + if (ops->num_active_namespaces != nullptr + && ops->num_active_namespaces () > 1) + uiout->table_header (5, ui_left, "namespace", "NS"); uiout->table_header (12 - 1, ui_left, "syms-read", "Syms Read"); uiout->table_header (0, ui_noalign, "name", "Shared Object Library"); @@ -1083,6 +1095,19 @@ info_sharedlibrary_command (const char *pattern, int from_tty) uiout->field_skip ("to"); } + if (ops->num_active_namespaces != nullptr + && ops->num_active_namespaces ()> 1) + { + try + { + uiout->field_fmt ("namespace", "[[%d]]", ops->find_solib_ns (so)); + } + catch (const gdb_exception_error &er) + { + uiout->field_skip ("namespace"); + } + } + if (!top_level_interpreter ()->interp_ui_out ()->is_mi_like_p () && so.symbols_loaded && !objfile_has_symbols (so.objfile)) { diff --git a/gdb/solist.h b/gdb/solist.h index 9a157a4..03d2392 100644 --- a/gdb/solist.h +++ b/gdb/solist.h @@ -180,6 +180,20 @@ struct solib_ops name). */ std::optional<CORE_ADDR> (*find_solib_addr) (solib &so); + + /* Return which linker namespace contains the current so. + If the linker or libc does not support linkage namespaces at all + (which is basically all of them but solib-svr4), this function should + be set to nullptr, so that "info shared" won't add an unnecessary + column. + + If the namespace can not be determined (such as when we're stepping + though the dynamic linker), this function should throw a + gdb_exception_error. */ + int (*find_solib_ns) (const solib &so); + + /* Returns the number of active namespaces in the inferior. */ + int (*num_active_namespaces) (); }; /* A unique pointer to a so_list. */ diff --git a/gdb/source-cache.c b/gdb/source-cache.c index 30c9e61..2c3ad34 100644 --- a/gdb/source-cache.c +++ b/gdb/source-cache.c @@ -364,7 +364,8 @@ source_cache::ensure (struct symtab *s) if (!styled_p) { std::optional<std::string> ext_contents; - ext_contents = ext_lang_colorize (fullname, contents); + ext_contents = ext_lang_colorize (fullname, contents, + s->language ()); if (ext_contents.has_value ()) { contents = std::move (*ext_contents); diff --git a/gdb/sparc-obsd-tdep.c b/gdb/sparc-obsd-tdep.c index 2bc944e..8329f3a 100644 --- a/gdb/sparc-obsd-tdep.c +++ b/gdb/sparc-obsd-tdep.c @@ -147,7 +147,7 @@ static const struct frame_unwind_legacy sparc32obsd_sigtramp_frame_unwind ( -/* Offset wthin the thread structure where we can find %fp and %i7. */ +/* Offset within the thread structure where we can find %fp and %i7. */ #define SPARC32OBSD_UTHREAD_FP_OFFSET 128 #define SPARC32OBSD_UTHREAD_PC_OFFSET 132 diff --git a/gdb/sparc-sol2-nat.c b/gdb/sparc-sol2-nat.c index 8f9607f..8d04696 100644 --- a/gdb/sparc-sol2-nat.c +++ b/gdb/sparc-sol2-nat.c @@ -26,7 +26,7 @@ #include "target.h" #include "procfs.h" -/* This file provids the (temporary) glue between the Solaris SPARC +/* This file provides the (temporary) glue between the Solaris SPARC target dependent code and the machine independent SVR4 /proc support. */ diff --git a/gdb/sparc64-obsd-tdep.c b/gdb/sparc64-obsd-tdep.c index 8596d2f..175ccb5 100644 --- a/gdb/sparc64-obsd-tdep.c +++ b/gdb/sparc64-obsd-tdep.c @@ -318,7 +318,7 @@ static const struct frame_unwind_legacy sparc64obsd_trapframe_unwind ( /* Threads support. */ -/* Offset wthin the thread structure where we can find %fp and %i7. */ +/* Offset within the thread structure where we can find %fp and %i7. */ #define SPARC64OBSD_UTHREAD_FP_OFFSET 232 #define SPARC64OBSD_UTHREAD_PC_OFFSET 240 diff --git a/gdb/stabsread.c b/gdb/stabsread.c index fcc226e..73f50fe 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -891,7 +891,7 @@ read_ofile_symtab (struct objfile *objfile, legacy_psymtab *pst) symnum < max_symnum; symnum++) { - QUIT; /* Allow this to be interruptable. */ + QUIT; /* Allow this to be interruptible. */ if (symbuf_idx == symbuf_end) fill_symbuf (abfd, objfile); bufp = &symbuf[symbuf_idx++]; @@ -1301,7 +1301,7 @@ read_stabs_symtab_1 (minimal_symbol_reader &reader, for (symnum = 0; symnum < DBX_SYMCOUNT (objfile); symnum++) { /* Get the symbol for this run and pull out some info. */ - QUIT; /* Allow this to be interruptable. */ + QUIT; /* Allow this to be interruptible. */ if (symbuf_idx == symbuf_end) fill_symbuf (abfd, objfile); bufp = &symbuf[symbuf_idx++]; @@ -1540,7 +1540,7 @@ read_stabs_symtab_1 (minimal_symbol_reader &reader, } /* Some other compilers (C++ ones in particular) emit useless - SOs for non-existant .c files. We ignore all subsequent SOs + SOs for non-existent .c files. We ignore all subsequent SOs that immediately follow the first. */ if (!pst) @@ -3511,7 +3511,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type, sym->set_aclass_index (LOC_STATIC); sym->set_domain (VAR_DOMAIN); /* Don't add symbol references to global_sym_chain. - Symbol references don't have valid names and wont't match up with + Symbol references don't have valid names and won't match up with minimal symbols when the global_sym_chain is relocated. We'll fixup symbol references when we fixup the defining symbol. */ if (sym->linkage_name () && sym->linkage_name ()[0] != '#') @@ -4907,7 +4907,7 @@ read_member_functions (struct stab_field_info *fip, const char **pp, int nbits; /* virtual member function, followed by index. The sign bit is set to distinguish pointers-to-methods - from virtual function indicies. Since the array is + from virtual function indices. Since the array is in words, the quantity must be shifted left by 1 on 16 bit machine, and by 2 on 32 bit machine, forcing the sign bit out, and usable as a valid index into diff --git a/gdb/stabsread.h b/gdb/stabsread.h index 273ceaa..99ca215 100644 --- a/gdb/stabsread.h +++ b/gdb/stabsread.h @@ -131,7 +131,7 @@ struct header_file /* The actual length of HEADER_FILES. */ #define N_HEADER_FILES(OBJFILE) (DBX_SYMFILE_INFO (OBJFILE)->n_header_files) -/* The allocated lengh of HEADER_FILES. */ +/* The allocated length of HEADER_FILES. */ #define N_ALLOCATED_HEADER_FILES(OBJFILE) \ (DBX_SYMFILE_INFO (OBJFILE)->n_allocated_header_files) diff --git a/gdb/stack.c b/gdb/stack.c index 6f986aa..6c4e0cd 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -827,7 +827,7 @@ print_frame_args (const frame_print_options &fp_opts, (1) Because find_saved_registers may be slow for remote debugging. - (2) Because registers are often re-used and stack + (2) Because registers are often reused and stack slots rarely (never?) are. Therefore using the stack slot is much less likely to print garbage. diff --git a/gdb/stap-probe.c b/gdb/stap-probe.c index b312b38..fc37a59 100644 --- a/gdb/stap-probe.c +++ b/gdb/stap-probe.c @@ -1225,7 +1225,7 @@ stap_parse_argument (const char **arg, struct type *atype, { /* We need to initialize the expression buffer, in order to begin our parsing efforts. We use language_c here because we may need - to do pointer arithmetics. */ + to do pointer arithmetic. */ struct stap_parse_info p (*arg, atype, language_def (language_c), gdbarch); diff --git a/gdb/symfile.c b/gdb/symfile.c index b0c178a..6c3af61 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -3035,7 +3035,7 @@ section_is_mapped (struct obj_section *osect) case ovly_off: return 0; /* overlay debugging off */ case ovly_auto: /* overlay debugging automatic */ - /* Unles there is a gdbarch_overlay_update function, + /* Unless there is a gdbarch_overlay_update function, there's really nothing useful to do here (can't really go auto). */ gdbarch = osect->objfile->arch (); if (gdbarch_overlay_update_p (gdbarch)) diff --git a/gdb/symtab.c b/gdb/symtab.c index 06e2cd5..3ab1a58 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -6550,7 +6550,7 @@ find_main_name (void) language. It is easy to guaranty this with Ada, since we use a special symbol generated only when the main in Ada to find the name of the main procedure. It is difficult however to see how this can - be guarantied for languages such as C, for instance. This suggests + be guaranteed for languages such as C, for instance. This suggests that order of call for these methods becomes important, which means a more complicated approach. */ new_main_name = ada_main_name (); diff --git a/gdb/testsuite/gdb.ada/array_of_variant.exp b/gdb/testsuite/gdb.ada/array_of_variant.exp index 8b83f4e..83b626c 100644 --- a/gdb/testsuite/gdb.ada/array_of_variant.exp +++ b/gdb/testsuite/gdb.ada/array_of_variant.exp @@ -20,7 +20,7 @@ require allow_ada_tests standard_ada_testfile p -set old_gcc [gnat_version_compare <= 7] +set old_gcc [gnat_version_compare < 8] proc gdb_test_with_xfail { cmd re re_xfail msg } { global scenario old_gcc diff --git a/gdb/testsuite/gdb.base/set-solib-absolute-prefix.c b/gdb/testsuite/gdb.arch/x86-set-solib-absolute-prefix.c index 685a22e..685a22e 100644 --- a/gdb/testsuite/gdb.base/set-solib-absolute-prefix.c +++ b/gdb/testsuite/gdb.arch/x86-set-solib-absolute-prefix.c diff --git a/gdb/testsuite/gdb.base/set-solib-absolute-prefix.exp b/gdb/testsuite/gdb.arch/x86-set-solib-absolute-prefix.exp index cf74789..cf74789 100644 --- a/gdb/testsuite/gdb.base/set-solib-absolute-prefix.exp +++ b/gdb/testsuite/gdb.arch/x86-set-solib-absolute-prefix.exp diff --git a/gdb/testsuite/gdb.base/attach-pie-noexec.exp b/gdb/testsuite/gdb.base/attach-pie-noexec.exp index 4e6ede1..20c93b5 100644 --- a/gdb/testsuite/gdb.base/attach-pie-noexec.exp +++ b/gdb/testsuite/gdb.base/attach-pie-noexec.exp @@ -35,7 +35,7 @@ if ![runto_main] { } set test "sanity check info shared" gdb_test_multiple "info shared" $test { - -re "From\[ \t\]+To\[ \t\]+Syms Read\[ \t\]+Shared Object Library\r\n0x.*\r\n$gdb_prompt $" { + -re "From\[ \t\]+To(\\s+NS)?\[ \t\]+Syms Read\[ \t\]+Shared Object Library\r\n0x.*\r\n$gdb_prompt $" { pass $test } -re "No shared libraries loaded at this time\\.\r\n$gdb_prompt $" { @@ -62,6 +62,6 @@ if { ![gdb_attach $testpid] } { return } gdb_test "set architecture $arch" "The target architecture is set to \"$arch\"\\." -gdb_test "info shared" "From\[ \t\]+To\[ \t\]+Syms Read\[ \t\]+Shared Object Library\r\n0x.*" +gdb_test "info shared" "From\[ \t\]+To(\\s+NS)?\[ \t\]+Syms Read\[ \t\]+Shared Object Library\r\n0x.*" kill_wait_spawned_process $test_spawn_id diff --git a/gdb/testsuite/gdb.base/dlmopen-ns-ids-lib.c b/gdb/testsuite/gdb.base/dlmopen-ns-ids-lib.c new file mode 100644 index 0000000..86cbb0f --- /dev/null +++ b/gdb/testsuite/gdb.base/dlmopen-ns-ids-lib.c @@ -0,0 +1,28 @@ +/* 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/>. + +*/ + +int gdb_dlmopen_glob = 0; + +__attribute__((visibility ("default"))) +int +inc (int n) +{ + int amount = gdb_dlmopen_glob; + return n + amount; /* bp.inc. */ +} diff --git a/gdb/testsuite/gdb.base/dlmopen-ns-ids-main.c b/gdb/testsuite/gdb.base/dlmopen-ns-ids-main.c new file mode 100644 index 0000000..3bcd819 --- /dev/null +++ b/gdb/testsuite/gdb.base/dlmopen-ns-ids-main.c @@ -0,0 +1,54 @@ +/* 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/>. + +*/ + +#define _GNU_SOURCE +#include <dlfcn.h> +#include <stddef.h> +#include <assert.h> +#include <unistd.h> +#include <stdio.h> + +int +main (void) +{ + void *handle[4]; + int (*fun) (int); + Lmid_t lmid; + int dl; + + handle[0] = dlmopen (LM_ID_NEWLM, DSO_NAME, RTLD_LAZY | RTLD_LOCAL); + assert (handle[0] != NULL); + + handle[1] = dlmopen (LM_ID_NEWLM, DSO_NAME, RTLD_LAZY | RTLD_LOCAL); + assert (handle[1] != NULL); + + handle[2] = dlmopen (LM_ID_NEWLM, DSO_NAME, RTLD_LAZY | RTLD_LOCAL); + assert (handle[2] != NULL); + + dlclose (handle[0]); /* TAG: first dlclose */ + dlclose (handle[1]); /* TAG: second dlclose */ + dlclose (handle[2]); /* TAG: third dlclose */ + + handle[3] = dlmopen (LM_ID_NEWLM, DSO_NAME, RTLD_LAZY | RTLD_LOCAL); + dlinfo (handle[3], RTLD_DI_LMID, &lmid); + + dlclose (handle[3]); /* TAG: fourth dlclose */ + + return 0; +} diff --git a/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp b/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp new file mode 100644 index 0000000..03b7a52 --- /dev/null +++ b/gdb/testsuite/gdb.base/dlmopen-ns-ids.exp @@ -0,0 +1,106 @@ +# 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 several things related to handling linker namespaces: +# * That the user-facing namespace ID is consistent; + +require allow_dlmopen_tests + +standard_testfile -main.c -lib.c + +set srcfile_lib $srcfile2 +set binfile_lib [standard_output_file dlmopen-lib.so] + +if { [build_executable "build shlib" $binfile_lib $srcfile_lib \ + [list debug shlib]] == -1 } { + return +} + +if { [build_executable "failed to build" $testfile $srcfile \ + [list additional_flags=-DDSO_NAME=\"$binfile_lib\" \ + shlib_load debug]] } { + return +} + +# Run the command "info sharedlibrary" and get the first namespace +# for the so +proc get_first_so_ns {} { + set ns -1 + gdb_test_multiple "info sharedlibrary" "get SO namespace" -lbl { + -re "From\\s+To\\s+\(NS\\s+\)?Syms\\s+Read\\s+Shared Object Library\r\n" { + exp_continue + } + -re "^$::hex\\s+$::hex\\s+\\\[\\\[($::decimal)\\\]\\\]\\s+\[^\r\n]+$::binfile_lib.*" { + set ns $expect_out(1,string) + } + -re "^$::gdb_prompt $" { + } + -re "^\[^\r\n\]+\r\n" { + exp_continue + } + } + return $ns +} + +# Run the tests relating to the command "info sharedlibrary", to +# verify that the namespace ID is consistent. +proc test_info_shared {} { + clean_restart $::binfile + + if { ![runto_main] } { + return + } + + # First test that we don't print a namespace column at the start. + gdb_test "info sharedlibrary" \ + "From\\s+To\\s+Syms\\s+Read\\s+Shared Object Library.*" \ + "before loading anything" + + gdb_breakpoint [gdb_get_line_number "TAG: first dlclose"] + gdb_continue_to_breakpoint "TAG: first dlclose" + + # Next, test that we *do* print a namespace column after loading SOs. + gdb_test "info sharedlibrary" \ + "From\\s+To\\s+NS\\s+Syms\\s+Read\\s+Shared Object Library.*" \ + "after loading everything" + + gdb_assert {[get_first_so_ns] == 1} "before closing any library" + + gdb_test "next" ".*second dlclose.*" "close first library" + gdb_assert {[get_first_so_ns] == 2} "after closing one library" + + gdb_test "next" ".*third dlclose.*" "close second library" + gdb_assert {[get_first_so_ns] == 3} "before closing two libraries" + + gdb_breakpoint [gdb_get_line_number "TAG: fourth dlclose"] + gdb_continue_to_breakpoint "TAG: fourth dlclose" + # As of writing this test, glibc's LMID is just an index on an array of + # namespaces. After closing a namespace, requesting a new one will + # return the index of the lowest-closed namespace, so this will likely + # be namespace 1, and because of glibc's reuse of the r_debug object, + # GDB should be able to assign the same number. + gdb_assert {[get_first_so_ns] == [get_integer_valueof "lmid" "-1"]} \ + "reopen a namespace" + + gdb_test "next" ".*return 0.*" "final namespace inactive" + gdb_test "info sharedlibrary" \ + "From\\s+To\\s+Syms\\s+Read\\s+Shared Object Library.*" \ + "after unloading everything" +} + +test_info_shared diff --git a/gdb/testsuite/gdb.base/dlmopen.exp b/gdb/testsuite/gdb.base/dlmopen.exp index a8e3b08..084c5bc 100644 --- a/gdb/testsuite/gdb.base/dlmopen.exp +++ b/gdb/testsuite/gdb.base/dlmopen.exp @@ -106,7 +106,7 @@ proc check_dso_count { dso num } { set count 0 gdb_test_multiple "info shared" "info shared" { - -re "$hex $hex Yes \[^\r\n\]*$dso\r\n" { + -re "$hex $hex \(\[\[$::decimal\]\]\\s+\)\?Yes \[^\r\n\]*$dso\r\n" { # use longer form so debug remote does not interfere set count [expr $count + 1] exp_continue @@ -233,12 +233,12 @@ proc get_dyld_info {} { set dyld_count 0 set dyld_start_addr "" gdb_test_multiple "info sharedlibrary" "" { - -re "From\\s+To\\s+Syms\\s+Read\\s+Shared Object Library\r\n" { + -re "From\\s+To\\s+\(NS\\s+\)?Syms\\s+Read\\s+Shared Object Library\r\n" { exp_continue } - -re "^($::hex)\\s+$::hex\\s+\[^/\]+(/\[^\r\n\]+)\r\n" { + -re "^($::hex)\\s+$::hex\\s+\(\#$::decimal\\s+\)?\[^/\]+(/\[^\r\n\]+)\r\n" { set addr $expect_out(1,string) - set lib $expect_out(2,string) + set lib $expect_out(3,string) if { [is_dyln $lib] } { # This looks like it might be the dynamic linker. diff --git a/gdb/testsuite/gdb.mi/mi-dlmopen.exp b/gdb/testsuite/gdb.mi/mi-dlmopen.exp index a5743f8..c0208eb 100644 --- a/gdb/testsuite/gdb.mi/mi-dlmopen.exp +++ b/gdb/testsuite/gdb.mi/mi-dlmopen.exp @@ -81,12 +81,12 @@ proc get_dyld_info {} { set dyld_count 0 set dyld_start_addr "" gdb_test_multiple "info sharedlibrary" "" { - -re "~\"From\\s+To\\s+Syms\\s+Read\\s+Shared Object Library\\\\n\"\r\n" { + -re "~\"From\\s+To(\\s+NS)?\\s+Syms\\s+Read\\s+Shared Object Library\\\\n\"\r\n" { exp_continue } - -re "^~\"($::hex)\\s+$::hex\\s+\[^/\]+(/\[^\r\n\]+)\\\\n\"\r\n" { + -re "^~\"($::hex)\\s+${::hex}(\\s+$::decimal)?\\s+\[^/\]+(/\[^\r\n\]+)\\\\n\"\r\n" { set addr $expect_out(1,string) - set lib $expect_out(2,string) + set lib $expect_out(3,string) if { [is_dyln $lib] } { # This looks like it might be the dynamic linker. diff --git a/gdb/testsuite/gdb.python/py-source-styling-2.c b/gdb/testsuite/gdb.python/py-source-styling-2.c new file mode 100644 index 0000000..aaa3d69 --- /dev/null +++ b/gdb/testsuite/gdb.python/py-source-styling-2.c @@ -0,0 +1,26 @@ +/* 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/>. */ + +int +main () +{ /* List this line. */ + try + {} + catch (...) + {} + return 0; +} diff --git a/gdb/testsuite/gdb.python/py-source-styling-2.exp b/gdb/testsuite/gdb.python/py-source-styling-2.exp new file mode 100644 index 0000000..b13ee1f --- /dev/null +++ b/gdb/testsuite/gdb.python/py-source-styling-2.exp @@ -0,0 +1,55 @@ +# Copyright (C) 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/>. + +# Compile a c++ file using a .c extension, and check that pygments uses c++ +# highlighting instead of c highlighting. + +require allow_python_tests + +load_lib gdb-python.exp + +standard_testfile py-source-styling-2.c + +set line_number [gdb_get_line_number "List this line."] + +set opts {} +lappend opts debug +lappend opts c++ + +if { [build_executable "failed to build" $testfile $srcfile $opts] == -1 } { + return +} + +clean_restart + +gdb_test_no_output "maint set gnu-source-highlight enabled off" + +gdb_load $binfile + +require {gdb_py_module_available pygments} + +with_ansi_styling_terminal { + gdb_test_no_output "set style enabled on" + + gdb_test_multiple "list $line_number" "Styling of c++ keyword try" { + -re -wrap " try\r\n.*" { + # Unstyled. + fail $gdb_test_name + } + -re -wrap "" { + pass $gdb_test_name + } + } +} diff --git a/gdb/testsuite/gdb.testsuite/version-compare.exp b/gdb/testsuite/gdb.testsuite/version-compare.exp new file mode 100644 index 0000000..8f2573e --- /dev/null +++ b/gdb/testsuite/gdb.testsuite/version-compare.exp @@ -0,0 +1,74 @@ +# 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 version_compare proc. + +proc eq { a b } { + with_test_prefix "$a == $b" { + gdb_assert { [version_compare $a == $b] } + gdb_assert { [version_compare $a <= $b] } + gdb_assert { [version_compare $a >= $b] } + gdb_assert { ![version_compare $a < $b] } + gdb_assert { ![version_compare $a > $b] } + } +} + +proc lt { a b } { + with_test_prefix "$a < $b" { + gdb_assert { [version_compare $a < $b] } + gdb_assert { [version_compare $a <= $b] } + gdb_assert { [version_compare $b > $a] } + gdb_assert { [version_compare $b >= $a] } + gdb_assert { ![version_compare $a == $b] } + gdb_assert { ![version_compare $b == $a] } + gdb_assert { ![version_compare $a > $b] } + gdb_assert { ![version_compare $a >= $b] } + gdb_assert { ![version_compare $b < $a] } + gdb_assert { ![version_compare $b <= $a] } + } +} + +# Equal, same length. +eq {1 0} {1 0} + +# Smaller than, same length. +lt {1 0} {1 1} +lt {1 1} {2 0} + +# Smaller than, different length. +lt {1 3} {2} +lt {1} {2 0} + +# The question how v1 and v1.0 relate to each other is not a trivial one. +# +# For instance, Python considers v1 == v1.0: +# $ test.py +# #!/usr/bin/python3 +# from packaging.version import parse +# v1_0 = parse("1.0") +# v1 = parse("1") +# print (v1 == v1_0) +# $ ./test.py +# True +# +# OTOH, version sort from coreutils considers v1 < v1.0: +# $ cat bla.txt +# 1.0 +# 1 +# $ sort -V bla.txt +# 1 +# 1.0 +# +# Proc version_compare seems to have taken the latter approach. +lt {1} {1 0} diff --git a/gdb/testsuite/lib/gdb-utils.exp b/gdb/testsuite/lib/gdb-utils.exp index b8ab30a..f32f533 100644 --- a/gdb/testsuite/lib/gdb-utils.exp +++ b/gdb/testsuite/lib/gdb-utils.exp @@ -117,7 +117,10 @@ proc gdb_get_bp_addr { num } { # Compare the version numbers in L1 to those in L2 using OP, and # return 1 if the comparison is true. OP can be "<", "<=", ">", ">=", -# or "==". It is ok if the lengths of the lists differ. +# or "==". +# It is ok if the lengths of the lists differ, but note that we have +# "{1} < {1 0}" instead of "{1} == {1 0}". See also +# gdb.testsuite/version-compare.exp. proc version_compare { l1 op l2 } { switch -exact $op { @@ -381,7 +381,7 @@ check_frame_language_change (void) /* Warn the user if the working language does not match the language of the current frame. Only warn the user if we are actually running the program, i.e. there is a stack. */ - /* FIXME: This should be cacheing the frame and only running when + /* FIXME: This should be caching the frame and only running when the frame changes. */ if (warn_frame_lang_mismatch && has_stack_frames ()) diff --git a/gdb/tui/tui.c b/gdb/tui/tui.c index 491fcb1..9f60e87 100644 --- a/gdb/tui/tui.c +++ b/gdb/tui/tui.c @@ -67,7 +67,12 @@ show_tui_debug (struct ui_file *file, int from_tty, /* Tells whether the TUI is active or not. */ bool tui_active = false; -static bool tui_finish_init = true; + +/* Tells whether the TUI should do deferred curses initialization. + If TRIBOOL_TRUE, then yes. If TRIBOOL_FALSE. then no (because + initialization is already done). If TRIBOOL_UNKNOWN, then no (because + initialization failed). */ +static tribool tui_finish_init = TRIBOOL_TRUE; enum tui_key_mode tui_current_key_mode = TUI_COMMAND_MODE; @@ -392,7 +397,13 @@ tui_enable (void) /* To avoid to initialize curses when gdb starts, there is a deferred curses initialization. This initialization is made only once and the first time the curses mode is entered. */ - if (tui_finish_init) + if (tui_finish_init == TRIBOOL_UNKNOWN) + { + /* Initialization failed before, just throw a generic error, don't try + again. */ + error (_("Cannot enable the TUI")); + } + else if (tui_finish_init == TRIBOOL_TRUE) { WINDOW *w; SCREEN *s; @@ -412,6 +423,9 @@ tui_enable (void) if (!gdb_stderr->isatty ()) error (_("Cannot enable the TUI when output is not a terminal")); + /* Don't try initialization again. */ + tui_finish_init = TRIBOOL_UNKNOWN; + s = newterm (NULL, stdout, stdin); #ifdef __MINGW32__ /* The MinGW port of ncurses requires $TERM to be unset in order @@ -470,7 +484,7 @@ tui_enable (void) tui_set_win_focus_to (tui_src_win ()); keypad (tui_cmd_win ()->handle.get (), TRUE); wrefresh (tui_cmd_win ()->handle.get ()); - tui_finish_init = false; + tui_finish_init = TRIBOOL_FALSE; } else { diff --git a/gdb/utils.c b/gdb/utils.c index ee7cf4d..2244b90 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -382,7 +382,7 @@ internal_vproblem (struct internal_problem *problem, #endif /* Create a string containing the full error/warning message. Need - to call query with this full string, as otherwize the reason + to call query with this full string, as otherwise the reason (error/warning) and question become separated. Format using a style similar to a compiler error message. Include extra detail so that the user knows that they are living on the edge. */ diff --git a/gdb/value.c b/gdb/value.c index ddc0959..d4548b8 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -107,7 +107,7 @@ ranges_contain (const std::vector<range> &ranges, LONGEST offset, range, we can do a binary search for the position the given range would be inserted if we only considered the starting OFFSET of ranges. We call that position I. Since we also have LENGTH to - care for (this is a range afterall), we need to check if the + care for (this is a range after all), we need to check if the _previous_ range overlaps the I range. E.g., R @@ -267,7 +267,7 @@ insert_into_bit_range_vector (std::vector<range> *vectorp, /* Do a binary search for the position the given range would be inserted if we only considered the starting OFFSET of ranges. Call that position I. Since we also have LENGTH to care for - (this is a range afterall), we need to check if the _previous_ + (this is a range after all), we need to check if the _previous_ range overlaps the I range. E.g., calling R the new range: #1 - overlaps with previous @@ -2833,7 +2833,7 @@ value_as_address (struct value *val) #endif } -/* Unpack raw data (copied from debugee, target byte order) at VALADDR +/* Unpack raw data (copied from debuggee, target byte order) at VALADDR as a long, or as a double, assuming the raw data is described by type TYPE. Knows how to convert different sizes of values and can convert between fixed and floating point. We don't assume @@ -2924,7 +2924,7 @@ unpack_long (struct type *type, const gdb_byte *valaddr) } } -/* Unpack raw data (copied from debugee, target byte order) at VALADDR +/* Unpack raw data (copied from debuggee, target byte order) at VALADDR as a CORE_ADDR, assuming the raw data is described by type TYPE. We don't assume any alignment for the raw data. Return value is in host byte order. diff --git a/gdb/value.h b/gdb/value.h index 8e5fd54..bb6005b 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -961,7 +961,7 @@ struct lval_funcs This may simply return the same closure, if VALUE's is reference-counted or statically allocated. - This may be NULL, in which case VALUE's closure is re-used in the + This may be NULL, in which case VALUE's closure is reused in the new value. */ void *(*copy_closure) (const struct value *v); diff --git a/gdb/varobj.c b/gdb/varobj.c index dcadce1..cf27b1e 100644 --- a/gdb/varobj.c +++ b/gdb/varobj.c @@ -1309,7 +1309,7 @@ install_new_value (struct varobj *var, struct value *value, bool initial) { /* For values that are not changeable, we don't compare the values. However, we want to notice if a value was not NULL and now is NULL, - or vise versa, so that we report when top-level varobjs come in scope + or vice versa, so that we report when top-level varobjs come in scope and leave the scope. */ changed = (var->value != NULL) != (value != NULL); } diff --git a/gdb/vax-tdep.c b/gdb/vax-tdep.c index 4660979..64ade0a 100644 --- a/gdb/vax-tdep.c +++ b/gdb/vax-tdep.c @@ -438,7 +438,7 @@ vax_frame_num_args (const frame_info_ptr &frame) -/* Initialize the current architecture based on INFO. If possible, re-use an +/* Initialize the current architecture based on INFO. If possible, reuse an architecture from ARCHES, which is a list of architectures already created during this debugging session. diff --git a/gdb/windows-nat.h b/gdb/windows-nat.h index b36e7f4..cd253e3 100644 --- a/gdb/windows-nat.h +++ b/gdb/windows-nat.h @@ -25,14 +25,14 @@ typedef int (segment_register_p_ftype) (int regnum); /* segment_register_p_ftype implementation for x86. */ int i386_windows_segment_register_p (int regnum); -/* context register offests for x86. */ +/* context register offsets for x86. */ extern const int i386_mappings[]; #ifdef __x86_64__ /* segment_register_p_ftype implementation for amd64. */ int amd64_windows_segment_register_p (int regnum); -/* context register offests for amd64. */ +/* context register offsets for amd64. */ extern const int amd64_mappings[]; #endif diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c index 2ff9d4a..233988d 100644 --- a/gdb/xcoffread.c +++ b/gdb/xcoffread.c @@ -970,7 +970,7 @@ read_xcoff_symtab (struct objfile *objfile, legacy_psymtab *pst) while (symnum < max_symnum) { - QUIT; /* make this command interruptable. */ + QUIT; /* make this command interruptible. */ /* READ_ONE_SYMBOL (symbol, cs, symname_alloced); */ /* read one symbol into `cs' structure. After processing the @@ -1371,7 +1371,7 @@ read_xcoff_symtab (struct objfile *objfile, legacy_psymtab *pst) case C_BINCL: /* beginning of include file */ /* In xlc output, C_BINCL/C_EINCL pair doesn't show up in sorted - order. Thus, when wee see them, we might not know enough info + order. Thus, when we see them, we might not know enough info to process them. Thus, we'll be saving them into a table (inclTable) and postpone their processing. */ diff --git a/gdb/xstormy16-tdep.c b/gdb/xstormy16-tdep.c index e7f4e6f..43176d9 100644 --- a/gdb/xstormy16-tdep.c +++ b/gdb/xstormy16-tdep.c @@ -435,7 +435,7 @@ xstormy16_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc) return sal.end; } } - /* No useable line symbol. Use result of prologue parsing method. */ + /* No usable line symbol. Use result of prologue parsing method. */ return plg_end; } diff --git a/gdb/xtensa-tdep.c b/gdb/xtensa-tdep.c index c87940c..074b748 100644 --- a/gdb/xtensa-tdep.c +++ b/gdb/xtensa-tdep.c @@ -1767,7 +1767,7 @@ xtensa_push_dummy_call (struct gdbarch *gdbarch, arg_type = builtin_type (gdbarch)->builtin_long; arg = value_cast (arg_type, arg); } - /* Aligment is equal to the type length for the basic types. */ + /* Alignment is equal to the type length for the basic types. */ info->align = arg_type->length (); break; diff --git a/gdbserver/regcache.cc b/gdbserver/regcache.cc index c08c9ae..96855f0 100644 --- a/gdbserver/regcache.cc +++ b/gdbserver/regcache.cc @@ -353,8 +353,7 @@ supply_register_by_name_zeroed (struct regcache *regcache, #endif /* Supply the whole register set whose contents are stored in BUF, to - REGCACHE. If BUF is NULL, all the registers' values are recorded - as unavailable. */ + REGCACHE. */ void supply_regblock (struct regcache *regcache, const void *buf) diff --git a/gprofng/src/DwarfLib.cc b/gprofng/src/DwarfLib.cc index 9b40401..d399c33 100644 --- a/gprofng/src/DwarfLib.cc +++ b/gprofng/src/DwarfLib.cc @@ -204,12 +204,6 @@ ElfReloc::dump_rela_debug_sec (int sec) if (ScnSize == 0 || EntSize == 0) return; - Elf_Internal_Shdr *shdr_sym = elf->get_shdr (shdr->sh_link); - if (shdr_sym == NULL) - return; - Elf_Data *data_sym = elf->elf_getdata (shdr->sh_link); - Elf_Data *data_str = elf->elf_getdata (shdr_sym->sh_link); - char *Strtab = data_str ? (char*) data_str->d_buf : NULL; Elf_Internal_Rela rela; int n, cnt = (int) (ScnSize / EntSize); @@ -233,7 +227,8 @@ ElfReloc::dump_rela_debug_sec (int sec) int ndx = (int) GELF_R_SYM (rela.r_info); Elf_Internal_Shdr *secHdr; Elf_Internal_Sym sym; - elf->elf_getsym (data_sym, ndx, &sym); + asymbol *asym; + asym = elf->elf_getsym (ndx, &sym, false); Dprintf (DUMP_RELA_SEC, NTXT ("%3d:%5d |%11lld |0x%016llx | %-15s|"), n, (int) rela.r_addend, (long long) rela.r_offset, (long long) rela.r_info, @@ -243,12 +238,9 @@ ElfReloc::dump_rela_debug_sec (int sec) case STT_FUNC: case STT_OBJECT: case STT_NOTYPE: - secHdr = elf->get_shdr (sym.st_shndx); - if (secHdr) - Dprintf (DUMP_RELA_SEC, NTXT (" img_offset=0x%llx"), - (long long) (sym.st_value + secHdr->sh_offset)); - if (Strtab && sym.st_name) - Dprintf (DUMP_RELA_SEC, NTXT (" %s"), Strtab + sym.st_name); + Dprintf (DUMP_RELA_SEC, NTXT (" img_offset=0x%llx"), + (long long) (bfd_asymbol_value (asym))); + Dprintf (DUMP_RELA_SEC, NTXT (" %s"), bfd_asymbol_name (asym)); break; case STT_SECTION: secHdr = elf->get_shdr (sym.st_shndx); @@ -311,10 +303,6 @@ ElfReloc::get_elf_reloc (Elf *elfp, char *sec_name, ElfReloc *rlc) return rlc; int cnt = (int) (data->d_size / shdr->sh_entsize); - Elf_Internal_Shdr *shdr_sym = elfp->get_shdr (shdr->sh_link); - if (shdr_sym == NULL) - return rlc; - Elf_Data *data_sym = elfp->elf_getdata (shdr->sh_link); Vector<Sreloc *> *vp = NULL; for (int n = 0; n < cnt; n++) @@ -331,7 +319,7 @@ ElfReloc::get_elf_reloc (Elf *elfp, char *sec_name, ElfReloc *rlc) } int ndx = (int) GELF_R_SYM (rela.r_info); Elf_Internal_Sym sym; - elfp->elf_getsym (data_sym, ndx, &sym); + elfp->elf_getsym (ndx, &sym, false); srlc = new Sreloc; srlc->offset = rela.r_offset; diff --git a/gprofng/src/Elf.cc b/gprofng/src/Elf.cc index b9da240..f0fd121 100644 --- a/gprofng/src/Elf.cc +++ b/gprofng/src/Elf.cc @@ -533,42 +533,43 @@ Elf::elf_strptr (unsigned int sec, uint64_t off) return NULL; } -Elf_Internal_Sym * -Elf::elf_getsym (Elf_Data *edta, unsigned int ndx, Elf_Internal_Sym *dst) +long +Elf::elf_getSymCount (bool is_dynamic) { - if (dst == NULL || edta == NULL) - return NULL; - if (elf_getclass () == ELFCLASS32) - { - if (edta->d_size <= ndx * sizeof (Elf32_Sym)) - return NULL; - Elf32_Sym *hdr = (Elf32_Sym*) bind (edta->d_off + ndx * sizeof (Elf32_Sym), sizeof (Elf32_Sym)); - if (hdr == NULL) - return NULL; - dst->st_name = decode (hdr->st_name); - dst->st_value = decode (hdr->st_value); - dst->st_size = decode (hdr->st_size); - dst->st_info = ELF64_ST_INFO (ELF32_ST_BIND (decode (hdr->st_info)), - ELF32_ST_TYPE (decode (hdr->st_info))); - dst->st_other = decode (hdr->st_other); - dst->st_shndx = decode (hdr->st_shndx); - } + if (bfd_dynsym == NULL && bfd_sym == NULL) + get_bfd_symbols (); + if (is_dynamic) + return bfd_dynsymcnt; + return bfd_symcnt; +} + +/* Returns an ASYMBOL on index NDX if it exists. If DST is defined, + the internal elf symbol at intex NDX is copied into it. IS_DYNAMIC + selects the type of the symbol. */ + +asymbol * +Elf::elf_getsym (unsigned int ndx, Elf_Internal_Sym *dst, bool is_dynamic) +{ + asymbol *asym; + + if (bfd_dynsym == NULL && bfd_sym == NULL) + get_bfd_symbols (); + + if (is_dynamic) + if (ndx < bfd_dynsymcnt) + asym = bfd_dynsym[ndx]; + else + return NULL; else - { - if (edta->d_size <= ndx * sizeof (Elf64_Sym)) - return NULL; - Elf64_Sym *hdr = (Elf64_Sym*) bind (edta->d_off + ndx * sizeof (Elf64_Sym), - sizeof (Elf64_Sym)); - if (hdr == NULL) - return NULL; - dst->st_name = decode (hdr->st_name); - dst->st_value = decode (hdr->st_value); - dst->st_size = decode (hdr->st_size); - dst->st_info = decode (hdr->st_info); - dst->st_other = decode (hdr->st_other); - dst->st_shndx = decode (hdr->st_shndx); - } - return dst; + if (ndx < bfd_symcnt) + asym = bfd_sym[ndx]; + else + return NULL; + + if (dst != NULL) + *dst = ((elf_symbol_type *) asym)->internal_elf_sym; + + return asym; } Elf_Internal_Rela * diff --git a/gprofng/src/Elf.h b/gprofng/src/Elf.h index 7c32dfe..b324c39 100644 --- a/gprofng/src/Elf.h +++ b/gprofng/src/Elf.h @@ -92,7 +92,8 @@ public: int64_t elf_checksum (); uint64_t get_baseAddr(); char *elf_strptr (unsigned int sec, uint64_t off); - Elf_Internal_Sym *elf_getsym (Elf_Data *edta, unsigned int ndx, Elf_Internal_Sym *dst); + long elf_getSymCount (bool is_dynamic); + asymbol *elf_getsym (unsigned int ndx, Elf_Internal_Sym *dst, bool is_dynamic); Elf_Internal_Rela *elf_getrel (Elf_Data *edta, unsigned int ndx, Elf_Internal_Rela *dst); Elf_Internal_Rela *elf_getrela (Elf_Data *edta, unsigned int ndx, Elf_Internal_Rela *dst); Elf64_Ancillary *elf_getancillary (Elf_Data *edta, unsigned int ndx, Elf64_Ancillary *dst); diff --git a/gprofng/src/Stabs.cc b/gprofng/src/Stabs.cc index 2120319..b98ac28 100644 --- a/gprofng/src/Stabs.cc +++ b/gprofng/src/Stabs.cc @@ -241,6 +241,40 @@ RelValueCmp (const void *a, const void *b) (item1->value == item2->value) ? 0 : -1; } +/* Remove all duplicate symbols which can be in SymLst. The + duplication is due to processing of both static and dynamic + symbols. This function is called before computing symbol + aliases. */ + +void +Stabs::removeDupSyms () +{ + long ind, i, last; + Symbol *symA, *symB; + SymLst->sort (SymImgOffsetCmp); + dump (); + + last = 0; + ind = SymLst->size (); + for (i = 0; i < ind; i++) + { + symA = SymLst->fetch (i); + if (symA->img_offset == 0) // Ignore this bad symbol + continue; + + SymLst->put (last++, symA); + for (long k = i + 1; k < ind; k++, i++) + { + symB = SymLst->fetch (k); + if (symA->img_offset != symB->img_offset) + break; + if (strcmp (symA->name, symB->name) != 0) + break; + } + } + SymLst->truncate (last); +} + Stabs * Stabs::NewStabs (char *_path, char *lo_name) { @@ -272,7 +306,7 @@ Stabs::Stabs (char *_path, char *_lo_name) stabsModules = NULL; textsz = 0; wsize = Wnone; - st_check_symtab = st_check_relocs = false; + st_check_symtab = false; status = DBGD_ERR_NONE; if (openElf (false) == NULL) @@ -412,7 +446,6 @@ Stabs::read_symbols (Vector<Function*> *functions) if (openElf (true) == NULL) return false; check_Symtab (); - check_Relocs (); if (functions) { Function *fp; @@ -1703,43 +1736,31 @@ Stabs::check_Symtab () pltSym->flags |= SYM_PLT; } } - if (elf->symtab) - readSymSec (elf->symtab, elf); - else - { - readSymSec (elf->SUNW_ldynsym, elf); - readSymSec (elf->dynsym, elf); - } + + // Read first static symbols + readSymSec (elf, false); + + // Read dynamic symbols + readSymSec (elf, true); } void -Stabs::readSymSec (unsigned int sec, Elf *elf) +Stabs::readSymSec (Elf *elf, bool is_dynamic) { Symbol *sitem; Sp_lang_code local_lcode; - if (sec == 0) - return; - // Get ELF data - Elf_Data *data = elf->elf_getdata (sec); - if (data == NULL) - return; - uint64_t SymtabSize = data->d_size; - Elf_Internal_Shdr *shdr = elf->get_shdr (sec); - - if ((SymtabSize == 0) || (shdr->sh_entsize == 0)) - return; - Elf_Data *data_str = elf->elf_getdata (shdr->sh_link); - if (data_str == NULL) - return; - char *Strtab = (char *) data_str->d_buf; + unsigned int tot = elf->elf_getSymCount (is_dynamic); // read func symbolic table - for (unsigned int n = 0, tot = SymtabSize / shdr->sh_entsize; n < tot; n++) + for (unsigned int n = 0; n < tot; n++) { Elf_Internal_Sym Sym; - elf->elf_getsym (data, n, &Sym); - const char *st_name = Sym.st_name < data_str->d_size ? - (Strtab + Sym.st_name) : NTXT ("no_name"); + asymbol *asym; + asym = elf->elf_getsym (n, &Sym, is_dynamic); + // TBD: convert this check to an assert + if (asym == NULL) + break; + const char *st_name = bfd_asymbol_name (asym); switch (GELF_ST_TYPE (Sym.st_info)) { case STT_FUNC: @@ -1814,6 +1835,7 @@ Stabs::readSymSec (unsigned int sec, Elf *elf) } } } + removeDupSyms (); fixSymtabAlias (); SymLst->sort (SymValueCmp); get_save_addr (elf->need_swap_endian); @@ -1821,142 +1843,6 @@ Stabs::readSymSec (unsigned int sec, Elf *elf) }//check_Symtab void -Stabs::check_Relocs () -{ - // We may have many relocation tables to process: .rela.text%foo, - // rela.text%bar, etc. On Intel, compilers generate .rel.text sections - // which have to be processed as well. A lot of rework is needed here. - Symbol *sptr = NULL; - if (st_check_relocs) - return; - st_check_relocs = true; - - Elf *elf = openElf (false); - if (elf == NULL) - return; - for (unsigned int sec = 1; sec < elf->elf_getehdr ()->e_shnum; sec++) - { - bool use_rela, use_PLT; - char *name = elf->get_sec_name (sec); - if (name == NULL) - continue; - if (strncmp (name, NTXT (".rela.text"), 10) == 0) - { - use_rela = true; - use_PLT = false; - } - else if (streq (name, NTXT (".rela.plt"))) - { - use_rela = true; - use_PLT = true; - } - else if (strncmp (name, NTXT (".rel.text"), 9) == 0) - { - use_rela = false; - use_PLT = false; - } - else if (streq (name, NTXT (".rel.plt"))) - { - use_rela = false; - use_PLT = true; - } - else - continue; - - Elf_Internal_Shdr *shdr = elf->get_shdr (sec); - if (shdr == NULL) - continue; - - // Get ELF data - Elf_Data *data = elf->elf_getdata (sec); - if (data == NULL) - continue; - uint64_t ScnSize = data->d_size; - uint64_t EntSize = shdr->sh_entsize; - if ((ScnSize == 0) || (EntSize == 0)) - continue; - int tot = (int) (ScnSize / EntSize); - - // Get corresponding text section - Elf_Internal_Shdr *shdr_txt = elf->get_shdr (shdr->sh_info); - if (shdr_txt == NULL) - continue; - if (!(shdr_txt->sh_flags & SHF_EXECINSTR)) - continue; - - // Get corresponding symbol table section - Elf_Internal_Shdr *shdr_sym = elf->get_shdr (shdr->sh_link); - if (shdr_sym == NULL) - continue; - Elf_Data *data_sym = elf->elf_getdata (shdr->sh_link); - - // Get corresponding string table section - Elf_Data *data_str = elf->elf_getdata (shdr_sym->sh_link); - if (data_str == NULL) - continue; - char *Strtab = (char*) data_str->d_buf; - for (int n = 0; n < tot; n++) - { - Elf_Internal_Sym sym; - Elf_Internal_Rela rela; - char *symName; - if (use_rela) - elf->elf_getrela (data, n, &rela); - else - { - // GElf_Rela is extended GElf_Rel - elf->elf_getrel (data, n, &rela); - rela.r_addend = 0; - } - - int ndx = (int) GELF_R_SYM (rela.r_info); - elf->elf_getsym (data_sym, ndx, &sym); - switch (GELF_ST_TYPE (sym.st_info)) - { - case STT_FUNC: - case STT_OBJECT: - case STT_NOTYPE: - if (sym.st_name == 0 || sym.st_name >= data_str->d_size) - continue; - symName = Strtab + sym.st_name; - break; - case STT_SECTION: - { - Elf_Internal_Shdr *secHdr = elf->get_shdr (sym.st_shndx); - if (secHdr == NULL) - continue; - if (sptr == NULL) - sptr = new Symbol; - sptr->value = secHdr->sh_offset + rela.r_addend; - long index = SymLst->bisearch (0, -1, &sptr, SymFindCmp); - if (index == -1) - continue; - Symbol *sp = SymLst->fetch (index); - if (sptr->value != sp->value) - continue; - symName = sp->name; - break; - } - default: - continue; - } - Reloc *reloc = new Reloc; - reloc->name = dbe_strdup (symName); - reloc->type = GELF_R_TYPE (rela.r_info); - reloc->value = use_PLT ? rela.r_offset - : rela.r_offset + shdr_txt->sh_offset; - reloc->addend = rela.r_addend; - if (use_PLT) - RelPLTLst->append (reloc); - else - RelLst->append (reloc); - } - } - delete sptr; - RelLst->sort (RelValueCmp); -} //check_Relocs - -void Stabs::get_save_addr (bool need_swap_endian) { if (elfDis->is_Intel ()) diff --git a/gprofng/src/Stabs.h b/gprofng/src/Stabs.h index 42aa6fb..d34741f 100644 --- a/gprofng/src/Stabs.h +++ b/gprofng/src/Stabs.h @@ -129,8 +129,7 @@ class Stabs { // Interface with Elf Symbol Table void check_Symtab(); - void readSymSec(unsigned int sec, Elf *elf); - void check_Relocs(); + void readSymSec (Elf *elf, bool is_dynamic); void get_save_addr(bool need_swap_endian); Symbol *map_PC_to_sym(uint64_t pc); Symbol *pltSym; @@ -146,9 +145,10 @@ class Stabs { Map<const char*, Symbol*> *get_elf_symbols(); Dwarf *dwarf; - bool st_check_symtab, st_check_relocs; + bool st_check_symtab; Function *createFunction(LoadObject *lo, Module *module, Symbol *sym); void fixSymtabAlias(); + void removeDupSyms (); // Interface with dwarf Dwarf *openDwarf(); diff --git a/gprofng/src/vec.h b/gprofng/src/vec.h index 04cce4e..a768a02 100644 --- a/gprofng/src/vec.h +++ b/gprofng/src/vec.h @@ -112,6 +112,13 @@ public: return data[index]; } + void + truncate (long ncount) + { + if (count > ncount && ncount >= 0) + count = ncount; + } + // Return the first index in "this" that equals "item". // Return -1 if "item" is not found. long find (const ITEM item); diff --git a/include/coff/xcoff.h b/include/coff/xcoff.h index 8688742..cae0029 100644 --- a/include/coff/xcoff.h +++ b/include/coff/xcoff.h @@ -204,30 +204,30 @@ struct internal_ldhdr /* The version number: 1 : 32 bit 2 : 64 bit */ - unsigned long l_version; + unsigned int l_version; /* The number of symbol table entries. */ - bfd_size_type l_nsyms; + size_t l_nsyms; /* The number of relocation table entries. */ - bfd_size_type l_nreloc; + size_t l_nreloc; /* The length of the import file string table. */ - bfd_size_type l_istlen; + size_t l_istlen; /* The number of import files. */ - bfd_size_type l_nimpid; + size_t l_nimpid; + + /* The length of the string table. */ + size_t l_stlen; /* The offset from the start of the .loader section to the first entry in the import file table. */ - bfd_size_type l_impoff; - - /* The length of the string table. */ - bfd_size_type l_stlen; + bfd_vma l_impoff; /* The offset from the start of the .loader section to the first entry in the string table. */ - bfd_size_type l_stoff; + bfd_vma l_stoff; /* The offset to start of the symbol table, only in XCOFF64 */ bfd_vma l_symoff; @@ -248,11 +248,11 @@ struct internal_ldsym struct { /* Zero if the symbol name is more than SYMNMLEN characters. */ - long _l_zeroes; + uint32_t _l_zeroes; /* The offset in the string table if the symbol name is more than SYMNMLEN characters. */ - long _l_offset; + uint32_t _l_offset; } _l_l; } diff --git a/ld/pe-dll.c b/ld/pe-dll.c index de1cfaf..4a2ea03 100644 --- a/ld/pe-dll.c +++ b/ld/pe-dll.c @@ -2639,9 +2639,9 @@ make_import_fixup_mark (arelent *rel, char *name) memcpy (fixup_name, buf, prefix_len); bh = NULL; - bfd_coff_link_add_one_symbol (&link_info, abfd, fixup_name, BSF_GLOBAL, - current_sec, /* sym->section, */ - rel->address, NULL, true, false, &bh); + _bfd_generic_link_add_one_symbol (&link_info, abfd, fixup_name, BSF_GLOBAL, + current_sec, /* sym->section, */ + rel->address, NULL, true, false, &bh); return bh->root.string; } diff --git a/ld/testsuite/ld-pe/secidx.d b/ld/testsuite/ld-pe/secidx.d index 184cc9f..d0e52c9 100644 --- a/ld/testsuite/ld-pe/secidx.d +++ b/ld/testsuite/ld-pe/secidx.d @@ -1,11 +1,11 @@ tmpdir/secidx\.x: +file format pei-.* -Contents of section .text: +Contents of section \.text: .*1000 3e3e3e3e 3c3c3c3c 3e3e3e3e 3e3c3c3c >>>><<<<>>>>><<< .*1010 3e3e3e3e 3e3e3c3c 3e3e3e3e 3e3e3e3c >>>>>><<>>>>>>>< .*1020 3c3c3c3c 3e3e3e3e 3e909090 <<<<>>>>>... -Contents of section .data: +Contents of section \.data: .*2000 3e3e3e3e 3c3c3c3c 3e3e3e3e 3e3c3c3c >>>><<<<>>>>><<< .*2010 3e3e3e3e 3e3e3c3c 3e3e3e3e 3e3e3e3c >>>>>><<>>>>>>>< .*2020 3e3e3e3e 01001101 00110100 11010011 >>>>............ @@ -15,13 +15,13 @@ Contents of section .data: .*2060 3c3c3c3c 3c3c3c3c 3e3e3e3e 01001102 <<<<<<<<>>>>.... .*2070 00110300 113c3c3c 3c3c3c3c 3c000000 .....<<<<<<<<... .*2080 3c3c3c3e 3e3e3e3e 3e000000 <<<>>>>>>... -Contents of section .rdata: +Contents of section \.rdata: .*3000 3e3e3e3e 3c3c3c3c 3e3e3e3e 3e3c3c3c >>>><<<<>>>>><<< .*3010 3e3e3e3e 3e3e3c3c 3e3e3e3e 3e3e3e3c >>>>>><<>>>>>>>< .*3020 3e3e3e3e 00000000 00000000 00000000 >>>>............ .*3030 3c3c3c3e 3e3e3e3e 3e000000 ffffffff <<<>>>>>>....... .*3040 00000000 ffffffff 00000000 ............ -Contents of section .idata: +Contents of section \.idata: .*4000 00000000 00000000 00000000 00000000 ................ .*4010 00000000 .... #... diff --git a/ld/testsuite/ld-plugin/lto-20.ver b/ld/testsuite/ld-plugin/lto-20.ver new file mode 100644 index 0000000..ac906ac --- /dev/null +++ b/ld/testsuite/ld-plugin/lto-20.ver @@ -0,0 +1 @@ +FOO { global: foo; }; diff --git a/ld/testsuite/ld-plugin/lto-20a.c b/ld/testsuite/ld-plugin/lto-20a.c new file mode 100644 index 0000000..3d6dac9 --- /dev/null +++ b/ld/testsuite/ld-plugin/lto-20a.c @@ -0,0 +1,2 @@ +extern int foo (); +int main () { return foo (); } diff --git a/ld/testsuite/ld-plugin/lto-20b.c b/ld/testsuite/ld-plugin/lto-20b.c new file mode 100644 index 0000000..ba123cb --- /dev/null +++ b/ld/testsuite/ld-plugin/lto-20b.c @@ -0,0 +1,11 @@ +extern int printf (const char *, ...); +int foo () +{ +#ifdef SHARED + printf ("PASS\n"); + return 0; +#else + printf ("FAIL\n"); + return 1; +#endif +} diff --git a/ld/testsuite/ld-plugin/lto.exp b/ld/testsuite/ld-plugin/lto.exp index 556bbe9..9349190 100644 --- a/ld/testsuite/ld-plugin/lto.exp +++ b/ld/testsuite/ld-plugin/lto.exp @@ -477,6 +477,12 @@ set lto_link_elf_tests [list \ [list {liblto-19.so} \ {-shared tmpdir/lto-19b.o tmpdir/liblto-19.a} {-O2 -fPIC} \ {dummy.c} {} {liblto-19.so}] \ + [list {liblto-20_static.a} \ + {} {-fPIC} \ + {lto-20b.c} {} {liblto-20_static.a}] \ + [list {liblto-20.so} \ + {-shared -Wl,--version-script=lto-20.ver} {-DSHARED -fPIC} \ + {lto-20b.c} {} {liblto-20.so}] \ [list {pr26806.so} \ {-shared} {-fpic -O2 -flto} \ {pr26806.c} {{nm {-D} pr26806.d}} {pr26806.so}] \ @@ -880,6 +886,10 @@ set lto_run_elf_shared_tests [list \ {-Wl,--as-needed,-R,tmpdir} {} \ {lto-19c.c} {lto-19.exe} {pass.out} {-flto -O2} {c} {} \ {tmpdir/liblto-19.so tmpdir/liblto-19.a}] \ + [list {lto-20} \ + {-Wl,--as-needed,-R,tmpdir} {} \ + {lto-20a.c} {lto-20.exe} {pass.out} {-flto} {c} {} \ + {tmpdir/liblto-20.so tmpdir/liblto-20_static.a -Wl,--no-as-needed}] \ [list {pr31482a} \ {-Wl,--no-as-needed,-R,tmpdir} {} \ {pr31482a.c} {pr31482a.exe} {pass.out} {-flto} {c} {} \ |