diff --git a/Always-allocate-a-new-pointer-for-section-name-that-.patch b/Always-allocate-a-new-pointer-for-section-name-that-.patch new file mode 100644 index 0000000000000000000000000000000000000000..a9d4a5f9f7ccd6117ea46da984cce58ec515e2d2 --- /dev/null +++ b/Always-allocate-a-new-pointer-for-section-name-that-.patch @@ -0,0 +1,55 @@ +From f800fc88f6576c65fb8e4a3cce1c8f060e912c98 Mon Sep 17 00:00:00 2001 +From: ticat_fp +Date: Tue, 5 Mar 2024 14:56:22 +0800 +Subject: [PATCH 1/2] Always allocate a new pointer for section name that may + be freed. + +Signed-off-by: cailulu +Signed-off-by: ticat_fp +--- + bfd/peXXigen.c | 20 ++++++++++---------- + 1 file changed, 10 insertions(+), 10 deletions(-) + +diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c +index 14100b8a..2102928e 100644 +--- a/bfd/peXXigen.c ++++ b/bfd/peXXigen.c +@@ -170,25 +170,25 @@ _bfd_XXi_swap_sym_in (bfd * abfd, void * ext1, void * in1) + int unused_section_number = 0; + asection *sec; + flagword flags; ++ size_t name_len; ++ char *sec_name; + + for (sec = abfd->sections; sec; sec = sec->next) + if (unused_section_number <= sec->target_index) + unused_section_number = sec->target_index + 1; + +- if (name == namebuf) ++ name_len = strlen (name) + 1; ++ sec_name = bfd_alloc (abfd, name_len); ++ if (sec_name == NULL) + { +- name = (const char *) bfd_alloc (abfd, strlen (namebuf) + 1); +- if (name == NULL) +- { +- _bfd_error_handler (_("%B: out of memory creating name for empty section"), +- abfd); +- return; +- } +- strcpy ((char *) name, namebuf); ++ _bfd_error_handler (_("%pB: out of memory creating name " ++ "for empty section"), abfd); ++ return; + } ++ memcpy (sec_name, name, name_len); + + flags = SEC_HAS_CONTENTS | SEC_ALLOC | SEC_DATA | SEC_LOAD; +- sec = bfd_make_section_anyway_with_flags (abfd, name, flags); ++ sec = bfd_make_section_anyway_with_flags (abfd, sec_name, flags); + if (sec == NULL) + { + _bfd_error_handler (_("%B: unable to create fake empty section"), +-- +2.33.0 + diff --git a/binutils-Remove-ABI_XLP32-related-code.patch b/binutils-Remove-ABI_XLP32-related-code.patch new file mode 100644 index 0000000000000000000000000000000000000000..4c3eba0384d188d1627d7cecc7869de917382fca --- /dev/null +++ b/binutils-Remove-ABI_XLP32-related-code.patch @@ -0,0 +1,42 @@ +From 86945d30ebb2ecb48904fceea20a664a6aca2ac3 Mon Sep 17 00:00:00 2001 +From: ticat_fp +Date: Tue, 5 Mar 2024 15:02:28 +0800 +Subject: [PATCH 2/2] binutils: Remove ABI_XLP32 related code. + +LoongArch's gcc-8.3.0 does not have the built-in macro _ABILPX32, +and _ABILPX32 has been deprecated. + +Signed-off-by: caiyinyu +Signed-off-by: ticat_fp +--- + binutils/readelf.c | 1 - + include/elf/loongarch.h | 1 - + 2 files changed, 2 deletions(-) + +diff --git a/binutils/readelf.c b/binutils/readelf.c +index f3e989c8..125dd752 100644 +--- a/binutils/readelf.c ++++ b/binutils/readelf.c +@@ -3863,7 +3863,6 @@ get_machine_flags (Filedata * filedata, unsigned e_flags, unsigned e_machine) + switch (e_flags & EF_LARCH_ABI) + { + case EF_LARCH_ABI_LP64: strcat (buf, ", LP64"); break; +- case EF_LARCH_ABI_XLP32: strcat (buf, ", XLP32"); break; + case EF_LARCH_ABI_LP32: strcat (buf, ", LP32"); break; + } + break; +diff --git a/include/elf/loongarch.h b/include/elf/loongarch.h +index 09a8ad23..c26705c0 100644 +--- a/include/elf/loongarch.h ++++ b/include/elf/loongarch.h +@@ -88,7 +88,6 @@ END_RELOC_NUMBERS (R_LARCH_count) + + #define EF_LARCH_ABI 0x0003 + #define EF_LARCH_ABI_LP64 0x0003 +-#define EF_LARCH_ABI_XLP32 0x0002 + #define EF_LARCH_ABI_LP32 0x0001 + + #endif /* _ELF_LOONG_H */ +-- +2.33.0 + diff --git a/binutils.spec b/binutils.spec index ecae53b43fcfb3f9cb8a4a5047a1deaa50358c16..1d7589c8293a92187217d6d14aa587a61ad47be2 100644 --- a/binutils.spec +++ b/binutils.spec @@ -24,7 +24,7 @@ # /usr/bin/aarch64-linux-gnu-ar # /usr/bin/aarch64-linux-gnu-as # [etc] -%define anolis_release .0.1 +%define anolis_release .0.2 %if 0%{!?binutils_target:1} @@ -653,6 +653,8 @@ Patch1008: binutils-Delete-warning-of-compile.patch Patch1009: ld-Fix-the-bug-of-pr21964-4.patch Patch1010: Add-missing-opcode-and-3A6000.patch Patch1011: Some-testsuite-fix.patch +Patch1012: Always-allocate-a-new-pointer-for-section-name-that-.patch +Patch1013: binutils-Remove-ABI_XLP32-related-code.patch #end #---------------------------------------------------------------------------- @@ -910,6 +912,8 @@ using libelf instead of BFD. %patch1009 -p1 %patch1010 -p1 %patch1011 -p1 +%patch1012 -p1 +%patch1013 -p1 # We cannot run autotools as there is an exact requirement of autoconf-2.59. # FIXME - this is no longer true. Maybe try reinstating autotool use ? @@ -1359,6 +1363,10 @@ exit 0 #---------------------------------------------------------------------------- %changelog +* Thu Mar 07 2024 Peng Fan - 2.30-123.0.2 +- LoongArch: Always allocate a new pointer for section name. +- LoongArch: binutils Remove ABI_XLP32 related code. + * Wed Dec 06 2023 Xue haolin - 2.30-123.0.1 - Rebrand to Anolis OS. - Add loongarch support. (lixing@loongson.cn)