diff --git a/Sw64-Add-support-EFI-2.patch b/Sw64-Add-support-EFI-2.patch new file mode 100644 index 0000000000000000000000000000000000000000..c01bf53f4c7de7d170b76ce8cae63bf90945d057 --- /dev/null +++ b/Sw64-Add-support-EFI-2.patch @@ -0,0 +1,462 @@ +From f87b218ee2ae294f03be93cf51ee8f1eae719277 Mon Sep 17 00:00:00 2001 +From: zhangchunjing +Date: Mon, 8 Sep 2025 17:58:52 +0800 +Subject: [PATCH] Sw64 Add support EFI 2 + +--- + bfd/Makefile.am | 12 ++++++++++-- + bfd/Makefile.in | 15 ++++++++++++--- + bfd/bfd.c | 1 + + bfd/coffcode.h | 13 +++++++++++++ + bfd/libpei.h | 37 ++++++++++++++++++++++++++++++++++++- + bfd/peXXigen.c | 39 +++++++++++++++++++++------------------ + bfd/peicode.h | 24 +++++++++++++++++++----- + 7 files changed, 112 insertions(+), 29 deletions(-) + +diff --git a/bfd/Makefile.am b/bfd/Makefile.am +index 31e376f9..2702c2d0 100644 +--- a/bfd/Makefile.am ++++ b/bfd/Makefile.am +@@ -578,7 +578,9 @@ BFD64_BACKENDS = \ + pei-x86_64.lo \ + pepigen.lo \ + pex64igen.lo \ +- vms-alpha.lo ++ vms-alpha.lo \ ++ pe-sw_64igen.lo \ ++ pei-sw_64.lo + + BFD64_BACKENDS_CFILES = \ + aix5ppc-core.c \ +@@ -618,7 +620,8 @@ BFD64_BACKENDS_CFILES = \ + pei-aarch64.c \ + pei-ia64.c \ + pei-x86_64.c \ +- vms-alpha.c ++ vms-alpha.c \ ++ pei-sw_64.c + + OPTIONAL_BACKENDS = \ + aix386-core.lo \ +@@ -675,6 +678,7 @@ BUILD_CFILES = \ + elf32-aarch64.c elf64-aarch64.c \ + elf32-ia64.c elf64-ia64.c \ + elf32-riscv.c elf64-riscv.c \ ++ peigen.c pepigen.c pex64igen.c pe-aarch64igen.c pe-sw_64igen.c + peigen.c pepigen.c pex64igen.c pe-aarch64igen.c + + CFILES = $(SOURCE_CFILES) $(BUILD_CFILES) +@@ -884,6 +888,10 @@ pe-aarch64igen.c: peXXigen.c + echo "#line 1 \"peXXigen.c\"" > $@ + $(SED) -e s/XX/peAArch64/g < $< >> $@ + ++pe-sw_64igen.c: peXXigen.c ++ $(AM_V_at)echo "#line 1 \"peXXigen.c\"" > $@ ++ $(AM_V_GEN)$(SED) -e s/XX/peSW_64/g < $< >> $@ ++ + host-aout.lo: Makefile + + # The following program can be used to generate a simple config file +diff --git a/bfd/Makefile.in b/bfd/Makefile.in +index 91b522b8..50dc5a82 100644 +--- a/bfd/Makefile.in ++++ b/bfd/Makefile.in +@@ -1005,7 +1005,9 @@ BFD64_BACKENDS = \ + pei-x86_64.lo \ + pepigen.lo \ + pex64igen.lo \ +- vms-alpha.lo ++ vms-alpha.lo \ ++ pe-sw_64igen.lo \ ++ pei-sw_64.lo + + BFD64_BACKENDS_CFILES = \ + aix5ppc-core.c \ +@@ -1045,7 +1047,8 @@ BFD64_BACKENDS_CFILES = \ + pei-aarch64.c \ + pei-ia64.c \ + pei-x86_64.c \ +- vms-alpha.c ++ vms-alpha.c \ ++ pei-sw_64.c + + OPTIONAL_BACKENDS = \ + aix386-core.lo \ +@@ -1101,7 +1104,7 @@ BUILD_CFILES = \ + elf32-aarch64.c elf64-aarch64.c \ + elf32-ia64.c elf64-ia64.c \ + elf32-riscv.c elf64-riscv.c \ +- peigen.c pepigen.c pex64igen.c pe-aarch64igen.c ++ peigen.c pepigen.c pex64igen.c pe-aarch64igen.c pe-sw_64igen.c + + CFILES = $(SOURCE_CFILES) $(BUILD_CFILES) + SOURCE_HFILES = \ +@@ -1564,6 +1567,8 @@ distclean-compile: + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pei-ia64.Plo@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pei-mcore.Plo@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pei-sh.Plo@am__quote@ ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pei-sw_64.Plo@am__quote@ ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pe-sw_64igen.Plo@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pei-x86_64.Plo@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/peigen.Plo@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pepigen.Plo@am__quote@ +@@ -2016,6 +2021,10 @@ pe-aarch64igen.c: peXXigen.c + echo "#line 1 \"peXXigen.c\"" > $@ + $(SED) -e s/XX/peAArch64/g < $< >> $@ + ++pe-sw_64igen.c: peXXigen.c ++ $(AM_V_at)echo "#line 1 \"peXXigen.c\"" > $@ ++ $(AM_V_GEN)$(SED) -e s/XX/peSW_64/g < $< >> $@ ++ + host-aout.lo: Makefile + + # The following program can be used to generate a simple config file +diff --git a/bfd/bfd.c b/bfd/bfd.c +index 1d6af967..95eff741 100644 +--- a/bfd/bfd.c ++++ b/bfd/bfd.c +@@ -1738,6 +1738,7 @@ bfd_get_sign_extend_vma (bfd *abfd) + || strcmp (name, "pei-aarch64-little") == 0 + || strcmp (name, "pe-arm-wince-little") == 0 + || strcmp (name, "pei-arm-wince-little") == 0 ++ || strcmp (name, "pei-sw_64") == 0 + || strcmp (name, "aixcoff-rs6000") == 0 + || strcmp (name, "aix5coff64-rs6000") == 0) + return 1; +diff --git a/bfd/coffcode.h b/bfd/coffcode.h +index 70e28c35..9da7cda6 100644 +--- a/bfd/coffcode.h ++++ b/bfd/coffcode.h +@@ -2221,6 +2221,12 @@ coff_set_arch_mach_hook (bfd *abfd, void * filehdr) + machine = internal_f->f_flags & F_AARCH64_ARCHITECTURE_MASK; + break; + #endif ++#ifdef SW_64MAGIC ++ case SW_64MAGIC: ++ arch = bfd_arch_sw_64; ++ machine = internal_f->f_flags & F_SW_64_ARCHITECTURE_MASK; ++ break; ++#endif + #ifdef Z80MAGIC + case Z80MAGIC: + arch = bfd_arch_z80; +@@ -3878,6 +3884,7 @@ coff_write_object_contents (bfd * abfd) + #endif + + #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) ++#ifndef COFF_WITH_peSW_64 + #ifdef COFF_WITH_PE + internal_f.f_flags |= IMAGE_FILE_32BIT_MACHINE; + #else +@@ -3887,6 +3894,7 @@ coff_write_object_contents (bfd * abfd) + internal_f.f_flags |= F_AR32W; + #endif + #endif ++#endif + + #ifdef TI_TARGET_ID + /* Target id is used in TI COFF v1 and later; COFF0 won't use this field, +@@ -3931,6 +3939,11 @@ coff_write_object_contents (bfd * abfd) + internal_a.magic = ZMAGIC; + #endif + ++#if defined(SW_64) ++#define __A_MAGIC_SET__ ++ internal_a.magic = ZMAGIC; ++#endif ++ + #if defined MCORE_PE + #define __A_MAGIC_SET__ + internal_a.magic = IMAGE_NT_OPTIONAL_HDR_MAGIC; +diff --git a/bfd/libpei.h b/bfd/libpei.h +index 26589e8e..a5a2f233 100644 +--- a/bfd/libpei.h ++++ b/bfd/libpei.h +@@ -240,6 +240,41 @@ + #define _bfd_XXi_write_codeview_record _bfd_pex64i_write_codeview_record + #define _bfd_XXi_slurp_codeview_record _bfd_pex64i_slurp_codeview_record + ++#elif defined COFF_WITH_peSW_64 ++ ++#define GET_OPTHDR_IMAGE_BASE H_GET_64 ++#define PUT_OPTHDR_IMAGE_BASE H_PUT_64 ++#define GET_OPTHDR_SIZE_OF_STACK_RESERVE H_GET_64 ++#define PUT_OPTHDR_SIZE_OF_STACK_RESERVE H_PUT_64 ++#define GET_OPTHDR_SIZE_OF_STACK_COMMIT H_GET_64 ++#define PUT_OPTHDR_SIZE_OF_STACK_COMMIT H_PUT_64 ++#define GET_OPTHDR_SIZE_OF_HEAP_RESERVE H_GET_64 ++#define PUT_OPTHDR_SIZE_OF_HEAP_RESERVE H_PUT_64 ++#define GET_OPTHDR_SIZE_OF_HEAP_COMMIT H_GET_64 ++#define PUT_OPTHDR_SIZE_OF_HEAP_COMMIT H_PUT_64 ++#define GET_PDATA_ENTRY bfd_get_32 ++ ++#define _bfd_XX_bfd_copy_private_bfd_data_common _bfd_peSW_64_bfd_copy_private_bfd_data_common ++#define _bfd_XX_bfd_copy_private_section_data _bfd_peSW_64_bfd_copy_private_section_data ++#define _bfd_XX_get_symbol_info _bfd_peSW_64_get_symbol_info ++#define _bfd_XX_only_swap_filehdr_out _bfd_peSW_64_only_swap_filehdr_out ++#define _bfd_XX_print_private_bfd_data_common _bfd_peSW_64_print_private_bfd_data_common ++#define _bfd_XXi_final_link_postscript _bfd_peSW_64i_final_link_postscript ++#define _bfd_XXi_only_swap_filehdr_out _bfd_peSW_64i_only_swap_filehdr_out ++#define _bfd_XXi_swap_aouthdr_in _bfd_peSW_64i_swap_aouthdr_in ++#define _bfd_XXi_swap_aouthdr_out _bfd_peSW_64i_swap_aouthdr_out ++#define _bfd_XXi_swap_aux_in _bfd_peSW_64i_swap_aux_in ++#define _bfd_XXi_swap_aux_out _bfd_peSW_64i_swap_aux_out ++#define _bfd_XXi_swap_lineno_in _bfd_peSW_64i_swap_lineno_in ++#define _bfd_XXi_swap_lineno_out _bfd_peSW_64i_swap_lineno_out ++#define _bfd_XXi_swap_scnhdr_out _bfd_peSW_64i_swap_scnhdr_out ++#define _bfd_XXi_swap_sym_in _bfd_peSW_64i_swap_sym_in ++#define _bfd_XXi_swap_sym_out _bfd_peSW_64i_swap_sym_out ++#define _bfd_XXi_swap_debugdir_in _bfd_peSW_64i_swap_debugdir_in ++#define _bfd_XXi_swap_debugdir_out _bfd_peSW_64i_swap_debugdir_out ++#define _bfd_XXi_write_codeview_record _bfd_peSW_64i_write_codeview_record ++#define _bfd_XXi_slurp_codeview_record _bfd_peSW_64i_slurp_codeview_record ++ + #elif defined COFF_WITH_pep + + #define GET_OPTHDR_IMAGE_BASE H_GET_64 +@@ -406,4 +441,4 @@ bool _bfd_pe64_print_ce_compressed_pdata (bfd *, void *); + bool _bfd_pex64_print_ce_compressed_pdata (bfd *, void *); + bool _bfd_peAArch64_print_ce_compressed_pdata (bfd *, void *); + bool _bfd_pep_print_ce_compressed_pdata (bfd *, void *); +- ++bool _bfd_peSW_64_print_ce_compressed_pdata (bfd *, void *); +diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c +index 1bfd6c89..7568ce27 100644 +--- a/bfd/peXXigen.c ++++ b/bfd/peXXigen.c +@@ -86,6 +86,9 @@ + # include "coff/ia64.h" + #elif defined COFF_WITH_peAArch64 + # include "coff/aarch64.h" ++#elif defined COFF_WITH_peSW_64 ++# include "coff/sw_64.h" ++# include "coff/external.h" + #else + # include "coff/i386.h" + #endif +@@ -95,7 +98,7 @@ + #include "libpei.h" + #include "safe-ctype.h" + +-#if defined COFF_WITH_pep || defined COFF_WITH_pex64 || defined COFF_WITH_peAArch64 ++#if defined COFF_WITH_pep || defined COFF_WITH_pex64 || defined COFF_WITH_peAArch64 || defined COFF_WITH_peSW_64 + # undef AOUTSZ + # define AOUTSZ PEPAOUTSZ + # define PEAOUTHDR PEPAOUTHDR +@@ -472,7 +475,7 @@ _bfd_XXi_swap_aouthdr_in (bfd * abfd, + aouthdr_int->text_start = + GET_AOUTHDR_TEXT_START (abfd, aouthdr_ext->text_start); + +-#if !defined(COFF_WITH_pep) && !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) ++#if !defined(COFF_WITH_pep) && !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peSW_64) + /* PE32+ does not have data_start member! */ + aouthdr_int->data_start = + GET_AOUTHDR_DATA_START (abfd, aouthdr_ext->data_start); +@@ -558,7 +561,7 @@ _bfd_XXi_swap_aouthdr_in (bfd * abfd, + if (aouthdr_int->entry) + { + aouthdr_int->entry += a->ImageBase; +-#if !defined(COFF_WITH_pep) && !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) ++#if !defined(COFF_WITH_pep) && !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peSW_64) + aouthdr_int->entry &= 0xffffffff; + #endif + } +@@ -566,12 +569,12 @@ _bfd_XXi_swap_aouthdr_in (bfd * abfd, + if (aouthdr_int->tsize) + { + aouthdr_int->text_start += a->ImageBase; +-#if !defined(COFF_WITH_pep) && !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) ++#if !defined(COFF_WITH_pep) && !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peSW_64) + aouthdr_int->text_start &= 0xffffffff; + #endif + } + +-#if !defined(COFF_WITH_pep) && !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) ++#if !defined(COFF_WITH_pep) && !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peSW_64) + /* PE32+ does not have data_start member! */ + if (aouthdr_int->dsize) + { +@@ -631,7 +634,7 @@ _bfd_XXi_swap_aouthdr_out (bfd * abfd, void * in, void * out) + if (aouthdr_in->tsize) + { + aouthdr_in->text_start -= ib; +-#if !defined(COFF_WITH_pep) && !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) ++#if !defined(COFF_WITH_pep) && !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peSW_64) + aouthdr_in->text_start &= 0xffffffff; + #endif + } +@@ -639,7 +642,7 @@ _bfd_XXi_swap_aouthdr_out (bfd * abfd, void * in, void * out) + if (aouthdr_in->dsize) + { + aouthdr_in->data_start -= ib; +-#if !defined(COFF_WITH_pep) && !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) ++#if !defined(COFF_WITH_pep) && !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peSW_64) + aouthdr_in->data_start &= 0xffffffff; + #endif + } +@@ -647,7 +650,7 @@ _bfd_XXi_swap_aouthdr_out (bfd * abfd, void * in, void * out) + if (aouthdr_in->entry) + { + aouthdr_in->entry -= ib; +-#if !defined(COFF_WITH_pep) && !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) ++#if !defined(COFF_WITH_pep) && !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peSW_64) + aouthdr_in->entry &= 0xffffffff; + #endif + } +@@ -751,7 +754,7 @@ _bfd_XXi_swap_aouthdr_out (bfd * abfd, void * in, void * out) + PUT_AOUTHDR_TEXT_START (abfd, aouthdr_in->text_start, + aouthdr_out->standard.text_start); + +-#if !defined(COFF_WITH_pep) && !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) ++#if !defined(COFF_WITH_pep) && !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peSW_64) + /* PE32+ does not have data_start member! */ + PUT_AOUTHDR_DATA_START (abfd, aouthdr_in->data_start, + aouthdr_out->standard.data_start); +@@ -1803,7 +1806,7 @@ pe_print_edata (bfd * abfd, void * vfile) + static bool + pe_print_pdata (bfd * abfd, void * vfile) + { +-#if defined(COFF_WITH_pep) && !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) ++#if defined(COFF_WITH_pep) && !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peSW_64) + # define PDATA_ROW_SIZE (3 * 8) + #else + # define PDATA_ROW_SIZE (5 * 4) +@@ -1830,7 +1833,7 @@ pe_print_pdata (bfd * abfd, void * vfile) + + fprintf (file, + _("\nThe Function Table (interpreted .pdata section contents)\n")); +-#if defined(COFF_WITH_pep) && !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) ++#if defined(COFF_WITH_pep) && !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peSW_64) + fprintf (file, + _(" vma:\t\t\tBegin Address End Address Unwind Info\n")); + #else +@@ -1867,7 +1870,7 @@ pe_print_pdata (bfd * abfd, void * vfile) + bfd_vma eh_handler; + bfd_vma eh_data; + bfd_vma prolog_end_addr; +-#if !defined(COFF_WITH_pep) || defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) ++#if !defined(COFF_WITH_pep) || defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) || defined(COFF_WITH_peSW_64) + int em_data; + #endif + +@@ -1885,7 +1888,7 @@ pe_print_pdata (bfd * abfd, void * vfile) + /* We are probably into the padding of the section now. */ + break; + +-#if !defined(COFF_WITH_pep) || defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) ++#if !defined(COFF_WITH_pep) || defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) || defined(COFF_WITH_peSW_64) + em_data = ((eh_handler & 0x1) << 2) | (prolog_end_addr & 0x3); + #endif + eh_handler &= ~(bfd_vma) 0x3; +@@ -1896,7 +1899,7 @@ pe_print_pdata (bfd * abfd, void * vfile) + bfd_fprintf_vma (abfd, file, begin_addr); fputc (' ', file); + bfd_fprintf_vma (abfd, file, end_addr); fputc (' ', file); + bfd_fprintf_vma (abfd, file, eh_handler); +-#if !defined(COFF_WITH_pep) || defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) ++#if !defined(COFF_WITH_pep) || defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) || defined(COFF_WITH_peSW_64) + fputc (' ', file); + bfd_fprintf_vma (abfd, file, eh_data); fputc (' ', file); + bfd_fprintf_vma (abfd, file, prolog_end_addr); +@@ -2787,7 +2790,7 @@ _bfd_XX_print_private_bfd_data_common (bfd * abfd, void * vfile) + bfd_fprintf_vma (abfd, file, i->AddressOfEntryPoint); + fprintf (file, "\nBaseOfCode\t\t"); + bfd_fprintf_vma (abfd, file, i->BaseOfCode); +-#if !defined(COFF_WITH_pep) && !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) ++#if !defined(COFF_WITH_pep) && !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peSW_64) + /* PE32+ does not have BaseOfData member! */ + fprintf (file, "\nBaseOfData\t\t"); + bfd_fprintf_vma (abfd, file, i->BaseOfData); +@@ -3088,7 +3091,7 @@ _bfd_XX_get_symbol_info (bfd * abfd, asymbol *symbol, symbol_info *ret) + coff_get_symbol_info (abfd, symbol, ret); + } + +-#if !defined(COFF_WITH_pep) && defined(COFF_WITH_pex64) && defined(COFF_WITH_peAArch64) ++#if !defined(COFF_WITH_pep) && defined(COFF_WITH_peAArch64) && (defined(COFF_WITH_pex64) || defined(COFF_WITH_peSW_64)) + static int + sort_x64_pdata (const void *l, const void *r) + { +@@ -4507,7 +4510,7 @@ _bfd_XXi_final_link_postscript (bfd * abfd, struct coff_final_link_info *pfinfo) + the TLS data directory consists of 4 pointers, followed + by two 4-byte integer. This implies that the total size + is different for 32-bit and 64-bit executables. */ +-#if !defined(COFF_WITH_pep) && !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) ++#if !defined(COFF_WITH_pep) && !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) && !defined(COFF_WITH_peSW_64) + pe_data (abfd)->pe_opthdr.DataDirectory[PE_TLS_TABLE].Size = 0x18; + #else + pe_data (abfd)->pe_opthdr.DataDirectory[PE_TLS_TABLE].Size = 0x28; +@@ -4516,7 +4519,7 @@ _bfd_XXi_final_link_postscript (bfd * abfd, struct coff_final_link_info *pfinfo) + + /* 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) ++#if !defined(COFF_WITH_pep) && defined(COFF_WITH_peAArch64) && (defined(COFF_WITH_pex64) || defined(COFF_WITH_peSW_64)) + { + asection *sec = bfd_get_section_by_name (abfd, ".pdata"); + +diff --git a/bfd/peicode.h b/bfd/peicode.h +index 4e7a7486..d0e2294a 100644 +--- a/bfd/peicode.h ++++ b/bfd/peicode.h +@@ -232,7 +232,9 @@ coff_swap_scnhdr_in (bfd * abfd, void * ext, void * in) + scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; + /* Do not cut upper 32-bits for 64-bit vma. */ + #if !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peAArch64) ++#ifndef COFF_WITH_peSW_64 + scnhdr_int->s_vaddr &= 0xffffffff; ++#endif + #endif + } + +@@ -762,6 +764,14 @@ static const jump_table jtab[] = + 0x40, 0xbc, 0x60, 0x47, 0x00, 0x00, 0x00, 0x00 }, + 16, 12 + }, ++#endif ++#ifdef SW_64MAGIC ++/* We don't currently support jumping to DLLs, so if ++ someone does try emit a runtime trap. Through BREAK 0. */ ++ { SW_64MAGIC, ++ { 0x00, 0x00, 0x2a, 0x00 }, ++ 4, 0 ++ }, + #endif + { 0, { 0 }, 0, 0 } + }; +@@ -920,7 +930,7 @@ pe_ILF_build_a_bfd (bfd * abfd, + /* See PR 20907 for a reproducer. */ + goto error_return; + +-#if defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) ++#if defined(COFF_WITH_pex64) || defined(COFF_WITH_peAArch64) || defined(COFF_WITH_peSW_64) + ((unsigned int *) id4->contents)[0] = ordinal; + ((unsigned int *) id4->contents)[1] = 0x80000000; + ((unsigned int *) id5->contents)[0] = ordinal; +@@ -1176,10 +1186,6 @@ pe_ILF_object_p (bfd * abfd) + case IMAGE_FILE_MACHINE_UNKNOWN: + case IMAGE_FILE_MACHINE_ALPHA: + case IMAGE_FILE_MACHINE_ALPHA64: +-#ifdef TARGET_SW_64 +- case IMAGE_FILE_MACHINE_SW_64: +- case IMAGE_FILE_MACHINE_SW_6464: +-#endif + case IMAGE_FILE_MACHINE_IA64: + break; + +@@ -1226,6 +1232,14 @@ pe_ILF_object_p (bfd * abfd) + #endif + break; + ++#ifdef TARGET_SW_64 ++ case IMAGE_FILE_MACHINE_SW_64: ++#ifdef SW_64MAGIC ++ magic = SW_64MAGIC; ++#endif ++ break; ++#endif ++ + case IMAGE_FILE_MACHINE_THUMB: + #ifdef THUMBPEMAGIC + { +-- +2.33.0 + diff --git a/Sw64-Add-support-EFI.patch b/Sw64-Add-support-EFI.patch index 8185fe7303ae16c89467edd475d2bfadb3c9564f..0a9783e634082ccfe5998581e789f374976a87ae 100644 --- a/Sw64-Add-support-EFI.patch +++ b/Sw64-Add-support-EFI.patch @@ -1,114 +1,3 @@ -diff --git a/bfd/Makefile.am b/bfd/Makefile.am -index fab4df94..08317eef 100644 ---- a/bfd/Makefile.am -+++ b/bfd/Makefile.am -@@ -576,7 +576,9 @@ BFD64_BACKENDS = \ - pei-x86_64.lo \ - pepigen.lo \ - pex64igen.lo \ -- vms-alpha.lo -+ vms-alpha.lo \ -+ pe-sw_64igen.lo \ -+ pei-sw_64.lo - - BFD64_BACKENDS_CFILES = \ - aix5ppc-core.c \ -@@ -615,7 +617,8 @@ BFD64_BACKENDS_CFILES = \ - pe-x86_64.c \ - pei-ia64.c \ - pei-x86_64.c \ -- vms-alpha.c -+ vms-alpha.c \ -+ pei-sw_64.c - - OPTIONAL_BACKENDS = \ - aix386-core.lo \ -@@ -672,7 +675,7 @@ BUILD_CFILES = \ - elf32-aarch64.c elf64-aarch64.c \ - elf32-ia64.c elf64-ia64.c \ - elf32-riscv.c elf64-riscv.c \ -- peigen.c pepigen.c pex64igen.c -+ peigen.c pepigen.c pex64igen.c pe-sw_64igen.c - - CFILES = $(SOURCE_CFILES) $(BUILD_CFILES) - -@@ -868,6 +871,10 @@ pex64igen.c: peXXigen.c - echo "#line 1 \"peXXigen.c\"" > $@ - $(SED) -e s/XX/pex64/g < $< >> $@ - -+pe-sw_64igen.c: peXXigen.c -+ echo "#line 1 \"peXXigen.c\"" > $@ -+ $(SED) -e s/XX/peSW_64/g < $< >> $@ -+ - BFD_H_DEPS= $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h $(INCDIR)/diagnostics.h - LOCAL_H_DEPS= libbfd.h sysdep.h config.h - $(BFD32_LIBS) \ -diff --git a/bfd/Makefile.in b/bfd/Makefile.in -index 011c2130..782ca773 100644 ---- a/bfd/Makefile.in -+++ b/bfd/Makefile.in -@@ -1003,7 +1003,9 @@ BFD64_BACKENDS = \ - pei-x86_64.lo \ - pepigen.lo \ - pex64igen.lo \ -- vms-alpha.lo -+ vms-alpha.lo \ -+ pe-sw_64igen.lo \ -+ pei-sw_64.lo - - BFD64_BACKENDS_CFILES = \ - aix5ppc-core.c \ -@@ -1042,7 +1044,8 @@ BFD64_BACKENDS_CFILES = \ - pe-x86_64.c \ - pei-ia64.c \ - pei-x86_64.c \ -- vms-alpha.c -+ vms-alpha.c \ -+ pei-sw_64.c - - OPTIONAL_BACKENDS = \ - aix386-core.lo \ -@@ -1098,7 +1101,7 @@ BUILD_CFILES = \ - elf32-aarch64.c elf64-aarch64.c \ - elf32-ia64.c elf64-ia64.c \ - elf32-riscv.c elf64-riscv.c \ -- peigen.c pepigen.c pex64igen.c -+ peigen.c pepigen.c pex64igen.c pe-sw_64igen.c - - CFILES = $(SOURCE_CFILES) $(BUILD_CFILES) - SOURCE_HFILES = \ -@@ -1559,6 +1562,8 @@ distclean-compile: - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pei-ia64.Plo@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pei-mcore.Plo@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pei-sh.Plo@am__quote@ -+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pei-sw_64.Plo@am__quote@ -+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pe-sw_64igen.Plo@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pei-x86_64.Plo@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/peigen.Plo@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pepigen.Plo@am__quote@ -@@ -2000,6 +2005,10 @@ pepigen.c : peXXigen.c - pex64igen.c: peXXigen.c - echo "#line 1 \"peXXigen.c\"" > $@ - $(SED) -e s/XX/pex64/g < $< >> $@ -+ -+pe-sw_64igen.c: peXXigen.c -+ echo "#line 1 \"peXXigen.c\"" > $@ -+ $(SED) -e s/XX/peSW_64/g < $< >> $@ - $(BFD32_LIBS) \ - $(BFD64_LIBS) \ - $(ALL_MACHINES) \ -diff --git a/bfd/bfd.c b/bfd/bfd.c -index 0952aaea..f8109953 100644 ---- a/bfd/bfd.c -+++ b/bfd/bfd.c -@@ -1737,6 +1737,7 @@ bfd_get_sign_extend_vma (bfd *abfd) - || strcmp (name, "pei-x86-64") == 0 - || strcmp (name, "pe-arm-wince-little") == 0 - || strcmp (name, "pei-arm-wince-little") == 0 -+ || strcmp (name, "pei-sw_64") == 0 - || strcmp (name, "aixcoff-rs6000") == 0 - || strcmp (name, "aix5coff64-rs6000") == 0) - return 1; diff --git a/bfd/coff-sw_64.c b/bfd/coff-sw_64.c index b3390531..e1e5c20c 100644 --- a/bfd/coff-sw_64.c @@ -2752,51 +2641,6 @@ index b3390531..e1e5c20c 100644 +}; - &sw_64_ecoff_backend_data}; -diff --git a/bfd/coffcode.h b/bfd/coffcode.h -index f65f3352..5bc6b310 100644 ---- a/bfd/coffcode.h -+++ b/bfd/coffcode.h -@@ -2215,6 +2215,12 @@ coff_set_arch_mach_hook (bfd *abfd, void * filehdr) - } - break; - #endif -+#ifdef SW_64MAGIC -+ case SW_64MAGIC: -+ arch = bfd_arch_sw_64; -+ machine = internal_f->f_flags & F_SW_64_ARCHITECTURE_MASK; -+ break; -+#endif - #ifdef Z80MAGIC - case Z80MAGIC: - arch = bfd_arch_z80; -@@ -3867,6 +3873,7 @@ coff_write_object_contents (bfd * abfd) - #endif - - #ifndef COFF_WITH_pex64 -+#ifndef COFF_WITH_peSW_64 - #ifdef COFF_WITH_PE - internal_f.f_flags |= IMAGE_FILE_32BIT_MACHINE; - #else -@@ -3876,6 +3883,7 @@ coff_write_object_contents (bfd * abfd) - internal_f.f_flags |= F_AR32W; - #endif - #endif -+#endif - - #ifdef TI_TARGET_ID - /* Target id is used in TI COFF v1 and later; COFF0 won't use this field, -@@ -3915,6 +3923,11 @@ coff_write_object_contents (bfd * abfd) - internal_a.magic = ZMAGIC; - #endif - -+#if defined(SW_64) -+#define __A_MAGIC_SET__ -+ internal_a.magic = ZMAGIC; -+#endif -+ - #if defined MCORE_PE - #define __A_MAGIC_SET__ - internal_a.magic = IMAGE_NT_OPTIONAL_HDR_MAGIC; diff --git a/bfd/config.bfd b/bfd/config.bfd index 8251a157..a4d0323b 100644 --- a/bfd/config.bfd @@ -2880,231 +2724,6 @@ index 631f7aa8..7fd173d1 100644 mach_o_be_vec) tb="$tb mach-o.lo dwarf2.lo" ;; mach_o_le_vec) tb="$tb mach-o.lo dwarf2.lo" ;; mach_o_fat_vec) tb="$tb mach-o.lo dwarf2.lo" ;; -diff --git a/bfd/libpei.h b/bfd/libpei.h -index 4de0c9fd..f8f38e45 100644 ---- a/bfd/libpei.h -+++ b/bfd/libpei.h -@@ -240,6 +240,41 @@ - #define _bfd_XXi_write_codeview_record _bfd_pex64i_write_codeview_record - #define _bfd_XXi_slurp_codeview_record _bfd_pex64i_slurp_codeview_record - -+#elif defined COFF_WITH_peSW_64 -+ -+#define GET_OPTHDR_IMAGE_BASE H_GET_64 -+#define PUT_OPTHDR_IMAGE_BASE H_PUT_64 -+#define GET_OPTHDR_SIZE_OF_STACK_RESERVE H_GET_64 -+#define PUT_OPTHDR_SIZE_OF_STACK_RESERVE H_PUT_64 -+#define GET_OPTHDR_SIZE_OF_STACK_COMMIT H_GET_64 -+#define PUT_OPTHDR_SIZE_OF_STACK_COMMIT H_PUT_64 -+#define GET_OPTHDR_SIZE_OF_HEAP_RESERVE H_GET_64 -+#define PUT_OPTHDR_SIZE_OF_HEAP_RESERVE H_PUT_64 -+#define GET_OPTHDR_SIZE_OF_HEAP_COMMIT H_GET_64 -+#define PUT_OPTHDR_SIZE_OF_HEAP_COMMIT H_PUT_64 -+#define GET_PDATA_ENTRY bfd_get_32 -+ -+#define _bfd_XX_bfd_copy_private_bfd_data_common _bfd_peSW_64_bfd_copy_private_bfd_data_common -+#define _bfd_XX_bfd_copy_private_section_data _bfd_peSW_64_bfd_copy_private_section_data -+#define _bfd_XX_get_symbol_info _bfd_peSW_64_get_symbol_info -+#define _bfd_XX_only_swap_filehdr_out _bfd_peSW_64_only_swap_filehdr_out -+#define _bfd_XX_print_private_bfd_data_common _bfd_peSW_64_print_private_bfd_data_common -+#define _bfd_XXi_final_link_postscript _bfd_peSW_64i_final_link_postscript -+#define _bfd_XXi_only_swap_filehdr_out _bfd_peSW_64i_only_swap_filehdr_out -+#define _bfd_XXi_swap_aouthdr_in _bfd_peSW_64i_swap_aouthdr_in -+#define _bfd_XXi_swap_aouthdr_out _bfd_peSW_64i_swap_aouthdr_out -+#define _bfd_XXi_swap_aux_in _bfd_peSW_64i_swap_aux_in -+#define _bfd_XXi_swap_aux_out _bfd_peSW_64i_swap_aux_out -+#define _bfd_XXi_swap_lineno_in _bfd_peSW_64i_swap_lineno_in -+#define _bfd_XXi_swap_lineno_out _bfd_peSW_64i_swap_lineno_out -+#define _bfd_XXi_swap_scnhdr_out _bfd_peSW_64i_swap_scnhdr_out -+#define _bfd_XXi_swap_sym_in _bfd_peSW_64i_swap_sym_in -+#define _bfd_XXi_swap_sym_out _bfd_peSW_64i_swap_sym_out -+#define _bfd_XXi_swap_debugdir_in _bfd_peSW_64i_swap_debugdir_in -+#define _bfd_XXi_swap_debugdir_out _bfd_peSW_64i_swap_debugdir_out -+#define _bfd_XXi_write_codeview_record _bfd_peSW_64i_write_codeview_record -+#define _bfd_XXi_slurp_codeview_record _bfd_peSW_64i_slurp_codeview_record -+ - #elif defined COFF_WITH_pep - - #define GET_OPTHDR_IMAGE_BASE H_GET_64 -@@ -370,4 +405,5 @@ bool _bfd_pe_print_ce_compressed_pdata (bfd *, void *); - bool _bfd_pe64_print_ce_compressed_pdata (bfd *, void *); - bool _bfd_pex64_print_ce_compressed_pdata (bfd *, void *); - bool _bfd_pep_print_ce_compressed_pdata (bfd *, void *); -+bool _bfd_peSW_64_print_ce_compressed_pdata (bfd *, void *); - -diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c -index c41c3299..08d72edb 100644 ---- a/bfd/peXXigen.c -+++ b/bfd/peXXigen.c -@@ -83,6 +83,9 @@ - # include "coff/x86_64.h" - #elif defined COFF_WITH_pep - # include "coff/ia64.h" -+#elif defined COFF_WITH_peSW_64 -+# include "coff/sw_64.h" -+# include "coff/external.h" - #else - # include "coff/i386.h" - #endif -@@ -92,7 +95,7 @@ - #include "libpei.h" - #include "safe-ctype.h" - --#if defined COFF_WITH_pep || defined COFF_WITH_pex64 -+#if defined COFF_WITH_pep || defined COFF_WITH_pex64 || defined COFF_WITH_peSW_64 - # undef AOUTSZ - # define AOUTSZ PEPAOUTSZ - # define PEAOUTHDR PEPAOUTHDR -@@ -469,7 +472,7 @@ _bfd_XXi_swap_aouthdr_in (bfd * abfd, - aouthdr_int->text_start = - GET_AOUTHDR_TEXT_START (abfd, aouthdr_ext->text_start); - --#if !defined(COFF_WITH_pep) && !defined(COFF_WITH_pex64) -+#if !defined(COFF_WITH_pep) && !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peSW_64) - /* PE32+ does not have data_start member! */ - aouthdr_int->data_start = - GET_AOUTHDR_DATA_START (abfd, aouthdr_ext->data_start); -@@ -555,7 +558,7 @@ _bfd_XXi_swap_aouthdr_in (bfd * abfd, - if (aouthdr_int->entry) - { - aouthdr_int->entry += a->ImageBase; --#if !defined(COFF_WITH_pep) && !defined(COFF_WITH_pex64) -+#if !defined(COFF_WITH_pep) && !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peSW_64) - aouthdr_int->entry &= 0xffffffff; - #endif - } -@@ -563,12 +566,12 @@ _bfd_XXi_swap_aouthdr_in (bfd * abfd, - if (aouthdr_int->tsize) - { - aouthdr_int->text_start += a->ImageBase; --#if !defined(COFF_WITH_pep) && !defined(COFF_WITH_pex64) -+#if !defined(COFF_WITH_pep) && !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peSW_64) - aouthdr_int->text_start &= 0xffffffff; - #endif - } - --#if !defined(COFF_WITH_pep) && !defined(COFF_WITH_pex64) -+#if !defined(COFF_WITH_pep) && !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peSW_64) - /* PE32+ does not have data_start member! */ - if (aouthdr_int->dsize) - { -@@ -628,7 +631,7 @@ _bfd_XXi_swap_aouthdr_out (bfd * abfd, void * in, void * out) - if (aouthdr_in->tsize) - { - aouthdr_in->text_start -= ib; --#if !defined(COFF_WITH_pep) && !defined(COFF_WITH_pex64) -+#if !defined(COFF_WITH_pep) && !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peSW_64) - aouthdr_in->text_start &= 0xffffffff; - #endif - } -@@ -636,7 +639,7 @@ _bfd_XXi_swap_aouthdr_out (bfd * abfd, void * in, void * out) - if (aouthdr_in->dsize) - { - aouthdr_in->data_start -= ib; --#if !defined(COFF_WITH_pep) && !defined(COFF_WITH_pex64) -+#if !defined(COFF_WITH_pep) && !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peSW_64) - aouthdr_in->data_start &= 0xffffffff; - #endif - } -@@ -644,7 +647,7 @@ _bfd_XXi_swap_aouthdr_out (bfd * abfd, void * in, void * out) - if (aouthdr_in->entry) - { - aouthdr_in->entry -= ib; --#if !defined(COFF_WITH_pep) && !defined(COFF_WITH_pex64) -+#if !defined(COFF_WITH_pep) && !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peSW_64) - aouthdr_in->entry &= 0xffffffff; - #endif - } -@@ -748,7 +751,7 @@ _bfd_XXi_swap_aouthdr_out (bfd * abfd, void * in, void * out) - PUT_AOUTHDR_TEXT_START (abfd, aouthdr_in->text_start, - aouthdr_out->standard.text_start); - --#if !defined(COFF_WITH_pep) && !defined(COFF_WITH_pex64) -+#if !defined(COFF_WITH_pep) && !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peSW_64) - /* PE32+ does not have data_start member! */ - PUT_AOUTHDR_DATA_START (abfd, aouthdr_in->data_start, - aouthdr_out->standard.data_start); -@@ -1800,7 +1803,7 @@ pe_print_edata (bfd * abfd, void * vfile) - static bool - pe_print_pdata (bfd * abfd, void * vfile) - { --#if defined(COFF_WITH_pep) && !defined(COFF_WITH_pex64) -+#if defined(COFF_WITH_pep) && !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peSW_64) - # define PDATA_ROW_SIZE (3 * 8) - #else - # define PDATA_ROW_SIZE (5 * 4) -@@ -1827,7 +1830,7 @@ pe_print_pdata (bfd * abfd, void * vfile) - - fprintf (file, - _("\nThe Function Table (interpreted .pdata section contents)\n")); --#if defined(COFF_WITH_pep) && !defined(COFF_WITH_pex64) -+#if defined(COFF_WITH_pep) && !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peSW_64) - fprintf (file, - _(" vma:\t\t\tBegin Address End Address Unwind Info\n")); - #else -@@ -1864,7 +1867,7 @@ pe_print_pdata (bfd * abfd, void * vfile) - bfd_vma eh_handler; - bfd_vma eh_data; - bfd_vma prolog_end_addr; --#if !defined(COFF_WITH_pep) || defined(COFF_WITH_pex64) -+#if !defined(COFF_WITH_pep) || defined(COFF_WITH_pex64) || defined(COFF_WITH_peSW_64) - int em_data; - #endif - -@@ -1882,7 +1885,7 @@ pe_print_pdata (bfd * abfd, void * vfile) - /* We are probably into the padding of the section now. */ - break; - --#if !defined(COFF_WITH_pep) || defined(COFF_WITH_pex64) -+#if !defined(COFF_WITH_pep) || defined(COFF_WITH_pex64) || defined(COFF_WITH_peSW_64) - em_data = ((eh_handler & 0x1) << 2) | (prolog_end_addr & 0x3); - #endif - eh_handler &= ~(bfd_vma) 0x3; -@@ -1893,7 +1896,7 @@ pe_print_pdata (bfd * abfd, void * vfile) - bfd_fprintf_vma (abfd, file, begin_addr); fputc (' ', file); - bfd_fprintf_vma (abfd, file, end_addr); fputc (' ', file); - bfd_fprintf_vma (abfd, file, eh_handler); --#if !defined(COFF_WITH_pep) || defined(COFF_WITH_pex64) -+#if !defined(COFF_WITH_pep) || defined(COFF_WITH_pex64) || defined(COFF_WITH_peSW_64) - fputc (' ', file); - bfd_fprintf_vma (abfd, file, eh_data); fputc (' ', file); - bfd_fprintf_vma (abfd, file, prolog_end_addr); -@@ -2784,7 +2787,7 @@ _bfd_XX_print_private_bfd_data_common (bfd * abfd, void * vfile) - bfd_fprintf_vma (abfd, file, i->AddressOfEntryPoint); - fprintf (file, "\nBaseOfCode\t\t"); - bfd_fprintf_vma (abfd, file, i->BaseOfCode); --#if !defined(COFF_WITH_pep) && !defined(COFF_WITH_pex64) -+#if !defined(COFF_WITH_pep) && !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peSW_64) - /* PE32+ does not have BaseOfData member! */ - fprintf (file, "\nBaseOfData\t\t"); - bfd_fprintf_vma (abfd, file, i->BaseOfData); -@@ -3085,7 +3088,7 @@ _bfd_XX_get_symbol_info (bfd * abfd, asymbol *symbol, symbol_info *ret) - coff_get_symbol_info (abfd, symbol, ret); - } - --#if !defined(COFF_WITH_pep) && defined(COFF_WITH_pex64) -+#if !defined(COFF_WITH_pep) && (defined(COFF_WITH_pex64) || defined(COFF_WITH_peSW_64)) - static int - sort_x64_pdata (const void *l, const void *r) - { -@@ -4504,7 +4507,7 @@ _bfd_XXi_final_link_postscript (bfd * abfd, struct coff_final_link_info *pfinfo) - the TLS data directory consists of 4 pointers, followed - by two 4-byte integer. This implies that the total size - is different for 32-bit and 64-bit executables. */ --#if !defined(COFF_WITH_pep) && !defined(COFF_WITH_pex64) -+#if !defined(COFF_WITH_pep) && !defined(COFF_WITH_pex64) && !defined(COFF_WITH_peSW_64) - pe_data (abfd)->pe_opthdr.DataDirectory[PE_TLS_TABLE].Size = 0x18; - #else - pe_data (abfd)->pe_opthdr.DataDirectory[PE_TLS_TABLE].Size = 0x28; -@@ -4513,7 +4516,7 @@ _bfd_XXi_final_link_postscript (bfd * abfd, struct coff_final_link_info *pfinfo) - - /* 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) -+#if !defined(COFF_WITH_pep) && (defined(COFF_WITH_pex64) || defined(COFF_WITH_peSW_64)) - { - asection *sec = bfd_get_section_by_name (abfd, ".pdata"); - diff --git a/bfd/pei-sw_64.c b/bfd/pei-sw_64.c new file mode 100644 index 00000000..ce9a9d26 @@ -3185,71 +2804,6 @@ index 00000000..ce9a9d26 +#define PEAOUTHDR PEPAOUTHDR + +#include "coff-sw_64.c" -diff --git a/bfd/peicode.h b/bfd/peicode.h -index b2d0f0f7..067c7782 100644 ---- a/bfd/peicode.h -+++ b/bfd/peicode.h -@@ -232,7 +232,9 @@ coff_swap_scnhdr_in (bfd * abfd, void * ext, void * in) - scnhdr_int->s_vaddr += pe_data (abfd)->pe_opthdr.ImageBase; - /* Do not cut upper 32-bits for 64-bit vma. */ - #ifndef COFF_WITH_pex64 -+#ifndef COFF_WITH_peSW_64 - scnhdr_int->s_vaddr &= 0xffffffff; -+#endif - #endif - } - -@@ -752,6 +754,15 @@ static const jump_table jtab[] = - 0x40, 0xbc, 0x60, 0x47, 0x00, 0x00, 0x00, 0x00 }, - 16, 12 - }, -+#endif -+#ifdef SW_64MAGIC -+/* We don't currently support jumping to DLLs, so if -+ someone does try emit a runtime trap. Through BREAK 0. */ -+ { SW_64MAGIC, -+ { 0x00, 0x00, 0x2a, 0x00 }, -+ 4, 0 -+ }, -+ - #endif - { 0, { 0 }, 0, 0 } - }; -@@ -910,7 +921,7 @@ pe_ILF_build_a_bfd (bfd * abfd, - /* See PR 20907 for a reproducer. */ - goto error_return; - --#ifdef COFF_WITH_pex64 -+#if defined(COFF_WITH_pex64) || defined(COFF_WITH_peSW_64) - ((unsigned int *) id4->contents)[0] = ordinal; - ((unsigned int *) id4->contents)[1] = 0x80000000; - ((unsigned int *) id5->contents)[0] = ordinal; -@@ -1166,10 +1177,6 @@ pe_ILF_object_p (bfd * abfd) - case IMAGE_FILE_MACHINE_UNKNOWN: - case IMAGE_FILE_MACHINE_ALPHA: - case IMAGE_FILE_MACHINE_ALPHA64: --#ifdef TARGET_SW_64 -- case IMAGE_FILE_MACHINE_SW_64: -- case IMAGE_FILE_MACHINE_SW_6464: --#endif - case IMAGE_FILE_MACHINE_IA64: - break; - -@@ -1210,6 +1217,14 @@ pe_ILF_object_p (bfd * abfd) - #endif - break; - -+#ifdef TARGET_SW_64 -+ case IMAGE_FILE_MACHINE_SW_64: -+#ifdef SW_64MAGIC -+ magic = SW_64MAGIC; -+#endif -+ break; -+#endif -+ - case IMAGE_FILE_MACHINE_THUMB: - #ifdef THUMBPEMAGIC - { diff --git a/bfd/targets.c b/bfd/targets.c index d4ab611e..de758e91 100644 --- a/bfd/targets.c diff --git a/binutils.spec b/binutils.spec index 9b8f28b8dee30d9938d6d7a4bb20cf9ea4e70294..115476b3f201f4ef2b129a1cf825e830322d7844 100644 --- a/binutils.spec +++ b/binutils.spec @@ -1,7 +1,7 @@ Summary: Binary utilities Name: binutils Version: 2.37 -Release: 37 +Release: 38 License: GPLv3+ URL: https://sourceware.org/binutils @@ -129,6 +129,7 @@ Patch5007: backport-CVE-2025-3198.patch # Patch6004: Unused Patch6005: Sw64-binutils-Add-Sw64-new-support.patch Patch6006: Sw64-Add-support-EFI.patch +Patch6007: Sw64-Add-support-EFI-2.patch %endif @@ -486,6 +487,9 @@ fi %{_infodir}/bfd*info* %changelog +* Mon Sep 08 2025 zengyao - 2.37-38 +- fix SW patch + * Thu Sep 4 2025 yixiangzhike - 2.37-37 - backport PR29171 to fix invalid read causing SIGSEGV