From ebcc3a796fcf9fa6a5a652b8d89660f90fe7fb98 Mon Sep 17 00:00:00 2001 From: Alexpux Date: Fri, 14 Mar 2014 12:09:21 +0400 Subject: [PATCH] gdb: Add support for bigobj file format. Fix using gnu_print with mingw. --- mingw-w64-gdb/020-add-bigobj-format.patch | 779 ++++++++++++++++++++ mingw-w64-gdb/PKGBUILD | 15 +- mingw-w64-gdb/gdb-fix-using-gnu-print.patch | 68 +- 3 files changed, 854 insertions(+), 8 deletions(-) create mode 100644 mingw-w64-gdb/020-add-bigobj-format.patch diff --git a/mingw-w64-gdb/020-add-bigobj-format.patch b/mingw-w64-gdb/020-add-bigobj-format.patch new file mode 100644 index 0000000000..04591e05ef --- /dev/null +++ b/mingw-w64-gdb/020-add-bigobj-format.patch @@ -0,0 +1,779 @@ +From 167ad85bf06582759e8dfe021aac9da79b81340d Mon Sep 17 00:00:00 2001 +From: Tristan Gingold +Date: Mon, 2 Dec 2013 14:30:32 +0100 +Subject: [PATCH] Add pe/x86_64 bigobj file format. + +bfd/ + * peicode.h (pe_ILF_object_p): Adjust, as the version number + has been read. + (pe_bfd_object_p): Also read version number to detect ILF. + * pe-x86_64.c (COFF_WITH_PE_BIGOBJ): Define. + (x86_64pe_bigobj_vec): Define + * coffcode.h (bfd_coff_backend_data): Add _bfd_coff_max_nscns field. + (bfd_coff_max_nscns): New macro. + (coff_compute_section_file_positions): Use unsigned int for + target_index. Compare with bfd_coff_max_nscns. + (bfd_coff_std_swap_table, ticoff0_swap_table, ticoff1_swap_table): + Set a value for _bfd_coff_max_nscns. + (header_bigobj_classid): New constant. + (coff_bigobj_swap_filehdr_in, coff_bigobj_swap_filehdr_out) + (coff_bigobj_swap_sym_in, coff_bigobj_swap_sym_out) + (coff_bigobj_swap_aux_in, coff_bigobj_swap_aux_out): New + functions. + (bigobj_swap_table): New table. + * libcoff.h: Regenerate. + * coff-sh.c (bfd_coff_small_swap_table): Likewise. + * coff-alpha.c (alpha_ecoff_backend_data): Add value for + _bfd_coff_max_nscns. + * coff-mips.c (mips_ecoff_backend_data): Likewise. + * coff-rs6000.c (bfd_xcoff_backend_data) + (bfd_pmac_xcoff_backend_data): Likewise. + * coff64-rs6000.c (bfd_xcoff_backend_data) + (bfd_xcoff_aix5_backend_data): Likewise. + * targets.c (x86_64pe_bigobj_vec): Declare. + * configure.in (x86_64pe_bigobj_vec): New vector. + * configure: Regenerate. + * config.bfd: Add bigobj object format for Windows targets. + +include/coff/ + * pe.h (struct external_ANON_OBJECT_HEADER_BIGOBJ): Declare. + (FILHSZ_BIGOBJ): Define. + (struct external_SYMBOL_EX): Declare. + (SYMENT_BIGOBJ, SYMESZ_BIGOBJ): Define. + (union external_AUX_SYMBOL_EX): Declare. + (AUXENT_BIGOBJ, AUXESZ_BIGOBJ): Define. + * internal.h (struct internal_filehdr): Change type + of f_nscns. +--- + bfd/ChangeLog | 33 ++++++ + bfd/coff-alpha.c | 2 +- + bfd/coff-mips.c | 2 +- + bfd/coff-rs6000.c | 2 + + bfd/coff-sh.c | 1 + + bfd/coff64-rs6000.c | 2 + + bfd/coffcode.h | 258 ++++++++++++++++++++++++++++++++++++++++- + bfd/config.bfd | 2 +- + bfd/configure | 1 + + bfd/configure.in | 1 + + bfd/libcoff.h | 4 + + bfd/pe-x86_64.c | 54 +++++++++ + bfd/peicode.h | 19 ++- + bfd/targets.c | 2 + + include/coff/ChangeLog | 11 ++ + include/coff/internal.h | 2 +- + include/coff/pe.h | 79 +++++++++++++ + 24 files changed, 537 insertions(+), 17 deletions(-) + +diff --git a/bfd/coff-alpha.c b/bfd/coff-alpha.c +index a7a977c..8c68b56 100644 +--- a/bfd/coff-alpha.c ++++ b/bfd/coff-alpha.c +@@ -2241,7 +2241,7 @@ static const struct ecoff_backend_data alpha_ecoff_backend_data = + alpha_ecoff_swap_filehdr_out, alpha_ecoff_swap_aouthdr_out, + alpha_ecoff_swap_scnhdr_out, + FILHSZ, AOUTSZ, SCNHSZ, 0, 0, 0, 0, FILNMLEN, TRUE, +- ECOFF_NO_LONG_SECTION_NAMES, 4, FALSE, 2, ++ ECOFF_NO_LONG_SECTION_NAMES, 4, FALSE, 2, 32768, + alpha_ecoff_swap_filehdr_in, alpha_ecoff_swap_aouthdr_in, + alpha_ecoff_swap_scnhdr_in, NULL, + alpha_ecoff_bad_format_hook, _bfd_ecoff_set_arch_mach_hook, +diff --git a/bfd/coff-mips.c b/bfd/coff-mips.c +index 454f89a..3a30d83 100644 +--- a/bfd/coff-mips.c ++++ b/bfd/coff-mips.c +@@ -1254,7 +1254,7 @@ static const struct ecoff_backend_data mips_ecoff_backend_data = + mips_ecoff_swap_filehdr_out, mips_ecoff_swap_aouthdr_out, + mips_ecoff_swap_scnhdr_out, + FILHSZ, AOUTSZ, SCNHSZ, 0, 0, 0, 0, FILNMLEN, TRUE, +- ECOFF_NO_LONG_SECTION_NAMES, 4, FALSE, 2, ++ ECOFF_NO_LONG_SECTION_NAMES, 4, FALSE, 2, 32768, + mips_ecoff_swap_filehdr_in, mips_ecoff_swap_aouthdr_in, + mips_ecoff_swap_scnhdr_in, NULL, + mips_ecoff_bad_format_hook, _bfd_ecoff_set_arch_mach_hook, +diff --git a/bfd/coff-rs6000.c b/bfd/coff-rs6000.c +index 06ee721..d0b8eaf 100644 +--- a/bfd/coff-rs6000.c ++++ b/bfd/coff-rs6000.c +@@ -4105,6 +4105,7 @@ static const struct xcoff_backend_data_rec bfd_xcoff_backend_data = + 3, /* _bfd_coff_default_section_alignment_power */ + FALSE, /* _bfd_coff_force_symnames_in_strings */ + 2, /* _bfd_coff_debug_string_prefix_length */ ++ 32768, /* _bfd_coff_max_nscns */ + coff_swap_filehdr_in, + coff_swap_aouthdr_in, + coff_swap_scnhdr_in, +@@ -4285,6 +4286,7 @@ static const struct xcoff_backend_data_rec bfd_pmac_xcoff_backend_data = + 3, /* _bfd_coff_default_section_alignment_power */ + FALSE, /* _bfd_coff_force_symnames_in_strings */ + 2, /* _bfd_coff_debug_string_prefix_length */ ++ 32768, /* _bfd_coff_max_nscns */ + coff_swap_filehdr_in, + coff_swap_aouthdr_in, + coff_swap_scnhdr_in, +diff --git a/bfd/coff-sh.c b/bfd/coff-sh.c +index aca2b8b..1bf3f21 100644 +--- a/bfd/coff-sh.c ++++ b/bfd/coff-sh.c +@@ -3090,6 +3090,7 @@ static bfd_coff_backend_data bfd_coff_small_swap_table = + #else + 2, + #endif ++ 32768, + coff_swap_filehdr_in, coff_swap_aouthdr_in, coff_swap_scnhdr_in, + coff_swap_reloc_in, coff_bad_format_hook, coff_set_arch_mach_hook, + coff_mkobject_hook, styp_to_sec_flags, coff_set_alignment_hook, +diff --git a/bfd/coff64-rs6000.c b/bfd/coff64-rs6000.c +index 4bc7ea8..d660e3a5 100644 +--- a/bfd/coff64-rs6000.c ++++ b/bfd/coff64-rs6000.c +@@ -2542,6 +2542,7 @@ static const struct xcoff_backend_data_rec bfd_xcoff_backend_data = + 3, /* _bfd_coff_default_section_alignment_power */ + TRUE, /* _bfd_coff_force_symnames_in_strings */ + 4, /* _bfd_coff_debug_string_prefix_length */ ++ 32768, /* _bfd_coff_max_nscns */ + coff_swap_filehdr_in, + coff_swap_aouthdr_in, + coff_swap_scnhdr_in, +@@ -2801,6 +2802,7 @@ static const struct xcoff_backend_data_rec bfd_xcoff_aix5_backend_data = + 3, /* _bfd_coff_default_section_alignment_power */ + TRUE, /* _bfd_coff_force_symnames_in_strings */ + 4, /* _bfd_coff_debug_string_prefix_length */ ++ 32768, /* _bfd_coff_max_nscns */ + coff_swap_filehdr_in, + coff_swap_aouthdr_in, + coff_swap_scnhdr_in, +diff --git a/bfd/coffcode.h b/bfd/coffcode.h +index 11e70a5..d6fe39f 100644 +--- a/bfd/coffcode.h ++++ b/bfd/coffcode.h +@@ -1393,6 +1393,7 @@ Special entry points for gdb to swap in coff symbol table parts: + . unsigned int _bfd_coff_default_section_alignment_power; + . bfd_boolean _bfd_coff_force_symnames_in_strings; + . unsigned int _bfd_coff_debug_string_prefix_length; ++. unsigned int _bfd_coff_max_nscns; + . + . void (*_bfd_coff_swap_filehdr_in) + . (bfd *, void *, void *); +@@ -1530,6 +1531,9 @@ Special entry points for gdb to swap in coff symbol table parts: + . ((coff_backend_info (abfd)->_bfd_coff_set_long_section_names) (abfd, enable)) + .#define bfd_coff_default_section_alignment_power(abfd) \ + . (coff_backend_info (abfd)->_bfd_coff_default_section_alignment_power) ++.#define bfd_coff_max_nscns(abfd) \ ++. (coff_backend_info (abfd)->_bfd_coff_max_nscns) ++. + .#define bfd_coff_swap_filehdr_in(abfd, i,o) \ + . ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_in) (abfd, i, o)) + . +@@ -3136,7 +3140,7 @@ coff_compute_section_file_positions (bfd * abfd) + asection *current; + file_ptr sofar = bfd_coff_filhsz (abfd); + bfd_boolean align_adjust; +- int target_index; ++ unsigned int target_index; + #ifdef ALIGN_SECTIONS_IN_FILE + asection *previous = NULL; + file_ptr old_sofar; +@@ -3304,7 +3308,7 @@ coff_compute_section_file_positions (bfd * abfd) + } + #endif /* ! COFF_IMAGE_WITH_PE */ + +- if (target_index >= 32768) ++ if (target_index >= bfd_coff_max_nscns (abfd)) + { + bfd_set_error (bfd_error_file_too_big); + (*_bfd_error_handler) +@@ -5497,6 +5501,7 @@ static bfd_coff_backend_data bfd_coff_std_swap_table ATTRIBUTE_UNUSED = + #else + 2, + #endif ++ 32768, + coff_SWAP_filehdr_in, coff_SWAP_aouthdr_in, coff_SWAP_scnhdr_in, + coff_SWAP_reloc_in, coff_bad_format_hook, coff_set_arch_mach_hook, + coff_mkobject_hook, styp_to_sec_flags, coff_set_alignment_hook, +@@ -5537,6 +5542,7 @@ static bfd_coff_backend_data ticoff0_swap_table = + #else + 2, + #endif ++ 32768, + coff_SWAP_filehdr_in, coff_SWAP_aouthdr_in, coff_SWAP_scnhdr_in, + coff_SWAP_reloc_in, ticoff0_bad_format_hook, coff_set_arch_mach_hook, + coff_mkobject_hook, styp_to_sec_flags, coff_set_alignment_hook, +@@ -5578,6 +5584,7 @@ static bfd_coff_backend_data ticoff1_swap_table = + #else + 2, + #endif ++ 32768, + coff_SWAP_filehdr_in, coff_SWAP_aouthdr_in, coff_SWAP_scnhdr_in, + coff_SWAP_reloc_in, ticoff1_bad_format_hook, coff_set_arch_mach_hook, + coff_mkobject_hook, styp_to_sec_flags, coff_set_alignment_hook, +@@ -5591,6 +5598,253 @@ static bfd_coff_backend_data ticoff1_swap_table = + }; + #endif + ++#ifdef COFF_WITH_PE_BIGOBJ ++/* The UUID for bigobj files. */ ++ ++static const char header_bigobj_classid[16] = ++{ ++ 0xC7, 0xA1, 0xBA, 0xD1, ++ 0xEE, 0xBA, ++ 0xa9, 0x4b, ++ 0xAF, 0x20, ++ 0xFA, 0xF6, 0x6A, 0xA4, 0xDC, 0xB8 ++}; ++ ++/* Swap routines. */ ++ ++static void ++coff_bigobj_swap_filehdr_in (bfd * abfd, void * src, void * dst) ++{ ++ struct external_ANON_OBJECT_HEADER_BIGOBJ *filehdr_src = ++ (struct external_ANON_OBJECT_HEADER_BIGOBJ *) src; ++ struct internal_filehdr *filehdr_dst = (struct internal_filehdr *) dst; ++ ++ filehdr_dst->f_magic = H_GET_16 (abfd, filehdr_src->Machine); ++ filehdr_dst->f_nscns = H_GET_32 (abfd, filehdr_src->NumberOfSections); ++ filehdr_dst->f_timdat = H_GET_32 (abfd, filehdr_src->TimeDateStamp); ++ filehdr_dst->f_symptr = ++ GET_FILEHDR_SYMPTR (abfd, filehdr_src->PointerToSymbolTable); ++ filehdr_dst->f_nsyms = H_GET_32 (abfd, filehdr_src->NumberOfSymbols); ++ filehdr_dst->f_opthdr = 0; ++ filehdr_dst->f_flags = 0; ++ ++ /* Check other magic numbers. */ ++ if (H_GET_16 (abfd, filehdr_src->Sig1) != IMAGE_FILE_MACHINE_UNKNOWN ++ || H_GET_16 (abfd, filehdr_src->Sig2) != 0xffff ++ || H_GET_16 (abfd, filehdr_src->Version) != 2 ++ || memcmp (filehdr_src->ClassID, header_bigobj_classid, 16) != 0) ++ filehdr_dst->f_opthdr = 0xffff; ++ ++ /* Note that CLR metadata are ignored. */ ++} ++ ++static unsigned int ++coff_bigobj_swap_filehdr_out (bfd *abfd, void * in, void * out) ++{ ++ struct internal_filehdr *filehdr_in = (struct internal_filehdr *) in; ++ struct external_ANON_OBJECT_HEADER_BIGOBJ *filehdr_out = ++ (struct external_ANON_OBJECT_HEADER_BIGOBJ *) out; ++ ++ memset (filehdr_out, 0, sizeof (*filehdr_out)); ++ ++ H_PUT_16 (abfd, IMAGE_FILE_MACHINE_UNKNOWN, filehdr_out->Sig1); ++ H_PUT_16 (abfd, 0xffff, filehdr_out->Sig2); ++ H_PUT_16 (abfd, 2, filehdr_out->Version); ++ memcpy (filehdr_out->ClassID, header_bigobj_classid, 16); ++ H_PUT_16 (abfd, filehdr_in->f_magic, filehdr_out->Machine); ++ H_PUT_32 (abfd, filehdr_in->f_nscns, filehdr_out->NumberOfSections); ++ H_PUT_32 (abfd, filehdr_in->f_timdat, filehdr_out->TimeDateStamp); ++ PUT_FILEHDR_SYMPTR (abfd, filehdr_in->f_symptr, ++ filehdr_out->PointerToSymbolTable); ++ H_PUT_32 (abfd, filehdr_in->f_nsyms, filehdr_out->NumberOfSymbols); ++ ++ return bfd_coff_filhsz (abfd); ++} ++ ++static void ++coff_bigobj_swap_sym_in (bfd * abfd, void * ext1, void * in1) ++{ ++ SYMENT_BIGOBJ *ext = (SYMENT_BIGOBJ *) ext1; ++ struct internal_syment *in = (struct internal_syment *) in1; ++ ++ if (ext->e.e_name[0] == 0) ++ { ++ in->_n._n_n._n_zeroes = 0; ++ in->_n._n_n._n_offset = H_GET_32 (abfd, ext->e.e.e_offset); ++ } ++ else ++ { ++#if SYMNMLEN != E_SYMNMLEN ++#error we need to cope with truncating or extending SYMNMLEN ++#else ++ memcpy (in->_n._n_name, ext->e.e_name, SYMNMLEN); ++#endif ++ } ++ ++ in->n_value = H_GET_32 (abfd, ext->e_value); ++ in->n_scnum = H_GET_32 (abfd, ext->e_scnum); ++ in->n_type = H_GET_16 (abfd, ext->e_type); ++ in->n_sclass = H_GET_8 (abfd, ext->e_sclass); ++ in->n_numaux = H_GET_8 (abfd, ext->e_numaux); ++} ++ ++static unsigned int ++coff_bigobj_swap_sym_out (bfd * abfd, void * inp, void * extp) ++{ ++ struct internal_syment *in = (struct internal_syment *) inp; ++ SYMENT_BIGOBJ *ext = (SYMENT_BIGOBJ *) extp; ++ ++ if (in->_n._n_name[0] == 0) ++ { ++ H_PUT_32 (abfd, 0, ext->e.e.e_zeroes); ++ H_PUT_32 (abfd, in->_n._n_n._n_offset, ext->e.e.e_offset); ++ } ++ else ++ { ++#if SYMNMLEN != E_SYMNMLEN ++#error we need to cope with truncating or extending SYMNMLEN ++#else ++ memcpy (ext->e.e_name, in->_n._n_name, SYMNMLEN); ++#endif ++ } ++ ++ H_PUT_32 (abfd, in->n_value, ext->e_value); ++ H_PUT_32 (abfd, in->n_scnum, ext->e_scnum); ++ ++ H_PUT_16 (abfd, in->n_type, ext->e_type); ++ H_PUT_8 (abfd, in->n_sclass, ext->e_sclass); ++ H_PUT_8 (abfd, in->n_numaux, ext->e_numaux); ++ ++ return SYMESZ_BIGOBJ; ++} ++ ++static void ++coff_bigobj_swap_aux_in (bfd *abfd, ++ void * ext1, ++ int type, ++ int in_class, ++ int indx, ++ int numaux, ++ void * in1) ++{ ++ AUXENT_BIGOBJ *ext = (AUXENT_BIGOBJ *) ext1; ++ union internal_auxent *in = (union internal_auxent *) in1; ++ ++ switch (in_class) ++ { ++ case C_FILE: ++ if (numaux > 1) ++ { ++ if (indx == 0) ++ memcpy (in->x_file.x_fname, ext->File.Name, ++ numaux * sizeof (AUXENT_BIGOBJ)); ++ } ++ else ++ memcpy (in->x_file.x_fname, ext->File.Name, sizeof (ext->File.Name)); ++ break; ++ ++ case C_STAT: ++ case C_LEAFSTAT: ++ case C_HIDDEN: ++ if (type == T_NULL) ++ { ++ in->x_scn.x_scnlen = H_GET_32 (abfd, ext->Section.Length); ++ in->x_scn.x_nreloc = ++ H_GET_16 (abfd, ext->Section.NumberOfRelocations); ++ in->x_scn.x_nlinno = ++ H_GET_16 (abfd, ext->Section.NumberOfLinenumbers); ++ in->x_scn.x_checksum = H_GET_32 (abfd, ext->Section.Checksum); ++ in->x_scn.x_associated = H_GET_16 (abfd, ext->Section.Number) ++ | (H_GET_16 (abfd, ext->Section.HighNumber) << 16); ++ in->x_scn.x_comdat = H_GET_8 (abfd, ext->Section.Selection); ++ return; ++ } ++ break; ++ ++ default: ++ in->x_sym.x_tagndx.l = H_GET_32 (abfd, ext->Sym.WeakDefaultSymIndex); ++ /* Characteristics is ignored. */ ++ break; ++ } ++} ++ ++static unsigned int ++coff_bigobj_swap_aux_out (bfd * abfd, ++ void * inp, ++ int type, ++ int in_class, ++ int indx ATTRIBUTE_UNUSED, ++ int numaux ATTRIBUTE_UNUSED, ++ void * extp) ++{ ++ union internal_auxent * in = (union internal_auxent *) inp; ++ AUXENT_BIGOBJ *ext = (AUXENT_BIGOBJ *) extp; ++ ++ memset (ext, 0, AUXESZ); ++ ++ switch (in_class) ++ { ++ case C_FILE: ++ memcpy (ext->File.Name, in->x_file.x_fname, sizeof (ext->File.Name)); ++ ++ return AUXESZ; ++ ++ case C_STAT: ++ case C_LEAFSTAT: ++ case C_HIDDEN: ++ if (type == T_NULL) ++ { ++ H_PUT_32 (abfd, in->x_scn.x_scnlen, ext->Section.Length); ++ H_PUT_16 (abfd, in->x_scn.x_nreloc, ++ ext->Section.NumberOfRelocations); ++ H_PUT_16 (abfd, in->x_scn.x_nlinno, ++ ext->Section.NumberOfLinenumbers); ++ H_PUT_32 (abfd, in->x_scn.x_checksum, ext->Section.Checksum); ++ H_PUT_16 (abfd, in->x_scn.x_associated & 0xffff, ++ ext->Section.Number); ++ H_PUT_16 (abfd, (in->x_scn.x_associated >> 16), ++ ext->Section.HighNumber); ++ H_PUT_8 (abfd, in->x_scn.x_comdat, ext->Section.Selection); ++ return AUXESZ; ++ } ++ break; ++ } ++ ++ H_PUT_32 (abfd, in->x_sym.x_tagndx.l, ext->Sym.WeakDefaultSymIndex); ++ H_PUT_32 (abfd, 1, ext->Sym.WeakSearchType); ++ ++ return AUXESZ; ++} ++ ++static bfd_coff_backend_data bigobj_swap_table = ++{ ++ coff_bigobj_swap_aux_in, coff_bigobj_swap_sym_in, coff_SWAP_lineno_in, ++ coff_bigobj_swap_aux_out, coff_bigobj_swap_sym_out, ++ coff_SWAP_lineno_out, coff_SWAP_reloc_out, ++ coff_bigobj_swap_filehdr_out, coff_SWAP_aouthdr_out, ++ coff_SWAP_scnhdr_out, ++ FILHSZ_BIGOBJ, AOUTSZ, SCNHSZ, SYMESZ_BIGOBJ, AUXESZ_BIGOBJ, ++ RELSZ, LINESZ, FILNMLEN_BIGOBJ, ++ TRUE, ++ COFF_DEFAULT_LONG_SECTION_NAMES, ++ COFF_DEFAULT_SECTION_ALIGNMENT_POWER, ++ FALSE, ++ 2, ++ 1U << 31, ++ coff_bigobj_swap_filehdr_in, coff_SWAP_aouthdr_in, coff_SWAP_scnhdr_in, ++ coff_SWAP_reloc_in, coff_bad_format_hook, coff_set_arch_mach_hook, ++ coff_mkobject_hook, styp_to_sec_flags, coff_set_alignment_hook, ++ coff_slurp_symbol_table, symname_in_debug_hook, coff_pointerize_aux_hook, ++ 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_link_output_has_begun, coff_final_link_postscript, ++ bfd_pe_print_pdata /* huh */ ++}; ++ ++#endif /* COFF_WITH_PE_BIGOBJ */ ++ + #ifndef coff_close_and_cleanup + #define coff_close_and_cleanup _bfd_generic_close_and_cleanup + #endif +diff --git a/bfd/config.bfd b/bfd/config.bfd +index 59b9f64..147954a 100644 +--- a/bfd/config.bfd ++++ b/bfd/config.bfd +@@ -676,7 +676,7 @@ case "${targ}" in + ;; + x86_64-*-mingw* | x86_64-*-pe | x86_64-*-pep | x86_64-*-cygwin) + targ_defvec=x86_64pe_vec +- targ_selvecs="x86_64pe_vec x86_64pei_vec bfd_elf64_x86_64_vec bfd_elf64_l1om_vec bfd_elf64_k1om_vec i386pe_vec i386pei_vec bfd_elf32_i386_vec" ++ targ_selvecs="x86_64pe_vec x86_64pei_vec x86_64pe_bigobj_vec bfd_elf64_x86_64_vec bfd_elf64_l1om_vec bfd_elf64_k1om_vec i386pe_vec i386pei_vec bfd_elf32_i386_vec" + want64=true + targ_underscore=no + ;; +diff --git a/bfd/configure b/bfd/configure +index bef7295..fbf5f44 100755 +--- a/bfd/configure ++++ b/bfd/configure +@@ -15453,6 +15453,7 @@ do + i386pei_vec) tb="$tb pei-i386.lo peigen.lo cofflink.lo" ;; + x86_64pe_vec) tb="$tb pe-x86_64.lo pex64igen.lo cofflink.lo"; target_size=64 ;; + x86_64pei_vec) tb="$tb pei-x86_64.lo pex64igen.lo cofflink.lo"; target_size=64 ;; ++ x86_64pe_bigobj_vec) tb="$tb pe-x86_64.lo pex64igen.lo cofflink.lo"; target_size=64 ;; + i860coff_vec) tb="$tb coff-i860.lo cofflink.lo" ;; + icoff_big_vec) tb="$tb coff-i960.lo cofflink.lo" ;; + icoff_little_vec) tb="$tb coff-i960.lo cofflink.lo" ;; +diff --git a/bfd/configure.in b/bfd/configure.in +index da8c6dc..f1ec965 100644 +--- a/bfd/configure.in ++++ b/bfd/configure.in +@@ -942,6 +942,7 @@ do + i386pei_vec) tb="$tb pei-i386.lo peigen.lo cofflink.lo" ;; + x86_64pe_vec) tb="$tb pe-x86_64.lo pex64igen.lo cofflink.lo"; target_size=64 ;; + x86_64pei_vec) tb="$tb pei-x86_64.lo pex64igen.lo cofflink.lo"; target_size=64 ;; ++ x86_64pe_bigobj_vec) tb="$tb pe-x86_64.lo pex64igen.lo cofflink.lo"; target_size=64 ;; + i860coff_vec) tb="$tb coff-i860.lo cofflink.lo" ;; + icoff_big_vec) tb="$tb coff-i960.lo cofflink.lo" ;; + icoff_little_vec) tb="$tb coff-i960.lo cofflink.lo" ;; +diff --git a/bfd/libcoff.h b/bfd/libcoff.h +index b5a9852..36c9829 100644 +--- a/bfd/libcoff.h ++++ b/bfd/libcoff.h +@@ -736,6 +736,7 @@ typedef struct + unsigned int _bfd_coff_default_section_alignment_power; + bfd_boolean _bfd_coff_force_symnames_in_strings; + unsigned int _bfd_coff_debug_string_prefix_length; ++ unsigned int _bfd_coff_max_nscns; + + void (*_bfd_coff_swap_filehdr_in) + (bfd *, void *, void *); +@@ -873,6 +874,9 @@ typedef struct + ((coff_backend_info (abfd)->_bfd_coff_set_long_section_names) (abfd, enable)) + #define bfd_coff_default_section_alignment_power(abfd) \ + (coff_backend_info (abfd)->_bfd_coff_default_section_alignment_power) ++#define bfd_coff_max_nscns(abfd) \ ++ (coff_backend_info (abfd)->_bfd_coff_max_nscns) ++ + #define bfd_coff_swap_filehdr_in(abfd, i,o) \ + ((coff_backend_info (abfd)->_bfd_coff_swap_filehdr_in) (abfd, i, o)) + +diff --git a/bfd/pe-x86_64.c b/bfd/pe-x86_64.c +index 26bb99d..16b13ec 100644 +--- a/bfd/pe-x86_64.c ++++ b/bfd/pe-x86_64.c +@@ -27,6 +27,7 @@ + #define TARGET_NAME "pe-x86-64" + #define COFF_WITH_PE + #define COFF_WITH_pex64 ++#define COFF_WITH_PE_BIGOBJ + #define PCRELOFFSET TRUE + #if defined (USE_MINGW64_LEADING_UNDERSCORES) + #define TARGET_UNDERSCORE '_' +@@ -58,3 +59,56 @@ + COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 } + + #include "coff-x86_64.c" ++ ++/* Entry for big object files. */ ++ ++const bfd_target ++x86_64pe_bigobj_vec = ++{ ++ "pe-bigobj-x86-64", /* Name. */ ++ bfd_target_coff_flavour, ++ BFD_ENDIAN_LITTLE, /* Data byte order is little. */ ++ BFD_ENDIAN_LITTLE, /* Header byte order is little. */ ++ ++ (HAS_RELOC | EXEC_P | /* Object flags. */ ++ HAS_LINENO | HAS_DEBUG | ++ HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED | BFD_COMPRESS | BFD_DECOMPRESS), ++ ++ (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC /* Section flags. */ ++ | SEC_LINK_ONCE | SEC_LINK_DUPLICATES | SEC_READONLY | SEC_DEBUGGING ++ | SEC_CODE | SEC_DATA | SEC_EXCLUDE ), ++ ++ TARGET_UNDERSCORE, /* Leading underscore. */ ++ '/', /* Ar_pad_char. */ ++ 15, /* Ar_max_namelen. */ ++ 0, /* match priority. */ ++ ++ bfd_getl64, bfd_getl_signed_64, bfd_putl64, ++ bfd_getl32, bfd_getl_signed_32, bfd_putl32, ++ bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* Data. */ ++ bfd_getl64, bfd_getl_signed_64, bfd_putl64, ++ bfd_getl32, bfd_getl_signed_32, bfd_putl32, ++ bfd_getl16, bfd_getl_signed_16, bfd_putl16, /* Hdrs. */ ++ ++ /* Note that we allow an object file to be treated as a core file as well. */ ++ { _bfd_dummy_target, amd64coff_object_p, /* BFD_check_format. */ ++ bfd_generic_archive_p, amd64coff_object_p }, ++ { bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format. */ ++ bfd_false }, ++ { bfd_false, coff_write_object_contents, /* bfd_write_contents. */ ++ _bfd_write_archive_contents, bfd_false }, ++ ++ BFD_JUMP_TABLE_GENERIC (coff), ++ BFD_JUMP_TABLE_COPY (coff), ++ BFD_JUMP_TABLE_CORE (_bfd_nocore), ++ BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff), ++ BFD_JUMP_TABLE_SYMBOLS (coff), ++ BFD_JUMP_TABLE_RELOCS (coff), ++ BFD_JUMP_TABLE_WRITE (coff), ++ BFD_JUMP_TABLE_LINK (coff), ++ BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), ++ ++ NULL, ++ ++ &bigobj_swap_table ++}; +diff --git a/bfd/peicode.h b/bfd/peicode.h +index 8fd689c..157879b 100644 +--- a/bfd/peicode.h ++++ b/bfd/peicode.h +@@ -1077,7 +1077,7 @@ pe_ILF_build_a_bfd (bfd * abfd, + static const bfd_target * + pe_ILF_object_p (bfd * abfd) + { +- bfd_byte buffer[16]; ++ bfd_byte buffer[14]; + bfd_byte * ptr; + char * symbol_name; + char * source_dll; +@@ -1087,17 +1087,13 @@ pe_ILF_object_p (bfd * abfd) + unsigned int types; + unsigned int magic; + +- /* Upon entry the first four buyes of the ILF header have ++ /* Upon entry the first six bytes of the ILF header have + already been read. Now read the rest of the header. */ +- if (bfd_bread (buffer, (bfd_size_type) 16, abfd) != 16) ++ if (bfd_bread (buffer, (bfd_size_type) 14, abfd) != 14) + return NULL; + + ptr = buffer; + +- /* We do not bother to check the version number. +- version = H_GET_16 (abfd, ptr); */ +- ptr += 2; +- + machine = H_GET_16 (abfd, ptr); + ptr += 2; + +@@ -1251,7 +1247,7 @@ pe_ILF_object_p (bfd * abfd) + static const bfd_target * + pe_bfd_object_p (bfd * abfd) + { +- bfd_byte buffer[4]; ++ bfd_byte buffer[6]; + struct external_PEI_DOS_hdr dos_hdr; + struct external_PEI_IMAGE_hdr image_hdr; + struct internal_filehdr internal_f; +@@ -1260,15 +1256,18 @@ pe_bfd_object_p (bfd * abfd) + file_ptr offset; + + /* Detect if this a Microsoft Import Library Format element. */ ++ /* First read the beginning of the header. */ + if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 +- || bfd_bread (buffer, (bfd_size_type) 4, abfd) != 4) ++ || bfd_bread (buffer, (bfd_size_type) 6, abfd) != 6) + { + if (bfd_get_error () != bfd_error_system_call) + bfd_set_error (bfd_error_wrong_format); + return NULL; + } + +- if (H_GET_32 (abfd, buffer) == 0xffff0000) ++ /* Then check the magic and the version (only 0 is supported). */ ++ if (H_GET_32 (abfd, buffer) == 0xffff0000 ++ && H_GET_16 (abfd, buffer + 4) == 0) + return pe_ILF_object_p (abfd); + + if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0 +diff --git a/bfd/targets.c b/bfd/targets.c +index f502eec..058ab77 100644 +--- a/bfd/targets.c ++++ b/bfd/targets.c +@@ -896,6 +896,7 @@ extern const bfd_target w65_vec; + extern const bfd_target we32kcoff_vec; + extern const bfd_target x86_64pe_vec; + extern const bfd_target x86_64pei_vec; ++extern const bfd_target x86_64pe_bigobj_vec; + extern const bfd_target x86_64coff_vec; + extern const bfd_target z80coff_vec; + extern const bfd_target z8kcoff_vec; +@@ -1231,6 +1232,7 @@ static const bfd_target * const _bfd_target_vector[] = + &x86_64coff_vec, + &x86_64pe_vec, + &x86_64pei_vec, ++ &x86_64pe_bigobj_vec, + #endif + &i860coff_vec, + &icoff_big_vec, +diff --git a/include/coff/internal.h b/include/coff/internal.h +index 4f99f2f..b34e5c6 100644 +--- a/include/coff/internal.h ++++ b/include/coff/internal.h +@@ -73,7 +73,7 @@ struct internal_filehdr + + /* Standard coff internal info. */ + unsigned short f_magic; /* magic number */ +- unsigned short f_nscns; /* number of sections */ ++ unsigned int f_nscns; /* number of sections */ + long f_timdat; /* time & date stamp */ + bfd_vma f_symptr; /* file pointer to symtab */ + long f_nsyms; /* number of symtab entries */ +diff --git a/include/coff/pe.h b/include/coff/pe.h +index 0093398..3166531 100644 +--- a/include/coff/pe.h ++++ b/include/coff/pe.h +@@ -358,6 +358,85 @@ typedef struct + #define IMAGE_WEAK_EXTERN_SEARCH_LIBRARY 2 + #define IMAGE_WEAK_EXTERN_SEARCH_ALIAS 3 + ++/* Bigobj header. */ ++struct external_ANON_OBJECT_HEADER_BIGOBJ ++{ ++ /* ANON_OBJECT_HEADER_V2 header. */ ++ char Sig1[2]; ++ char Sig2[2]; ++ char Version[2]; ++ char Machine[2]; ++ char TimeDateStamp[4]; ++ char ClassID[16]; ++ char SizeOfData[4]; ++ char Flags[4]; ++ char MetaDataSize[4]; ++ char MetaDataOffset[4]; ++ ++ /* BIGOBJ specific. */ ++ char NumberOfSections[4]; ++ char PointerToSymbolTable[4]; ++ char NumberOfSymbols[4]; ++}; ++ ++#define FILHSZ_BIGOBJ (14 * 4) ++ ++struct external_SYMBOL_EX ++{ ++ union ++ { ++ char e_name[E_SYMNMLEN]; ++ ++ struct ++ { ++ char e_zeroes[4]; ++ char e_offset[4]; ++ } e; ++ } e; ++ ++ char e_value[4]; ++ char e_scnum[4]; ++ char e_type[2]; ++ char e_sclass[1]; ++ char e_numaux[1]; ++} ATTRIBUTE_PACKED ; ++ ++#define SYMENT_BIGOBJ struct external_SYMBOL_EX ++#define SYMESZ_BIGOBJ 20 ++ ++#define FILNMLEN_BIGOBJ 20 ++ ++union external_AUX_SYMBOL_EX ++{ ++ struct ++ { ++ char WeakDefaultSymIndex[4]; ++ char WeakSearchType[4]; ++ char rgbReserved[12]; ++ } Sym; ++ ++ struct ++ { ++ char Name[FILNMLEN_BIGOBJ]; ++ } File; ++ ++ struct ++ { ++ char Length[4]; /* section length */ ++ char NumberOfRelocations[2]; /* # relocation entries */ ++ char NumberOfLinenumbers[2]; /* # line numbers */ ++ char Checksum[4]; /* section COMDAT checksum */ ++ char Number[2]; /* COMDAT associated section index */ ++ char Selection[1]; /* COMDAT selection number */ ++ char bReserved[1]; ++ char HighNumber[2]; /* High bits of COMDAT associated sec. */ ++ char rgbReserved[2]; ++ } Section; ++} ATTRIBUTE_PACKED; ++ ++#define AUXENT_BIGOBJ union external_AUX_SYMBOL_EX ++#define AUXESZ_BIGOBJ 20 ++ + /* .pdata/.xdata defines and structures for x64 PE+ for exception handling. */ + + /* .pdata in exception directory. */ +-- +1.8.5.5 + diff --git a/mingw-w64-gdb/PKGBUILD b/mingw-w64-gdb/PKGBUILD index 223b09985a..49173eb970 100644 --- a/mingw-w64-gdb/PKGBUILD +++ b/mingw-w64-gdb/PKGBUILD @@ -5,7 +5,7 @@ _mingw_suff=mingw-w64-${CARCH} _gcc_ver=4.8.2 pkgname=("${_mingw_suff}-${_realname}") pkgver=7.7 -pkgrel=2 +pkgrel=3 pkgdesc="GNU Debugger (mingw-w64)" arch=('any') url="http://www.gnu.org/software/gdb/" @@ -25,14 +25,16 @@ source=("ftp://mirrors.kernel.org/sources.redhat.com/gdb/releases/gdb-${pkgver}. 'gdb-mingw-gcc-4.7.patch' 'gdb-perfomance.patch' 'gdb-fix-python-stack-corruption.patch' - 'gdb-fix-using-gnu-print.patch') + 'gdb-fix-using-gnu-print.patch' + '020-add-bigobj-format.patch') md5sums=('271a18f41858a7e98b28ae4eb91287c9' 'dec2439447cb1accf037457b459093f7' 'e48292d553379a9765c82e80e618ffd2' '7cc5df72d958ef3e4b1ffa9f7b069e6f' 'e9b7c252fedfa950998f5f3b32536461' '3e8c305a3855f01b1ebfd608f2378ffe' - '7f24fa76a81f23f462789a50891d9c88') + 'd7112b220466a294aa266bb4d5c06a59' + '9b596cfe3a448dc5823370173349d88b') prepare() { cd ${srcdir}/gdb-${pkgver} @@ -46,6 +48,7 @@ prepare() { patch -p1 -i ${srcdir}/gdb-fix-python-stack-corruption.patch patch -p1 -i ${srcdir}/gdb-fix-using-gnu-print.patch + patch -p1 -i ${srcdir}/020-add-bigobj-format.patch # hack! - libiberty configure tests for header files using "$CPP $CPPFLAGS" sed -i "/ac_cpp=/s/\$CPPFLAGS/\$CPPFLAGS -O2/" libiberty/configure @@ -71,11 +74,10 @@ build() { --disable-rpath \ --with-system-gdbinit=${MINGW_PREFIX}/etc/gdbinit \ --with-python=${MINGW_PREFIX}/bin/python-config.sh \ - --without-tcl \ - --without-tk \ --with-expat \ --with-libiconv-prefix=${MINGW_PREFIX} \ --with-zlib \ + --with-lzma \ --disable-tui make @@ -86,7 +88,7 @@ package() { make DESTDIR=${pkgdir} install # Remove unwanted files - #rm -rf ${pkgdir}${MINGW_PREFIX}/share/{man,info} + rm -rf ${pkgdir}${MINGW_PREFIX}/share/{man,info} # install "custom" system gdbinit install -D -m644 ${srcdir}/gdbinit ${pkgdir}${MINGW_PREFIX}/etc/gdbinit @@ -94,4 +96,5 @@ package() { rm -f ${pkgdir}${MINGW_PREFIX}/include/*.h rm -f ${pkgdir}${MINGW_PREFIX}/lib/*.a + } diff --git a/mingw-w64-gdb/gdb-fix-using-gnu-print.patch b/mingw-w64-gdb/gdb-fix-using-gnu-print.patch index 17c153bf97..29c0e0299f 100644 --- a/mingw-w64-gdb/gdb-fix-using-gnu-print.patch +++ b/mingw-w64-gdb/gdb-fix-using-gnu-print.patch @@ -1,5 +1,30 @@ ---- gdb-7.7/gdb/common/format.h.orig 2014-03-11 08:18:16.200800000 +0400 -+++ gdb-7.7/gdb/common/format.h 2014-03-11 08:18:59.334800000 +0400 +diff -Naur gdb-7.7-orig/bfd/bfd-in.h gdb-7.7/bfd/bfd-in.h +--- gdb-7.7-orig/bfd/bfd-in.h 2014-02-06 06:21:29.000000000 +0400 ++++ gdb-7.7/bfd/bfd-in.h 2014-03-14 10:39:32.085200000 +0400 +@@ -137,7 +137,7 @@ + + #if BFD_HOST_64BIT_LONG + #define BFD_VMA_FMT "l" +-#elif defined (__MSVCRT__) ++#elif defined(__MSVCRT__) && !defined( __USE_MINGW_ANSI_STDIO) + #define BFD_VMA_FMT "I64" + #else + #define BFD_VMA_FMT "ll" +diff -Naur gdb-7.7-orig/bfd/bfd-in2.h gdb-7.7/bfd/bfd-in2.h +--- gdb-7.7-orig/bfd/bfd-in2.h 2014-02-06 06:21:29.000000000 +0400 ++++ gdb-7.7/bfd/bfd-in2.h 2014-03-14 10:39:32.085200000 +0400 +@@ -144,7 +144,7 @@ + + #if BFD_HOST_64BIT_LONG + #define BFD_VMA_FMT "l" +-#elif defined (__MSVCRT__) ++#elif defined (__MSVCRT__) && !defined(__USE_MINGW_ANSI_STDIO) + #define BFD_VMA_FMT "I64" + #else + #define BFD_VMA_FMT "ll" +diff -Naur gdb-7.7-orig/gdb/common/format.h gdb-7.7/gdb/common/format.h +--- gdb-7.7-orig/gdb/common/format.h 2014-01-08 13:23:36.000000000 +0400 ++++ gdb-7.7/gdb/common/format.h 2014-03-14 10:39:32.412800000 +0400 @@ -18,7 +18,11 @@ along with this program. If not, see . */ @@ -13,3 +38,42 @@ # define PRINTF_HAS_LONG_LONG #else # define USE_PRINTF_I64 0 +diff -Naur gdb-7.7-orig/gdb/gnulib/import/inttypes.in.h gdb-7.7/gdb/gnulib/import/inttypes.in.h +--- gdb-7.7-orig/gdb/gnulib/import/inttypes.in.h 2013-12-08 08:11:51.000000000 +0400 ++++ gdb-7.7/gdb/gnulib/import/inttypes.in.h 2014-03-14 10:43:47.309400000 +0400 +@@ -183,7 +183,7 @@ + #ifdef INT64_MAX + # if (@APPLE_UNIVERSAL_BUILD@ ? defined _LP64 : @INT64_MAX_EQ_LONG_MAX@) + # define _PRI64_PREFIX "l" +-# elif defined _MSC_VER || defined __MINGW32__ ++# elif (defined _MSC_VER || defined __MINGW32__) && !defined(__USE_MINGW_ANSI_STDIO) + # define _PRI64_PREFIX "I64" + # elif @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1 + # define _PRI64_PREFIX _LONG_LONG_FORMAT_PREFIX +@@ -200,7 +200,7 @@ + #ifdef UINT64_MAX + # if (@APPLE_UNIVERSAL_BUILD@ ? defined _LP64 : @UINT64_MAX_EQ_ULONG_MAX@) + # define _PRIu64_PREFIX "l" +-# elif defined _MSC_VER || defined __MINGW32__ ++# elif (defined _MSC_VER || defined __MINGW32__) && !defined(__USE_MINGW_ANSI_STDIO) + # define _PRIu64_PREFIX "I64" + # elif @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1 + # define _PRIu64_PREFIX _LONG_LONG_FORMAT_PREFIX +@@ -676,7 +676,7 @@ + #ifdef INT64_MAX + # if (@APPLE_UNIVERSAL_BUILD@ ? defined _LP64 : @INT64_MAX_EQ_LONG_MAX@) + # define _SCN64_PREFIX "l" +-# elif defined _MSC_VER || defined __MINGW32__ ++# elif (defined _MSC_VER || defined __MINGW32__) && !defined(__USE_MINGW_ANSI_STDIO) + # define _SCN64_PREFIX "I64" + # elif @HAVE_LONG_LONG_INT@ && LONG_MAX >> 30 == 1 + # define _SCN64_PREFIX _LONG_LONG_FORMAT_PREFIX +@@ -693,7 +693,7 @@ + #ifdef UINT64_MAX + # if (@APPLE_UNIVERSAL_BUILD@ ? defined _LP64 : @UINT64_MAX_EQ_ULONG_MAX@) + # define _SCNu64_PREFIX "l" +-# elif defined _MSC_VER || defined __MINGW32__ ++# elif (defined _MSC_VER || defined __MINGW32__) && !defined(__USE_MINGW_ANSI_STDIO) + # define _SCNu64_PREFIX "I64" + # elif @HAVE_UNSIGNED_LONG_LONG_INT@ && ULONG_MAX >> 31 == 1 + # define _SCNu64_PREFIX _LONG_LONG_FORMAT_PREFIX