diff --git a/1000-arch-support-loongarch64-platform.patch b/1000-arch-support-loongarch64-platform.patch deleted file mode 100644 index 5ffada9264860a105df7ca0dcbcd7b061d4ed292..0000000000000000000000000000000000000000 --- a/1000-arch-support-loongarch64-platform.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/src/elflint.c b/src/elflint.c -index 565cffd..a23d6e6 100644 ---- a/src/elflint.c -+++ b/src/elflint.c -@@ -329,7 +329,7 @@ static const int valid_e_machine[] = - EM_CRIS, EM_JAVELIN, EM_FIREPATH, EM_ZSP, EM_MMIX, EM_HUANY, EM_PRISM, - EM_AVR, EM_FR30, EM_D10V, EM_D30V, EM_V850, EM_M32R, EM_MN10300, - EM_MN10200, EM_PJ, EM_OPENRISC, EM_ARC_A5, EM_XTENSA, EM_ALPHA, -- EM_TILEGX, EM_TILEPRO, EM_AARCH64, EM_BPF, EM_RISCV, EM_CSKY -+ EM_TILEGX, EM_TILEPRO, EM_AARCH64, EM_BPF, EM_RISCV, EM_CSKY, EM_LOONGARCH - }; - #define nvalid_e_machine \ - (sizeof (valid_e_machine) / sizeof (valid_e_machine[0])) diff --git a/1001-backends-add-loongarch-support.patch b/1001-backends-add-loongarch-support.patch deleted file mode 100644 index 89ede5b23eca9c167594a367739443d2edb12f94..0000000000000000000000000000000000000000 --- a/1001-backends-add-loongarch-support.patch +++ /dev/null @@ -1,1120 +0,0 @@ -From 0b8705e04e66aaf56c6ba258f9c05c5993834fae Mon Sep 17 00:00:00 2001 -From: Liwei Ge -Date: Tue, 13 Sep 2022 18:00:10 +0800 -Subject: [PATCH 1001/1001] backends: add loongarch support - ---- - backends/Makefile.am | 8 +- - backends/Makefile.in | 39 +++++++- - backends/loongarch_cfi.c | 77 +++++++++++++++ - backends/loongarch_init.c | 78 +++++++++++++++ - backends/loongarch_initreg.c | 98 +++++++++++++++++++ - backends/loongarch_regs.c | 154 ++++++++++++++++++++++++++++++ - backends/loongarch_reloc.def | 93 ++++++++++++++++++ - backends/loongarch_retval.c | 179 +++++++++++++++++++++++++++++++++++ - backends/loongarch_symbol.c | 121 +++++++++++++++++++++++ - backends/loongarch_unwind.c | 85 +++++++++++++++++ - libebl/eblopenbackend.c | 2 + - 11 files changed, 929 insertions(+), 5 deletions(-) - create mode 100644 backends/loongarch_cfi.c - create mode 100644 backends/loongarch_init.c - create mode 100644 backends/loongarch_initreg.c - create mode 100644 backends/loongarch_regs.c - create mode 100644 backends/loongarch_reloc.def - create mode 100644 backends/loongarch_retval.c - create mode 100644 backends/loongarch_symbol.c - create mode 100644 backends/loongarch_unwind.c - -diff --git a/backends/Makefile.am b/backends/Makefile.am -index 62916c9..9cb45c0 100644 ---- a/backends/Makefile.am -+++ b/backends/Makefile.am -@@ -37,7 +37,7 @@ AM_CPPFLAGS += -I$(top_srcdir)/libebl -I$(top_srcdir)/libasm \ - noinst_LIBRARIES = libebl_backends.a libebl_backends_pic.a - - modules = i386 sh x86_64 ia64 alpha arm aarch64 sparc ppc ppc64 s390 \ -- m68k bpf riscv csky -+ m68k bpf riscv csky loongarch - - i386_SRCS = i386_init.c i386_symbol.c i386_corenote.c i386_cfi.c \ - i386_retval.c i386_regs.c i386_auxv.c \ -@@ -59,6 +59,10 @@ arm_SRCS = arm_init.c arm_symbol.c arm_regs.c arm_corenote.c \ - arm_auxv.c arm_attrs.c arm_retval.c arm_cfi.c arm_initreg.c \ - arm_machineflagname.c - -+loongarch_SRCS = loongarch_init.c loongarch_symbol.c loongarch_regs.c \ -+ loongarch_cfi.c loongarch_initreg.c loongarch_retval.c \ -+ loongarch_unwind.c -+ - aarch64_SRCS = aarch64_init.c aarch64_regs.c aarch64_symbol.c \ - aarch64_corenote.c aarch64_retval.c aarch64_cfi.c \ - aarch64_initreg.c aarch64_unwind.c -@@ -99,7 +103,7 @@ csky_SRCS = csky_attrs.c csky_init.c csky_symbol.c csky_cfi.c \ - libebl_backends_a_SOURCES = $(i386_SRCS) $(sh_SRCS) $(x86_64_SRCS) \ - $(ia64_SRCS) $(alpha_SRCS) $(arm_SRCS) \ - $(aarch64_SRCS) $(sparc_SRCS) $(ppc_SRCS) \ -- $(ppc64_SRCS) $(s390_SRCS) \ -+ $(ppc64_SRCS) $(s390_SRCS) $(loongarch_SRCS) \ - $(m68k_SRCS) $(bpf_SRCS) $(riscv_SRCS) $(csky_SRCS) - - libebl_backends_pic_a_SOURCES = -diff --git a/backends/Makefile.in b/backends/Makefile.in -index 7028fb0..e115b9a 100644 ---- a/backends/Makefile.in -+++ b/backends/Makefile.in -@@ -170,12 +170,16 @@ am__objects_14 = riscv_init.$(OBJEXT) riscv_symbol.$(OBJEXT) \ - am__objects_15 = csky_attrs.$(OBJEXT) csky_init.$(OBJEXT) \ - csky_symbol.$(OBJEXT) csky_cfi.$(OBJEXT) csky_regs.$(OBJEXT) \ - csky_initreg.$(OBJEXT) csky_corenote.$(OBJEXT) -+am__objects_16 = loongarch_init.$(OBJEXT) loongarch_symbol.$(OBJEXT) \ -+ loongarch_initreg.$(OBJEXT) loongarch_regs.$(OBJEXT) \ -+ loongarch_cfi.$(OBJEXT) loongarch_retval.$(OBJEXT) \ -+ loongarch_unwind.$(OBJEXT) - am_libebl_backends_a_OBJECTS = $(am__objects_1) $(am__objects_2) \ - $(am__objects_3) $(am__objects_4) $(am__objects_5) \ - $(am__objects_6) $(am__objects_7) $(am__objects_8) \ - $(am__objects_9) $(am__objects_10) $(am__objects_11) \ - $(am__objects_12) $(am__objects_13) $(am__objects_14) \ -- $(am__objects_15) -+ $(am__objects_15) $(am__objects_16) - libebl_backends_a_OBJECTS = $(am_libebl_backends_a_OBJECTS) - libebl_backends_pic_a_AR = $(AR) $(ARFLAGS) - libebl_backends_pic_a_LIBADD = -@@ -208,6 +212,10 @@ am__depfiles_remade = ./$(DEPDIR)/aarch64_cfi.Po \ - ./$(DEPDIR)/arm_initreg.Po ./$(DEPDIR)/arm_machineflagname.Po \ - ./$(DEPDIR)/arm_regs.Po ./$(DEPDIR)/arm_retval.Po \ - ./$(DEPDIR)/arm_symbol.Po ./$(DEPDIR)/bpf_init.Po \ -+ ./$(DEPDIR)/loongarch_init.Po ./$(DEPDIR)/loongarch_symbol.Po \ -+ ./$(DEPDIR)/loongarch_regs.Po ./$(DEPDIR)/loongarch_initreg.Po \ -+ ./$(DEPDIR)/loongarch_cfi.Po loongarch_retval.Po \ -+ ./$(DEPDIR)/loongarch_unwind.Po \ - ./$(DEPDIR)/bpf_regs.Po ./$(DEPDIR)/bpf_symbol.Po \ - ./$(DEPDIR)/csky_attrs.Po ./$(DEPDIR)/csky_cfi.Po \ - ./$(DEPDIR)/csky_corenote.Po ./$(DEPDIR)/csky_init.Po \ -@@ -522,7 +530,7 @@ textrel_msg = echo "WARNING: TEXTREL found in '$@'" - textrel_check = if $(READELF) -d $@ | grep -F -q TEXTREL; then $(textrel_found); fi - noinst_LIBRARIES = libebl_backends.a libebl_backends_pic.a - modules = i386 sh x86_64 ia64 alpha arm aarch64 sparc ppc ppc64 s390 \ -- m68k bpf riscv csky -+ m68k bpf riscv csky loongarch - - i386_SRCS = i386_init.c i386_symbol.c i386_corenote.c i386_cfi.c \ - i386_retval.c i386_regs.c i386_auxv.c \ -@@ -541,6 +549,10 @@ arm_SRCS = arm_init.c arm_symbol.c arm_regs.c arm_corenote.c \ - arm_auxv.c arm_attrs.c arm_retval.c arm_cfi.c arm_initreg.c \ - arm_machineflagname.c - -+loongarch_SRCS = loongarch_init.c loongarch_symbol.c loongarch_regs.c \ -+ loongarch_cfi.c loongarch_initreg.c loongarch_retval.c \ -+ loongarch_unwind.c -+ - aarch64_SRCS = aarch64_init.c aarch64_regs.c aarch64_symbol.c \ - aarch64_corenote.c aarch64_retval.c aarch64_cfi.c \ - aarch64_initreg.c aarch64_unwind.c -@@ -580,7 +592,7 @@ csky_SRCS = csky_attrs.c csky_init.c csky_symbol.c csky_cfi.c \ - libebl_backends_a_SOURCES = $(i386_SRCS) $(sh_SRCS) $(x86_64_SRCS) \ - $(ia64_SRCS) $(alpha_SRCS) $(arm_SRCS) \ - $(aarch64_SRCS) $(sparc_SRCS) $(ppc_SRCS) \ -- $(ppc64_SRCS) $(s390_SRCS) \ -+ $(ppc64_SRCS) $(s390_SRCS) $(loongarch_SRCS) \ - $(m68k_SRCS) $(bpf_SRCS) $(riscv_SRCS) $(csky_SRCS) - - libebl_backends_pic_a_SOURCES = -@@ -666,6 +678,13 @@ distclean-compile: - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arm_regs.Po@am__quote@ # am--include-marker - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arm_retval.Po@am__quote@ # am--include-marker - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arm_symbol.Po@am__quote@ # am--include-marker -+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/loongarch_init.Po@am__quote@ # am--include-marker -+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/loongarch_symbol.Po@am__quote@ # am--include-marker -+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/loongarch_regs.Po@am__quote@ # am--include-marker -+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/loongarch_initreg.Po@am__quote@ # am--include-marker -+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/loongarch_cfi.Po@am__quote@ # am--include-marker -+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/loongarch_retval.Po@am__quote@ # am--include-marker -+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/loongarch_unwind.Po@am__quote@ # am--include-marker - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bpf_init.Po@am__quote@ # am--include-marker - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bpf_regs.Po@am__quote@ # am--include-marker - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bpf_symbol.Po@am__quote@ # am--include-marker -@@ -922,6 +941,13 @@ distclean: distclean-am - -rm -f ./$(DEPDIR)/arm_regs.Po - -rm -f ./$(DEPDIR)/arm_retval.Po - -rm -f ./$(DEPDIR)/arm_symbol.Po -+ -rm -f ./$(DEPDIR)/loongarch_init.Po -+ -rm -f ./$(DEPDIR)/loongarch_symbol.Po -+ -rm -f ./$(DEPDIR)/loongarch_regs.Po -+ -rm -f ./$(DEPDIR)/loongarch_initreg.Po -+ -rm -f ./$(DEPDIR)/loongarch_cfi.Po -+ -rm -f ./$(DEPDIR)/loongarch_retval.Po -+ -rm -f ./$(DEPDIR)/loongarch_unwind.Po - -rm -f ./$(DEPDIR)/bpf_init.Po - -rm -f ./$(DEPDIR)/bpf_regs.Po - -rm -f ./$(DEPDIR)/bpf_symbol.Po -@@ -1077,6 +1103,13 @@ maintainer-clean: maintainer-clean-am - -rm -f ./$(DEPDIR)/arm_regs.Po - -rm -f ./$(DEPDIR)/arm_retval.Po - -rm -f ./$(DEPDIR)/arm_symbol.Po -+ -rm -f ./$(DEPDIR)/loongarch_init.Po -+ -rm -f ./$(DEPDIR)/loongarch_symbol.Po -+ -rm -f ./$(DEPDIR)/loongarch_initreg.Po -+ -rm -f ./$(DEPDIR)/loongarch_regs.Po -+ -rm -f ./$(DEPDIR)/loongarch_cfi.Po -+ -rm -f ./$(DEPDIR)/loongarch_retval.Po -+ -rm -f ./$(DEPDIR)/loongarch_unwind.Po - -rm -f ./$(DEPDIR)/bpf_init.Po - -rm -f ./$(DEPDIR)/bpf_regs.Po - -rm -f ./$(DEPDIR)/bpf_symbol.Po -diff --git a/backends/loongarch_cfi.c b/backends/loongarch_cfi.c -new file mode 100644 -index 0000000..568e230 ---- /dev/null -+++ b/backends/loongarch_cfi.c -@@ -0,0 +1,77 @@ -+/* LoongArch specific backend library. -+ * -+ * Copyright (C) 2022 OpenAnolis community LoongArch SIG. -+ * -+ * Author: Liwei Ge -+ * -+ */ -+ -+/* -+ This file is free software; you can redistribute it and/or modify -+ it under the terms of either -+ -+ * the GNU Lesser General Public License as published by the Free -+ Software Foundation; either version 3 of the License, or (at -+ your option) any later version -+ -+ or -+ -+ * the GNU General Public License as published by the Free -+ Software Foundation; either version 2 of the License, or (at -+ your option) any later version -+ -+ or both in parallel, as here. -+ -+ elfutils 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 copies of the GNU General Public License and -+ the GNU Lesser General Public License along with this program. If -+ not, see . -+*/ -+ -+#ifdef HAVE_CONFIG_H -+# include -+#endif -+ -+#include -+ -+#define BACKEND loongarch_ -+#include "libebl_CPU.h" -+ -+int -+loongarch_abi_cfi (Ebl *ebl __attribute__ ((unused)), Dwarf_CIE *abi_info) -+{ -+ static const uint8_t abi_cfi[] = -+ { -+ /* stack pointer r3, $sp */ -+ DW_CFA_def_cfa, ULEB128_7(3), ULEB128_7(0), -+ DW_CFA_val_offset, ULEB128_7(3), ULEB128_7(0), -+ -+#define SV(n) DW_CFA_same_value, ULEB128_7 (n) -+ /* The return address register contains the return address setup by caller. */ -+ SV(1), -+ -+ /* Callee-saved registers r23 - r31 */ -+ SV(23), SV(24), SV(25), SV(26), SV(27), SV(28), SV(29), SV(30), -+ SV(31), -+ -+ /* Frame pointer r22, $fp */ -+ SV(22), -+ -+ /* Callee-saved registers f24 - f31*/ -+ SV(56), SV(57), SV(58), SV(59), SV(60), SV(61), SV(62), SV(63), -+#undef SV -+ }; -+ -+ abi_info->initial_instructions = abi_cfi; -+ abi_info->initial_instructions_end = &abi_cfi[sizeof abi_cfi]; -+ -+ abi_info->data_alignment_factor = -4; -+ /* Return address r1, $ra */ -+ abi_info->return_address_register = 1; -+ -+ return 0; -+} -diff --git a/backends/loongarch_init.c b/backends/loongarch_init.c -new file mode 100644 -index 0000000..350da40 ---- /dev/null -+++ b/backends/loongarch_init.c -@@ -0,0 +1,78 @@ -+/* LoongArch specific backend library. -+ * -+ * Copyright (C) 2022 OpenAnolis community LoongArch SIG. -+ * -+ * Author: Liwei Ge -+ * -+ */ -+ -+/* -+ This file is free software; you can redistribute it and/or modify -+ it under the terms of either -+ -+ * the GNU Lesser General Public License as published by the Free -+ Software Foundation; either version 3 of the License, or (at -+ your option) any later version -+ -+ or -+ -+ * the GNU General Public License as published by the Free -+ Software Foundation; either version 2 of the License, or (at -+ your option) any later version -+ -+ or both in parallel, as here. -+ -+ elfutils 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 copies of the GNU General Public License and -+ the GNU Lesser General Public License along with this program. If -+ not, see . -+*/ -+ -+#ifdef HAVE_CONFIG_H -+# include -+#endif -+ -+#define BACKEND loongarch_ -+#define RELOC_PREFIX R_LARCH_ -+#include "libebl_CPU.h" -+ -+/* This defines the common reloc hooks based on loongarch_reloc.def. */ -+#include "common-reloc.c" -+ -+ -+Ebl * -+loongarch_init (Elf *elf __attribute__ ((unused)), -+ GElf_Half machine __attribute__ ((unused)), -+ Ebl *eh) -+{ -+ loongarch_init_reloc (eh); -+ -+ HOOK (eh, machine_flag_check); -+ HOOK (eh, check_special_symbol); -+ HOOK (eh, reloc_simple_type); -+ HOOK (eh, return_value_location); -+ HOOK (eh, set_initial_registers_tid); -+ HOOK (eh, register_info); -+ HOOK (eh, abi_cfi); -+ HOOK (eh, unwind); -+ -+ /* -+ This is FIRST_PSEUDO_REGISTER in GCC, since DWARF_FRAME_REGISTERS -+ is not explicitly defined. -+ -+ Number of hardware registers. We have: -+ - 32 integer registers -+ - 32 floating point registers -+ - 8 condition code registers -+ - 2 fake registers: -+ - ARG_POINTER_REGNUM -+ - FRAME_POINTER_REGNUM -+ */ -+ eh->frame_nregs = 74; -+ -+ return eh; -+} -diff --git a/backends/loongarch_initreg.c b/backends/loongarch_initreg.c -new file mode 100644 -index 0000000..0b8a562 ---- /dev/null -+++ b/backends/loongarch_initreg.c -@@ -0,0 +1,98 @@ -+/* LoongArch specific backend library. -+ * -+ * Copyright (C) 2022 OpenAnolis community LoongArch SIG. -+ * -+ * Author: Liwei Ge -+ * -+ */ -+ -+/* -+ This file is free software; you can redistribute it and/or modify -+ it under the terms of either -+ -+ * the GNU Lesser General Public License as published by the Free -+ Software Foundation; either version 3 of the License, or (at -+ your option) any later version -+ -+ or -+ -+ * the GNU General Public License as published by the Free -+ Software Foundation; either version 2 of the License, or (at -+ your option) any later version -+ -+ or both in parallel, as here. -+ -+ elfutils 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 copies of the GNU General Public License and -+ the GNU Lesser General Public License along with this program. If -+ not, see . -+*/ -+ -+#ifdef HAVE_CONFIG_H -+# include -+#endif -+ -+#include "system.h" -+#include -+#if defined(__loongarch__) && defined(__linux__) -+# include -+# include -+# include -+# include -+#endif -+ -+#define BACKEND loongarch_ -+#include "libebl_CPU.h" -+ -+bool -+loongarch_set_initial_registers_tid(pid_t tid __attribute__ ((unused)), -+ ebl_tid_registers_t *setfunc __attribute__ ((unused)), -+ void *arg __attribute__ ((unused))) -+{ -+ -+#if !defined __loongarch__ || !defined __linux__ -+ return false; -+#else -+ -+ /* General registers. */ -+ struct user_regs_struct gregs; -+ struct iovec iovec; -+ iovec.iov_base = &gregs; -+ iovec.iov_len = sizeof (gregs); -+ if (ptrace (PTRACE_GETREGSET, tid, NT_PRSTATUS, &iovec) != 0) -+ return false; -+ -+ /* r0 is constant 0. */ -+ Dwarf_Word zero = 0; -+ if (! setfunc (0, 1, &zero, arg)) -+ return false; -+ -+ /* r1 - r31 */ -+ if (! setfunc (1, 32, (Dwarf_Word *) &gregs.gpr[0], arg)) -+ return false; -+ -+ /* PC. */ -+ if (! setfunc (-1, 1, (Dwarf_Word *) &gregs.pc, arg)) -+ return false; -+ -+ struct user_fp_state fregs; -+ iovec.iov_base = &fregs; -+ iovec.iov_len = sizeof (fregs); -+ if (ptrace (PTRACE_GETREGSET, tid, NT_FPREGSET, &iovec) != 0) -+ return false; -+ -+ Dwarf_Word dwarf_fregs[32]; -+ for (int r = 0; r < 32; r++) -+ dwarf_fregs[r] = fregs.fpr[r] & 0xFFFFFFFF; -+ -+ if (! setfunc (32, 32, dwarf_fregs, arg)) -+ return false; -+ -+ return true; -+ -+#endif -+} -diff --git a/backends/loongarch_regs.c b/backends/loongarch_regs.c -new file mode 100644 -index 0000000..e504db3 ---- /dev/null -+++ b/backends/loongarch_regs.c -@@ -0,0 +1,154 @@ -+/* LoongArch specific backend library. -+ * -+ * Copyright (C) 2022 OpenAnolis community LoongArch SIG. -+ * -+ * Author: Liwei Ge -+ * -+ */ -+ -+/* -+ This file is free software; you can redistribute it and/or modify -+ it under the terms of either -+ -+ * the GNU Lesser General Public License as published by the Free -+ Software Foundation; either version 3 of the License, or (at -+ your option) any later version -+ -+ or -+ -+ * the GNU General Public License as published by the Free -+ Software Foundation; either version 2 of the License, or (at -+ your option) any later version -+ -+ or both in parallel, as here. -+ -+ elfutils 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 copies of the GNU General Public License and -+ the GNU Lesser General Public License along with this program. If -+ not, see . -+*/ -+ -+#ifdef HAVE_CONFIG_H -+# include -+#endif -+ -+#include -+#include -+#include -+ -+#define BACKEND loongarch_ -+#include "libebl_CPU.h" -+ -+ssize_t -+loongarch_register_info (Ebl *ebl __attribute__ ((unused)), -+ int regno, char *name, size_t namelen, -+ const char **prefix, const char **setname, -+ int *bits, int *type) -+{ -+ -+ if (name == NULL) -+ return 128; -+ -+ *prefix = ""; -+ if (regno < 32) -+ { -+ *setname = "integer"; -+ *type = DW_ATE_signed; -+ *bits = ebl->class == ELFCLASS64 ? 64 : 32; -+ } -+ else -+ { -+ *setname = "FPU"; -+ *type = DW_ATE_float; -+ *bits = 64; -+ } -+ -+ switch (regno) -+ { -+ case 0: -+ return stpcpy (name, "zero") + 1 - name; -+ case 1: -+ return stpcpy (name, "ra") + 1 - name; -+ case 2: -+ return stpcpy (name, "tp") + 1 - name; -+ case 3: -+ return stpcpy (name, "sp") + 1 - name; -+ -+ case 4 ... 11: -+ name[0] = 'a'; -+ name[1] = regno - 4 + '0'; -+ namelen = 2; -+ break; -+ -+ case 12 ... 20: -+ name[0] = 't'; -+ name[1] = regno - 12 + '0'; -+ namelen = 2; -+ break; -+ -+ case 21: -+ name[0] = 'u'; -+ name[1] = '0'; -+ namelen = 2; -+ break; -+ -+ case 22: -+ name[0] = 'f'; -+ name[1] = 'p'; -+ namelen = 2; -+ break; -+ -+ case 23 ... 31: -+ name[0] = 's'; -+ name[1] = regno - 23 + '0'; -+ namelen = 2; -+ break; -+ -+ case 32 ... 39: -+ name[0] = 'f'; -+ name[1] = 'a'; -+ name[2] = regno - 32 + '0'; -+ namelen = 3; -+ break; -+ -+ case 40 ... 49: -+ name[0] = 'f'; -+ name[1] = 't'; -+ name[2] = regno - 40 + '0'; -+ namelen = 3; -+ break; -+ case 50 ... 55: -+ name[0] = 'f'; -+ name[1] = 't'; -+ name[2] = '1'; -+ name[3] = regno - 50 + '0'; -+ namelen = 3; -+ break; -+ -+ case 56 ... 63: -+ name[0] = 'f'; -+ name[1] = 's'; -+ name[2] = regno - 56 + '0'; -+ namelen = 3; -+ break; -+ -+ case 64 ... 71: -+ name[0] = 'f'; -+ name[1] = 'c'; -+ name[2] = 'c'; -+ name[3] = regno - 64 + '0'; -+ namelen = 3; -+ break; -+ -+ default: -+ *setname = NULL; -+ return 0; -+ } -+ -+ name[namelen++] = '\0'; -+ return namelen; -+} -diff --git a/backends/loongarch_reloc.def b/backends/loongarch_reloc.def -new file mode 100644 -index 0000000..24bd1d6 ---- /dev/null -+++ b/backends/loongarch_reloc.def -@@ -0,0 +1,93 @@ -+/* LoongArch specific backend library. -+ * -+ * Copyright (C) 2022 OpenAnolis community LoongArch SIG. -+ * -+ * Author: Liwei Ge -+ * -+ */ -+ -+/* -+ This file is free software; you can redistribute it and/or modify -+ it under the terms of either -+ -+ * the GNU Lesser General Public License as published by the Free -+ Software Foundation; either version 3 of the License, or (at -+ your option) any later version -+ -+ or -+ -+ * the GNU General Public License as published by the Free -+ Software Foundation; either version 2 of the License, or (at -+ your option) any later version -+ -+ or both in parallel, as here. -+ -+ elfutils 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 copies of the GNU General Public License and -+ the GNU Lesser General Public License along with this program. If -+ not, see . -+*/ -+ -+/* LoongArch specific dynamic relocations */ -+RELOC_TYPE (NONE, REL|EXEC|DYN) -+RELOC_TYPE (32, REL|EXEC|DYN) -+RELOC_TYPE (64, REL|EXEC|DYN) -+RELOC_TYPE (RELATIVE, EXEC|DYN) -+RELOC_TYPE (COPY, EXEC|DYN) -+RELOC_TYPE (JUMP_SLOT, EXEC|DYN) -+RELOC_TYPE (TLS_DTPMOD32, EXEC|DYN) -+RELOC_TYPE (TLS_DTPMOD64, EXEC|DYN) -+RELOC_TYPE (TLS_DTPREL32, EXEC|DYN) -+RELOC_TYPE (TLS_DTPREL64, EXEC|DYN) -+RELOC_TYPE (TLS_TPREL32, EXEC|DYN) -+RELOC_TYPE (TLS_TPREL64, EXEC|DYN) -+RELOC_TYPE (IRELATIVE, EXEC|DYN) -+ -+ -+/* used by the static linker for relocating .text. */ -+RELOC_TYPE (MARK_LA, REL) -+RELOC_TYPE (MARK_PCREL, REL) -+RELOC_TYPE (SOP_PUSH_PCREL, REL) -+RELOC_TYPE (SOP_PUSH_ABSOLUTE, REL) -+RELOC_TYPE (SOP_PUSH_DUP, REL) -+RELOC_TYPE (SOP_PUSH_GPREL, REL) -+RELOC_TYPE (SOP_PUSH_TLS_TPREL, REL) -+RELOC_TYPE (SOP_PUSH_TLS_GOT, REL) -+RELOC_TYPE (SOP_PUSH_TLS_GD, REL) -+RELOC_TYPE (SOP_PUSH_PLT_PCREL, REL) -+RELOC_TYPE (SOP_ASSERT, REL) -+RELOC_TYPE (SOP_NOT, REL) -+RELOC_TYPE (SOP_SUB, REL) -+RELOC_TYPE (SOP_SL, REL) -+RELOC_TYPE (SOP_SR, REL) -+RELOC_TYPE (SOP_ADD, REL) -+RELOC_TYPE (SOP_AND, REL) -+RELOC_TYPE (SOP_IF_ELSE, REL) -+ -+RELOC_TYPE (SOP_POP_32_S_10_5, REL) -+RELOC_TYPE (SOP_POP_32_U_10_12, REL) -+RELOC_TYPE (SOP_POP_32_S_10_12, REL) -+RELOC_TYPE (SOP_POP_32_S_10_16, REL) -+RELOC_TYPE (SOP_POP_32_S_10_16_S2, REL) -+RELOC_TYPE (SOP_POP_32_S_5_20, REL) -+RELOC_TYPE (SOP_POP_32_S_0_5_10_16_S2, REL) -+RELOC_TYPE (SOP_POP_32_S_0_10_10_16_S2, REL) -+RELOC_TYPE (SOP_POP_32_U, REL) -+ -+/* used by the static linker for relocating non .text. */ -+RELOC_TYPE (ADD8, REL) -+RELOC_TYPE (ADD16, REL) -+RELOC_TYPE (ADD24, REL) -+RELOC_TYPE (ADD32, REL) -+RELOC_TYPE (ADD64, REL) -+RELOC_TYPE (SUB8, REL) -+RELOC_TYPE (SUB16, REL) -+RELOC_TYPE (SUB24, REL) -+RELOC_TYPE (SUB32, REL) -+RELOC_TYPE (SUB64, REL) -+RELOC_TYPE (GNU_VTINHERIT, REL) -+RELOC_TYPE (GNU_VTENTRY, REL) -diff --git a/backends/loongarch_retval.c b/backends/loongarch_retval.c -new file mode 100644 -index 0000000..6b345c8 ---- /dev/null -+++ b/backends/loongarch_retval.c -@@ -0,0 +1,179 @@ -+/* LoongArch specific backend library. -+ * -+ * Copyright (C) 2022 OpenAnolis community LoongArch SIG. -+ * -+ * Author: Liwei Ge -+ * -+ */ -+ -+/* -+ This file is free software; you can redistribute it and/or modify -+ it under the terms of either -+ -+ * the GNU Lesser General Public License as published by the Free -+ Software Foundation; either version 3 of the License, or (at -+ your option) any later version -+ -+ or -+ -+ * the GNU General Public License as published by the Free -+ Software Foundation; either version 2 of the License, or (at -+ your option) any later version -+ -+ or both in parallel, as here. -+ -+ elfutils 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 copies of the GNU General Public License and -+ the GNU Lesser General Public License along with this program. If -+ not, see . -+*/ -+ -+#ifdef HAVE_CONFIG_H -+# include -+#endif -+ -+#include -+#include -+ -+#define BACKEND loongarch_ -+#include "libebl_CPU.h" -+ -+static int -+dwarf_bytesize_aux (Dwarf_Die *die, Dwarf_Word *sizep) -+{ -+ int bits; -+ if (((bits = 8 * dwarf_bytesize (die)) < 0 -+ && (bits = dwarf_bitsize (die)) < 0) -+ || bits % 8 != 0) -+ return -1; -+ -+ *sizep = bits / 8; -+ return 0; -+} -+ -+/* r4 - r5, $a0 - $a1 Argument registers / return value registers */ -+static int -+pass_by_ref (const Dwarf_Op **locp) -+{ -+ static const Dwarf_Op loc[] = { { .atom = DW_OP_reg4 } }; -+ *locp = loc; -+ -+ return 1; -+} -+ -+static int -+pass_in_gpr (const Dwarf_Op **locp, Dwarf_Word size) -+{ -+ static const Dwarf_Op loc[] = -+ { -+ { .atom = DW_OP_reg4 }, { .atom = DW_OP_piece, .number = 8 }, -+ { .atom = DW_OP_reg5 }, { .atom = DW_OP_piece, .number = 8 } -+ }; -+ *locp = loc; -+ -+ return size <= 8 ? 1 : 4; -+} -+ -+/* r32 - r33, $fa0 - $fa1 Argument registers / return value registers */ -+static int -+pass_in_fpr (const Dwarf_Op **locp, Dwarf_Word size) -+{ -+ static const Dwarf_Op loc[] = -+ { -+ { .atom = DW_OP_regx, .number = 32 }, -+ { .atom = DW_OP_piece, .number = 8 }, -+ { .atom = DW_OP_regx, .number = 33 }, -+ { .atom = DW_OP_piece, .number = 8 } -+ }; -+ *locp = loc; -+ -+ return size <= 8 ? 1 : 4; -+} -+ -+int -+loongarch_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp) -+{ -+ /* Start with the function's type, and get the DW_AT_type attribute, -+ which is the type of the return value. */ -+ Dwarf_Die typedie; -+ int tag = dwarf_peeled_die_type (functypedie, &typedie); -+ if (tag <= 0) -+ return tag; -+ -+ Dwarf_Word size = (Dwarf_Word)-1; -+ -+ if (tag == DW_TAG_structure_type || tag == DW_TAG_union_type -+ || tag == DW_TAG_class_type || tag == DW_TAG_array_type) -+ { -+ if (dwarf_aggregate_size (&typedie, &size) < 0) -+ return -1; -+ -+ if (size > 16) -+ return pass_by_ref(locp); -+ else -+ return pass_in_gpr(locp, size); -+ } -+ -+ if (tag == DW_TAG_base_type -+ || tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type) -+ { -+ if (dwarf_bytesize_aux (&typedie, &size) < 0) -+ { -+ if (tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type) -+ size = 8; -+ else -+ return -1; -+ } -+ -+ Dwarf_Attribute attr_mem; -+ if (tag == DW_TAG_base_type) -+ { -+ Dwarf_Word encoding; -+ if (dwarf_formudata (dwarf_attr_integrate (&typedie, DW_AT_encoding, &attr_mem), -+ &encoding) != 0) -+ return -1; -+ -+ switch (encoding) -+ { -+ case DW_ATE_boolean: -+ case DW_ATE_signed: -+ case DW_ATE_unsigned: -+ case DW_ATE_unsigned_char: -+ case DW_ATE_signed_char: -+ return pass_in_gpr(locp, size); -+ -+ case DW_ATE_float: -+ switch (size) -+ { -+ case 4: /* single */ -+ case 8: /* double */ -+ return pass_in_fpr (locp, size); -+ case 16: -+ return pass_by_ref (locp); -+ default: -+ return -2; -+ } -+ case DW_ATE_complex_float: -+ switch (size) -+ { -+ case 8: /* single */ -+ case 16: /* double */ -+ return pass_in_fpr (locp, size); -+ case 32: -+ return pass_by_ref (locp); -+ default: -+ return -2; -+ } -+ } -+ } -+ else -+ return pass_in_gpr(locp, size); -+ } -+ -+ *locp = NULL; -+ return 0; -+} -diff --git a/backends/loongarch_symbol.c b/backends/loongarch_symbol.c -new file mode 100644 -index 0000000..b09448b ---- /dev/null -+++ b/backends/loongarch_symbol.c -@@ -0,0 +1,121 @@ -+/* LoongArch specific symbolic name handling. -+ * -+ * Copyright (C) 2022 OpenAnolis community LoongArch SIG. -+ * -+ * Author: Liwei Ge -+ * -+ */ -+ -+/* -+ This file is free software; you can redistribute it and/or modify -+ it under the terms of either -+ -+ * the GNU Lesser General Public License as published by the Free -+ Software Foundation; either version 3 of the License, or (at -+ your option) any later version -+ -+ or -+ -+ * the GNU General Public License as published by the Free -+ Software Foundation; either version 2 of the License, or (at -+ your option) any later version -+ -+ or both in parallel, as here. -+ -+ elfutils 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 copies of the GNU General Public License and -+ the GNU Lesser General Public License along with this program. If -+ not, see . -+*/ -+ -+#ifdef HAVE_CONFIG_H -+# include -+#endif -+ -+#include -+ -+#include -+#include -+#include -+ -+#define BACKEND loongarch_ -+#include "libebl_CPU.h" -+ -+ -+/* Check whether machine flags are valid. */ -+bool -+loongarch_machine_flag_check (GElf_Word flags) -+{ -+ -+ return ((flags &~ (EF_LARCH_ABI -+ | EF_LARCH_ABI_LP64D)) == 0); -+} -+ -+bool -+loongarch_check_special_symbol (Elf *elf, const GElf_Sym *sym, -+ const char *name, const GElf_Shdr *destshdr) -+{ -+ if (name != NULL && strcmp(name, "_GLOBAL_OFFSET_TABLE_") == 0) -+ { -+ size_t shstrndx; -+ if (elf_getshdrstrndx(elf, &shstrndx) != 0) -+ return false; -+ -+ const char *sname = elf_strptr(elf, shstrndx, destshdr->sh_name); -+ if (sname != NULL && (strcmp(sname, ".got") == 0 || strcmp(sname, ".got.plt") == 0)) -+ { -+ Elf_Scn *scn = NULL; -+ while ((scn = elf_nextscn(elf, scn)) != NULL) -+ { -+ GElf_Shdr shdr_mem; -+ GElf_Shdr *shdr = gelf_getshdr(scn, &shdr_mem); -+ if (shdr != NULL) -+ { -+ sname = elf_strptr(elf, shstrndx, shdr->sh_name); -+ if (sname != NULL && strcmp(sname, ".got") == 0) -+ return (sym->st_value >= shdr->sh_addr && sym->st_value < shdr->sh_addr + shdr->sh_size); -+ } -+ } -+ } -+ } -+ -+ return false; -+} -+ -+Elf_Type -+loongarch_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type, -+ int *addsub __attribute__ ((unused))) -+{ -+ switch (type) -+ { -+ case R_LARCH_32: -+ return ELF_T_WORD; -+ case R_LARCH_64: -+ return ELF_T_XWORD; -+ -+ case R_LARCH_ADD8: -+ return ELF_T_BYTE; -+ case R_LARCH_ADD16: -+ return ELF_T_HALF; -+ case R_LARCH_ADD32: -+ return ELF_T_WORD; -+ case R_LARCH_ADD64: -+ return ELF_T_XWORD; -+ -+ case R_LARCH_SUB8: -+ return ELF_T_BYTE; -+ case R_LARCH_SUB16: -+ return ELF_T_HALF; -+ case R_LARCH_SUB32: -+ return ELF_T_WORD; -+ case R_LARCH_SUB64: -+ return ELF_T_XWORD; -+ -+ default: -+ return ELF_T_NUM; -+ } -+} -diff --git a/backends/loongarch_unwind.c b/backends/loongarch_unwind.c -new file mode 100644 -index 0000000..208b596 ---- /dev/null -+++ b/backends/loongarch_unwind.c -@@ -0,0 +1,85 @@ -+/* LoongArch specific backend library. -+ * -+ * Copyright (C) 2022 OpenAnolis community LoongArch SIG. -+ * -+ * Author: Liwei Ge -+ * -+ */ -+ -+/* -+ This file is free software; you can redistribute it and/or modify -+ it under the terms of either -+ -+ * the GNU Lesser General Public License as published by the Free -+ Software Foundation; either version 3 of the License, or (at -+ your option) any later version -+ -+ or -+ -+ * the GNU General Public License as published by the Free -+ Software Foundation; either version 2 of the License, or (at -+ your option) any later version -+ -+ or both in parallel, as here. -+ -+ elfutils 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 copies of the GNU General Public License and -+ the GNU Lesser General Public License along with this program. If -+ not, see . -+*/ -+ -+#ifdef HAVE_CONFIG_H -+# include -+#endif -+ -+#define BACKEND loongarch_ -+#define RA_REG 3 -+#define SP_REG 3 -+#define FP_REG 22 -+ -+#define RA_OFFSET 8 -+#define SP_OFFSET 16 -+ -+#include "libebl_CPU.h" -+ -+ -+bool -+loongarch_unwind (Ebl *ebl __attribute__ ((unused)), Dwarf_Addr pc __attribute__ ((unused)), -+ ebl_tid_registers_t *setfunc, ebl_tid_registers_get_t *getfunc, -+ ebl_pid_memory_read_t *readfunc, void *arg, -+ bool *signal_framep __attribute__ ((unused))) -+{ -+ -+ Dwarf_Word ra; -+ if (!getfunc(RA_REG, 1, &ra, arg)) -+ return false; -+ /* set next frame */ -+ setfunc(-1, 1, &ra, arg); -+ -+ Dwarf_Word fp, sp; -+ /* read from regs */ -+ if (!getfunc(FP_REG, 1, &fp, arg)) -+ fp = 0; -+ if (!getfunc(SP_REG, 1, &sp, arg)) -+ sp = 0; -+ -+ /* read from frame */ -+ Dwarf_Word prev_fp; -+ if (!readfunc(fp, &prev_fp, arg)) -+ prev_fp = 0; -+ Dwarf_Word new_ra; -+ if (!readfunc(fp + RA_OFFSET, &new_ra, arg)) -+ return false; -+ Dwarf_Word new_sp = fp + SP_OFFSET; -+ -+ /* set regs */ -+ setfunc(FP_REG, 1, &prev_fp, arg); -+ setfunc(RA_REG, 1, &new_ra, arg); -+ setfunc(SP_REG, 1, &new_sp, arg); -+ -+ return fp == 0 || new_sp > sp; -+} -diff --git a/libebl/eblopenbackend.c b/libebl/eblopenbackend.c -index 0c07296..a1e9228 100644 ---- a/libebl/eblopenbackend.c -+++ b/libebl/eblopenbackend.c -@@ -56,6 +56,7 @@ Ebl *m68k_init (Elf *, GElf_Half, Ebl *); - Ebl *bpf_init (Elf *, GElf_Half, Ebl *); - Ebl *riscv_init (Elf *, GElf_Half, Ebl *); - Ebl *csky_init (Elf *, GElf_Half, Ebl *); -+Ebl *loongarch_init (Elf *, GElf_Half, Ebl *); - - /* This table should contain the complete list of architectures as far - as the ELF specification is concerned. */ -@@ -81,6 +82,7 @@ static const struct - // XXX class and machine fields need to be filled in for all archs. - { sh_init, "elf_sh", "sh", 2, EM_SH, 0, 0 }, - { arm_init, "ebl_arm", "arm", 3, EM_ARM, 0, 0 }, -+ { loongarch_init, "elf_loongarch", "loongarch64", 11, EM_LOONGARCH, ELFCLASS64, ELFDATA2LSB }, - { sparc_init, "elf_sparcv9", "sparc", 5, EM_SPARCV9, 0, 0 }, - { sparc_init, "elf_sparc", "sparc", 5, EM_SPARC, 0, 0 }, - { sparc_init, "elf_sparcv8plus", "sparc", 5, EM_SPARC32PLUS, 0, 0 }, --- -2.27.0 - diff --git a/download b/download index 3ea225322b2201d5f29add00a411759ac1a55877..fb3a125fa29bb5cc6e54d7465b48eaf09a5b7b21 100644 --- a/download +++ b/download @@ -1 +1 @@ -efb25a91873b2eec4df9f31e6a4f4e5c elfutils-0.188.tar.bz2 +5cfaa711a90cb670406cd495aeaa6030 elfutils-0.189.tar.bz2 diff --git a/elfutils-0.188-compile-warnings.patch b/elfutils-0.188-compile-warnings.patch deleted file mode 100644 index 397583fa122727c2fc7ee6f5c64e25422fcae353..0000000000000000000000000000000000000000 --- a/elfutils-0.188-compile-warnings.patch +++ /dev/null @@ -1,109 +0,0 @@ -commit 75f2de448f311807e2493f2a37a980e2d872b229 -Author: Mark Wielaard -Date: Thu Nov 3 13:38:45 2022 +0100 - - readelf: Check phdr != NULL or shdr != NULL in handle_dynamic. - - The compiler doesn't know that when use_dynamic_segment is true, - then phdr should/will be non-NULL and otherwise shdr is non-NULL. - Add explicit checks to help the compiler out and in case an error - is made calling the handle_dynamic function. - - Signed-off-by: Mark Wielaard - -diff --git a/src/readelf.c b/src/readelf.c -index 0e0b05c4..e721a209 100644 ---- a/src/readelf.c -+++ b/src/readelf.c -@@ -1828,7 +1828,7 @@ handle_dynamic (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr, GElf_Phdr *phdr) - size_t dyn_ents; - - /* Get the data of the section. */ -- if (use_dynamic_segment) -+ if (use_dynamic_segment && phdr != NULL) - data = elf_getdata_rawchunk(ebl->elf, phdr->p_offset, - phdr->p_filesz, ELF_T_DYN); - else -@@ -1840,7 +1840,7 @@ handle_dynamic (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr, GElf_Phdr *phdr) - /* Get the dynamic section entry number */ - dyn_ents = get_dyn_ents (data); - -- if (!use_dynamic_segment) -+ if (!use_dynamic_segment && shdr != NULL) - { - /* Get the section header string table index. */ - if (unlikely (elf_getshdrstrndx (ebl->elf, &shstrndx) < 0)) -@@ -1862,7 +1862,7 @@ handle_dynamic (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr, GElf_Phdr *phdr) - (int) shdr->sh_link, - elf_strptr (ebl->elf, shstrndx, glink->sh_name)); - } -- else -+ else if (phdr != NULL) - { - printf (ngettext ("\ - \nDynamic segment contains %lu entry:\n Addr: %#0*" PRIx64 " Offset: %#08" PRIx64 "\n", -@@ -1879,7 +1879,7 @@ handle_dynamic (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr, GElf_Phdr *phdr) - /* if --use-dynamic option is enabled, - use the string table to get the related library info. */ - Elf_Data *strtab_data = NULL; -- if (use_dynamic_segment) -+ if (use_dynamic_segment && phdr != NULL) - { - strtab_data = get_dynscn_strtab(ebl->elf, phdr); - if (strtab_data == NULL) -@@ -1903,7 +1903,7 @@ handle_dynamic (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr, GElf_Phdr *phdr) - || dyn->d_tag == DT_RPATH - || dyn->d_tag == DT_RUNPATH) - { -- if (! use_dynamic_segment) -+ if (! use_dynamic_segment && shdr != NULL) - name = elf_strptr (ebl->elf, shdr->sh_link, dyn->d_un.d_val); - else if (dyn->d_un.d_val < strtab_data->d_size - && memrchr (strtab_data->d_buf + dyn->d_un.d_val, '\0', - -commit b0a0235771906e3bcd6174c4e3c020b5522b0be5 -Author: Mark Wielaard -Date: Thu Nov 3 13:44:35 2022 +0100 - - libdw: Don't dereference and assign values we are skipping - - We don't use the FDE address encoding byte, so no reason - to read and store it. Just skip past it. - - Signed-off-by: Mark Wielaard - -diff --git a/libdw/dwarf_next_cfi.c b/libdw/dwarf_next_cfi.c -index 23b16885..be08984f 100644 ---- a/libdw/dwarf_next_cfi.c -+++ b/libdw/dwarf_next_cfi.c -@@ -226,7 +226,7 @@ dwarf_next_cfi (const unsigned char e_ident[], - if (sized_augmentation) - { - /* Skip FDE address encoding byte. */ -- encoding = *bytes++; -+ bytes++; - continue; - } - break; - -commit 52a6a3110e019d696284fdd822c2a2f0987dded2 -Author: Mark Wielaard -Date: Thu Nov 3 13:52:32 2022 +0100 - - readelf: Check gelf_getdyn doesn't return NULL - - Signed-off-by: Mark Wielaard - -diff --git a/src/readelf.c b/src/readelf.c -index e721a209..3dafb041 100644 ---- a/src/readelf.c -+++ b/src/readelf.c -@@ -4910,7 +4910,7 @@ get_dynscn_addrs(Elf *elf, GElf_Phdr *phdr, GElf_Addr addrs[i_max]) - GElf_Dyn dyn_mem; - GElf_Dyn *dyn = gelf_getdyn(data, dyn_idx, &dyn_mem); - /* DT_NULL Marks end of dynamic section. */ -- if (dyn->d_tag == DT_NULL) -+ if (dyn == NULL || dyn->d_tag == DT_NULL) - break; - - switch (dyn->d_tag) { diff --git a/elfutils-0.188-debuginfod-client-lifetime.patch b/elfutils-0.188-debuginfod-client-lifetime.patch deleted file mode 100644 index 4c8f735a874839f6e088da66fd6ebd8416fe3c73..0000000000000000000000000000000000000000 --- a/elfutils-0.188-debuginfod-client-lifetime.patch +++ /dev/null @@ -1,171 +0,0 @@ -commit c424e5f3d24f76e01242d15ba361dc6234706fed -Author: Frank Ch. Eigler -Date: Thu Nov 3 10:07:31 2022 -0400 - - debuginfod.cxx: fix coverity-found use-after-release error - - The debuginfod_client object lifetime needs more careful handling, - made easier with the defer_dtor<> gadget. - - Signed-off-by: Frank Ch. Eigler - -diff --git a/debuginfod/debuginfod.cxx b/debuginfod/debuginfod.cxx -index f46da6ef..02a11477 100644 ---- a/debuginfod/debuginfod.cxx -+++ b/debuginfod/debuginfod.cxx -@@ -2249,85 +2249,82 @@ handle_buildid (MHD_Connection* conn, - - int fd = -1; - debuginfod_client *client = debuginfod_pool_begin (); -- if (client != NULL) -- { -- debuginfod_set_progressfn (client, & debuginfod_find_progress); -+ if (client == NULL) -+ throw libc_exception(errno, "debuginfod client pool alloc"); -+ defer_dtor client_closer (client, debuginfod_pool_end); -+ -+ debuginfod_set_progressfn (client, & debuginfod_find_progress); - -- if (conn) -- { -- // Transcribe incoming User-Agent: -- string ua = MHD_lookup_connection_value (conn, MHD_HEADER_KIND, "User-Agent") ?: ""; -- string ua_complete = string("User-Agent: ") + ua; -- debuginfod_add_http_header (client, ua_complete.c_str()); -- -- // Compute larger XFF:, for avoiding info loss during -- // federation, and for future cyclicity detection. -- string xff = MHD_lookup_connection_value (conn, MHD_HEADER_KIND, "X-Forwarded-For") ?: ""; -- if (xff != "") -- xff += string(", "); // comma separated list -- -- unsigned int xff_count = 0; -- for (auto&& i : xff){ -- if (i == ',') xff_count++; -- } -+ if (conn) -+ { -+ // Transcribe incoming User-Agent: -+ string ua = MHD_lookup_connection_value (conn, MHD_HEADER_KIND, "User-Agent") ?: ""; -+ string ua_complete = string("User-Agent: ") + ua; -+ debuginfod_add_http_header (client, ua_complete.c_str()); -+ -+ // Compute larger XFF:, for avoiding info loss during -+ // federation, and for future cyclicity detection. -+ string xff = MHD_lookup_connection_value (conn, MHD_HEADER_KIND, "X-Forwarded-For") ?: ""; -+ if (xff != "") -+ xff += string(", "); // comma separated list -+ -+ unsigned int xff_count = 0; -+ for (auto&& i : xff){ -+ if (i == ',') xff_count++; -+ } - -- // if X-Forwarded-For: exceeds N hops, -- // do not delegate a local lookup miss to upstream debuginfods. -- if (xff_count >= forwarded_ttl_limit) -- throw reportable_exception(MHD_HTTP_NOT_FOUND, "not found, --forwared-ttl-limit reached \ -+ // if X-Forwarded-For: exceeds N hops, -+ // do not delegate a local lookup miss to upstream debuginfods. -+ if (xff_count >= forwarded_ttl_limit) -+ throw reportable_exception(MHD_HTTP_NOT_FOUND, "not found, --forwared-ttl-limit reached \ - and will not query the upstream servers"); - -- // Compute the client's numeric IP address only - so can't merge with conninfo() -- const union MHD_ConnectionInfo *u = MHD_get_connection_info (conn, -- MHD_CONNECTION_INFO_CLIENT_ADDRESS); -- struct sockaddr *so = u ? u->client_addr : 0; -- char hostname[256] = ""; // RFC1035 -- if (so && so->sa_family == AF_INET) { -- (void) getnameinfo (so, sizeof (struct sockaddr_in), hostname, sizeof (hostname), NULL, 0, -- NI_NUMERICHOST); -- } else if (so && so->sa_family == AF_INET6) { -- struct sockaddr_in6* addr6 = (struct sockaddr_in6*) so; -- if (IN6_IS_ADDR_V4MAPPED(&addr6->sin6_addr)) { -- struct sockaddr_in addr4; -- memset (&addr4, 0, sizeof(addr4)); -- addr4.sin_family = AF_INET; -- addr4.sin_port = addr6->sin6_port; -- memcpy (&addr4.sin_addr.s_addr, addr6->sin6_addr.s6_addr+12, sizeof(addr4.sin_addr.s_addr)); -- (void) getnameinfo ((struct sockaddr*) &addr4, sizeof (addr4), -- hostname, sizeof (hostname), NULL, 0, -- NI_NUMERICHOST); -- } else { -- (void) getnameinfo (so, sizeof (struct sockaddr_in6), hostname, sizeof (hostname), NULL, 0, -- NI_NUMERICHOST); -- } -- } -- -- string xff_complete = string("X-Forwarded-For: ")+xff+string(hostname); -- debuginfod_add_http_header (client, xff_complete.c_str()); -+ // Compute the client's numeric IP address only - so can't merge with conninfo() -+ const union MHD_ConnectionInfo *u = MHD_get_connection_info (conn, -+ MHD_CONNECTION_INFO_CLIENT_ADDRESS); -+ struct sockaddr *so = u ? u->client_addr : 0; -+ char hostname[256] = ""; // RFC1035 -+ if (so && so->sa_family == AF_INET) { -+ (void) getnameinfo (so, sizeof (struct sockaddr_in), hostname, sizeof (hostname), NULL, 0, -+ NI_NUMERICHOST); -+ } else if (so && so->sa_family == AF_INET6) { -+ struct sockaddr_in6* addr6 = (struct sockaddr_in6*) so; -+ if (IN6_IS_ADDR_V4MAPPED(&addr6->sin6_addr)) { -+ struct sockaddr_in addr4; -+ memset (&addr4, 0, sizeof(addr4)); -+ addr4.sin_family = AF_INET; -+ addr4.sin_port = addr6->sin6_port; -+ memcpy (&addr4.sin_addr.s_addr, addr6->sin6_addr.s6_addr+12, sizeof(addr4.sin_addr.s_addr)); -+ (void) getnameinfo ((struct sockaddr*) &addr4, sizeof (addr4), -+ hostname, sizeof (hostname), NULL, 0, -+ NI_NUMERICHOST); -+ } else { -+ (void) getnameinfo (so, sizeof (struct sockaddr_in6), hostname, sizeof (hostname), NULL, 0, -+ NI_NUMERICHOST); - } -- -- if (artifacttype == "debuginfo") -- fd = debuginfod_find_debuginfo (client, -- (const unsigned char*) buildid.c_str(), -- 0, NULL); -- else if (artifacttype == "executable") -- fd = debuginfod_find_executable (client, -- (const unsigned char*) buildid.c_str(), -- 0, NULL); -- else if (artifacttype == "source") -- fd = debuginfod_find_source (client, -- (const unsigned char*) buildid.c_str(), -- 0, suffix.c_str(), NULL); -- else if (artifacttype == "section") -- fd = debuginfod_find_section (client, -- (const unsigned char*) buildid.c_str(), -- 0, section.c_str(), NULL); -- -+ } -+ -+ string xff_complete = string("X-Forwarded-For: ")+xff+string(hostname); -+ debuginfod_add_http_header (client, xff_complete.c_str()); - } -- else -- fd = -errno; /* Set by debuginfod_begin. */ -- debuginfod_pool_end (client); -- -+ -+ if (artifacttype == "debuginfo") -+ fd = debuginfod_find_debuginfo (client, -+ (const unsigned char*) buildid.c_str(), -+ 0, NULL); -+ else if (artifacttype == "executable") -+ fd = debuginfod_find_executable (client, -+ (const unsigned char*) buildid.c_str(), -+ 0, NULL); -+ else if (artifacttype == "source") -+ fd = debuginfod_find_source (client, -+ (const unsigned char*) buildid.c_str(), -+ 0, suffix.c_str(), NULL); -+ else if (artifacttype == "section") -+ fd = debuginfod_find_section (client, -+ (const unsigned char*) buildid.c_str(), -+ 0, section.c_str(), NULL); -+ - if (fd >= 0) - { - if (conn != 0) diff --git a/elfutils-0.188-static-extract_section.patch b/elfutils-0.188-static-extract_section.patch deleted file mode 100644 index 6305b3e15c0f278b8e6899df9a62668f12ac5a9e..0000000000000000000000000000000000000000 --- a/elfutils-0.188-static-extract_section.patch +++ /dev/null @@ -1,24 +0,0 @@ -commit 58a7aa900bc2d9822b0d0cb596ba95a21ff0fd2d -Author: Mark Wielaard -Date: Wed Nov 2 17:54:11 2022 +0100 - - debuginfod: Mark extract_section function static - - The extract_section function in debuginfod-client.c is an internal - function and should not be exported. Mark it as static. - - Signed-off-by: Mark Wielaard - -diff --git a/debuginfod/debuginfod-client.c b/debuginfod/debuginfod-client.c -index 0c4a00cf..f48e32cc 100644 ---- a/debuginfod/debuginfod-client.c -+++ b/debuginfod/debuginfod-client.c -@@ -621,7 +621,7 @@ path_escape (const char *src, char *dest) - section name was not found. -EEXIST indicates that the section was - found but had type SHT_NOBITS. */ - --int -+static int - extract_section (int fd, const char *section, char *fd_path, char **usr_path) - { - elf_version (EV_CURRENT); diff --git a/elfutils-0.189-debuginfod_config_cache-double-close.patch b/elfutils-0.189-debuginfod_config_cache-double-close.patch new file mode 100644 index 0000000000000000000000000000000000000000..3380b71c65c860475a76ff7bdd74f3eef1b6667d --- /dev/null +++ b/elfutils-0.189-debuginfod_config_cache-double-close.patch @@ -0,0 +1,73 @@ +diff --git a/debuginfod/debuginfod-client.c b/debuginfod/debuginfod-client.c +index ef4d47e3..d92d8d62 100644 +--- a/debuginfod/debuginfod-client.c ++++ b/debuginfod/debuginfod-client.c +@@ -248,7 +248,7 @@ debuginfod_write_callback (char *ptr, size_t size, size_t nmemb, void *data) + + /* handle config file read and write */ + static int +-debuginfod_config_cache(char *config_path, ++debuginfod_config_cache(debuginfod_client *c, char *config_path, + long cache_config_default_s, + struct stat *st) + { +@@ -277,17 +277,27 @@ debuginfod_config_cache(char *config_path, + } + + long cache_config; ++ /* PR29696 - NB: When using fdopen, the file descriptor is NOT ++ dup'ed and will be closed when the stream is closed. Manually ++ closing fd after fclose is called will lead to a race condition ++ where, if reused, the file descriptor will compete for its ++ regular use before being incorrectly closed here. */ + FILE *config_file = fdopen(fd, "r"); + if (config_file) + { + if (fscanf(config_file, "%ld", &cache_config) != 1) +- cache_config = cache_config_default_s; +- fclose(config_file); ++ cache_config = cache_config_default_s; ++ if (0 != fclose (config_file) && c->verbose_fd >= 0) ++ dprintf (c->verbose_fd, "fclose failed with %s (err=%d)\n", ++ strerror (errno), errno); + } + else +- cache_config = cache_config_default_s; +- +- close (fd); ++ { ++ cache_config = cache_config_default_s; ++ if (0 != close (fd) && c->verbose_fd >= 0) ++ dprintf (c->verbose_fd, "close failed with %s (err=%d)\n", ++ strerror (errno), errno); ++ } + return cache_config; + } + +@@ -303,7 +313,7 @@ debuginfod_clean_cache(debuginfod_client *c, + struct stat st; + + /* Create new interval file. */ +- rc = debuginfod_config_cache(interval_path, ++ rc = debuginfod_config_cache(c, interval_path, + cache_clean_default_interval_s, &st); + if (rc < 0) + return rc; +@@ -320,7 +330,7 @@ debuginfod_clean_cache(debuginfod_client *c, + utime (interval_path, NULL); + + /* Read max unused age value from config file. */ +- rc = debuginfod_config_cache(max_unused_path, ++ rc = debuginfod_config_cache(c, max_unused_path, + cache_default_max_unused_age_s, &st); + if (rc < 0) + return rc; +@@ -1110,7 +1135,7 @@ debuginfod_query_server (debuginfod_client *c, + + close(fd); /* no need to hold onto the negative-hit file descriptor */ + +- rc = debuginfod_config_cache(cache_miss_path, ++ rc = debuginfod_config_cache(c, cache_miss_path, + cache_miss_default_s, &st); + if (rc < 0) + goto out; diff --git a/elfutils-0.189-elf_getdata_rawchunk.patch b/elfutils-0.189-elf_getdata_rawchunk.patch new file mode 100644 index 0000000000000000000000000000000000000000..7ce6695c6d88e05c2762bdba9341f981e0d1196d --- /dev/null +++ b/elfutils-0.189-elf_getdata_rawchunk.patch @@ -0,0 +1,224 @@ +From 3aca5b5f1f1617db2220022d9061dcaf129e54c4 Mon Sep 17 00:00:00 2001 +From: Mark Wielaard +Date: Wed, 21 Jun 2023 18:05:12 +0200 +Subject: [PATCH] libelf: Replace list of elf_getdata_rawchunk results with a + tree + +elf_getdata_rawchunks did a linear search to see if a chunk was +already fetched. Replace this list with a binary search tree to make +lookup faster when a lot of Elf_Data_Chunk were created. + + * libelf/libelfP.h (Elf_Data_Chunk): Remove next field. + (struct Elf): Change the rawchunks type from Elf_Data_Chunk * + to void *. + * elf_getdata_rawchunk.c (chunk_compare): New static function. + (elf_getdata_rawchunk): Use tsearch instead of a manual linked + list. + * elf_end.c (free_chunk): New static function. + (elf_end): Call tdestroy instead of walking linked list. + +Signed-off-by: Mark Wielaard +--- + libelf/elf_end.c | 22 +++++++++------- + libelf/elf_getdata_rawchunk.c | 47 +++++++++++++++++++++++++---------- + libelf/libelfP.h | 13 ++++------ + 3 files changed, 52 insertions(+), 30 deletions(-) + +diff --git a/libelf/elf_end.c b/libelf/elf_end.c +index 5c451f36..3e5d4c86 100644 +--- a/libelf/elf_end.c ++++ b/libelf/elf_end.c +@@ -1,5 +1,6 @@ + /* Free resources associated with Elf descriptor. + Copyright (C) 1998,1999,2000,2001,2002,2004,2005,2007,2015,2016 Red Hat, Inc. ++ Copyright (C) 2023 Mark J. Wielaard + This file is part of elfutils. + Written by Ulrich Drepper , 1998. + +@@ -32,12 +33,22 @@ + #endif + + #include ++#include + #include + #include + + #include "libelfP.h" + + ++static void ++free_chunk (void *n) ++{ ++ Elf_Data_Chunk *rawchunk = (Elf_Data_Chunk *)n; ++ if (rawchunk->dummy_scn.flags & ELF_F_MALLOCED) ++ free (rawchunk->data.d.d_buf); ++ free (rawchunk); ++} ++ + int + elf_end (Elf *elf) + { +@@ -112,20 +123,13 @@ elf_end (Elf *elf) + + case ELF_K_ELF: + { +- Elf_Data_Chunk *rawchunks ++ void *rawchunks + = (elf->class == ELFCLASS32 + || (offsetof (struct Elf, state.elf32.rawchunks) + == offsetof (struct Elf, state.elf64.rawchunks)) + ? elf->state.elf32.rawchunks + : elf->state.elf64.rawchunks); +- while (rawchunks != NULL) +- { +- Elf_Data_Chunk *next = rawchunks->next; +- if (rawchunks->dummy_scn.flags & ELF_F_MALLOCED) +- free (rawchunks->data.d.d_buf); +- free (rawchunks); +- rawchunks = next; +- } ++ tdestroy (rawchunks, free_chunk); + + Elf_ScnList *list = (elf->class == ELFCLASS32 + || (offsetof (struct Elf, state.elf32.scns) +diff --git a/libelf/elf_getdata_rawchunk.c b/libelf/elf_getdata_rawchunk.c +index 5a35ccdc..cfd40396 100644 +--- a/libelf/elf_getdata_rawchunk.c ++++ b/libelf/elf_getdata_rawchunk.c +@@ -1,6 +1,6 @@ + /* Return converted data from raw chunk of ELF file. + Copyright (C) 2007, 2014, 2015 Red Hat, Inc. +- Copyright (C) 2022 Mark J. Wielaard ++ Copyright (C) 2022, 2023 Mark J. Wielaard + This file is part of elfutils. + + This file is free software; you can redistribute it and/or modify +@@ -33,12 +33,28 @@ + + #include + #include ++#include + #include + #include + + #include "libelfP.h" + #include "common.h" + ++static int ++chunk_compare (const void *a, const void *b) ++{ ++ Elf_Data_Chunk *da = (Elf_Data_Chunk *)a; ++ Elf_Data_Chunk *db = (Elf_Data_Chunk *)b; ++ ++ if (da->offset != db->offset) ++ return da->offset - db->offset; ++ ++ if (da->data.d.d_size != db->data.d.d_size) ++ return da->data.d.d_size - db->data.d.d_size; ++ ++ return da->data.d.d_type - db->data.d.d_type; ++} ++ + Elf_Data * + elf_getdata_rawchunk (Elf *elf, int64_t offset, size_t size, Elf_Type type) + { +@@ -75,19 +91,25 @@ elf_getdata_rawchunk (Elf *elf, int64_t offset, size_t size, Elf_Type type) + rwlock_rdlock (elf->lock); + + /* Maybe we already got this chunk? */ +- Elf_Data_Chunk *rawchunks = elf->state.elf.rawchunks; +- while (rawchunks != NULL) ++ Elf_Data_Chunk key; ++ key.offset = offset; ++ key.data.d.d_size = size; ++ key.data.d.d_type = type; ++ Elf_Data_Chunk **found = tsearch (&key, &elf->state.elf.rawchunks, ++ &chunk_compare); ++ if (found == NULL) ++ goto nomem; ++ ++ /* Existing entry. */ ++ if (*found != &key && *found != NULL) + { +- if ((rawchunks->offset == offset || size == 0) +- && rawchunks->data.d.d_size == size +- && rawchunks->data.d.d_type == type) +- { +- result = &rawchunks->data.d; +- goto out; +- } +- rawchunks = rawchunks->next; ++ result = &(*found)->data.d; ++ goto out; + } + ++ /* New entry. */ ++ *found = NULL; ++ + size_t align = __libelf_type_align (elf->class, type); + if (elf->map_address != NULL) + { +@@ -189,8 +211,7 @@ elf_getdata_rawchunk (Elf *elf, int64_t offset, size_t size, Elf_Type type) + rwlock_unlock (elf->lock); + rwlock_wrlock (elf->lock); + +- chunk->next = elf->state.elf.rawchunks; +- elf->state.elf.rawchunks = chunk; ++ *found = chunk; + result = &chunk->data.d; + + out: +diff --git a/libelf/libelfP.h b/libelf/libelfP.h +index 6624f38a..d3c241e5 100644 +--- a/libelf/libelfP.h ++++ b/libelf/libelfP.h +@@ -1,5 +1,6 @@ + /* Internal interfaces for libelf. + Copyright (C) 1998-2010, 2015, 2016 Red Hat, Inc. ++ Copyright (C) 2023 Mark J. Wielaard + This file is part of elfutils. + Contributed by Ulrich Drepper , 1998. + +@@ -262,11 +263,7 @@ typedef struct Elf_ScnList + typedef struct Elf_Data_Chunk + { + Elf_Data_Scn data; +- union +- { +- Elf_Scn dummy_scn; +- struct Elf_Data_Chunk *next; +- }; ++ Elf_Scn dummy_scn; + int64_t offset; /* The original raw offset in the Elf image. */ + } Elf_Data_Chunk; + +@@ -324,7 +321,7 @@ struct Elf + Elf_ScnList *scns_last; /* Last element in the section list. + If NULL the data has not yet been + read from the file. */ +- Elf_Data_Chunk *rawchunks; /* List of elf_getdata_rawchunk results. */ ++ void *rawchunks; /* Tree of elf_getdata_rawchunk results. */ + unsigned int scnincr; /* Number of sections allocate the last + time. */ + int ehdr_flags; /* Flags (dirty) for ELF header. */ +@@ -343,7 +340,7 @@ struct Elf + Elf_ScnList *scns_last; /* Last element in the section list. + If NULL the data has not yet been + read from the file. */ +- Elf_Data_Chunk *rawchunks; /* List of elf_getdata_rawchunk results. */ ++ void *rawchunks; /* Tree of elf_getdata_rawchunk results. */ + unsigned int scnincr; /* Number of sections allocate the last + time. */ + int ehdr_flags; /* Flags (dirty) for ELF header. */ +@@ -368,7 +365,7 @@ struct Elf + Elf_ScnList *scns_last; /* Last element in the section list. + If NULL the data has not yet been + read from the file. */ +- Elf_Data_Chunk *rawchunks; /* List of elf_getdata_rawchunk results. */ ++ void *rawchunks; /* Tree of elf_getdata_rawchunk results. */ + unsigned int scnincr; /* Number of sections allocate the last + time. */ + int ehdr_flags; /* Flags (dirty) for ELF header. */ +-- +2.40.1 + diff --git a/elfutils-0.189-elfcompress.patch b/elfutils-0.189-elfcompress.patch new file mode 100644 index 0000000000000000000000000000000000000000..5f0d68170b28d0a8f2c1d4f0e10d3e529bd42852 --- /dev/null +++ b/elfutils-0.189-elfcompress.patch @@ -0,0 +1,95 @@ +From ef9164520c81ea61efe88777a8ad61bf17a54201 Mon Sep 17 00:00:00 2001 +From: Mark Wielaard +Date: Sat, 22 Apr 2023 01:26:17 +0200 +Subject: [PATCH] elfcompress: Don't compress if section already compressed + unless forced + +Before commit a5b07cdf9 "support ZSTD compression algorithm" +elfcompress would not try to compress a section if it already +had the requested compression type (or was already uncompressed) +unless the --force flag was given. An else if construct was changed +to an if in the commit causing elfcompress to warn (in verbose mode) +but then still try to (re)compress the section. + +Add an explicit check so if nothing needs (un)compressing, the file +isn't changed. + +The diff looks large, but git diff -b -w is just: + ++ if (force || type != schtype) ++ { + if (shdr->sh_type != SHT_NOBITS + && (shdr->sh_flags & SHF_ALLOC) == 0) + { +@@ -554,6 +556,7 @@ process_file (const char *fname) + printf ("[%zd] %s ignoring %s section\n", ndx, sname, + (shdr->sh_type == SHT_NOBITS ? "no bits" : "allocated")); + } ++ } + +Signed-off-by: Mark Wielaard +--- + src/elfcompress.c | 43 +++++++++++++++++++++++-------------------- + 1 file changed, 23 insertions(+), 20 deletions(-) + +diff --git a/src/elfcompress.c b/src/elfcompress.c +index 18ade66f..f771b92a 100644 +--- a/src/elfcompress.c ++++ b/src/elfcompress.c +@@ -529,30 +529,33 @@ process_file (const char *fname) + } + } + +- if (shdr->sh_type != SHT_NOBITS +- && (shdr->sh_flags & SHF_ALLOC) == 0) ++ if (force || type != schtype) + { +- set_section (sections, ndx); +- /* Check if we might want to change this section name. */ +- if (! adjust_names +- && ((type != ZLIB_GNU +- && startswith (sname, ".zdebug")) +- || (type == ZLIB_GNU +- && startswith (sname, ".debug")))) +- adjust_names = true; +- +- /* We need a buffer this large if we change the names. */ +- if (adjust_names) ++ if (shdr->sh_type != SHT_NOBITS ++ && (shdr->sh_flags & SHF_ALLOC) == 0) + { +- size_t slen = strlen (sname); +- if (slen > maxnamelen) +- maxnamelen = slen; ++ set_section (sections, ndx); ++ /* Check if we might want to change this section name. */ ++ if (! adjust_names ++ && ((type != ZLIB_GNU ++ && startswith (sname, ".zdebug")) ++ || (type == ZLIB_GNU ++ && startswith (sname, ".debug")))) ++ adjust_names = true; ++ ++ /* We need a buffer this large if we change the names. */ ++ if (adjust_names) ++ { ++ size_t slen = strlen (sname); ++ if (slen > maxnamelen) ++ maxnamelen = slen; ++ } + } ++ else ++ if (verbose >= 0) ++ printf ("[%zd] %s ignoring %s section\n", ndx, sname, ++ (shdr->sh_type == SHT_NOBITS ? "no bits" : "allocated")); + } +- else +- if (verbose >= 0) +- printf ("[%zd] %s ignoring %s section\n", ndx, sname, +- (shdr->sh_type == SHT_NOBITS ? "no bits" : "allocated")); + } + + if (shdr->sh_type == SHT_SYMTAB) +-- +2.31.1 + diff --git a/elfutils.spec b/elfutils.spec index 913ab23bff73f69812fd7d98ef004b9ae1066678..3f6cd03aa8da1cece4d727743d66ca07c5d1c45b 100644 --- a/elfutils.spec +++ b/elfutils.spec @@ -1,8 +1,7 @@ -%define anolis_release .0.1 Name: elfutils -Version: 0.188 +Version: 0.189 %global baserelease 3 -Release: %{baserelease}%{anolis_release}%{?dist} +Release: %{baserelease}%{?dist} URL: http://elfutils.org/ %global source_url ftp://sourceware.org/pub/elfutils/%{version}/ License: GPLv3+ and (GPLv2+ or LGPLv3+) and GFDL @@ -66,14 +65,12 @@ BuildRequires: gettext-devel # Patches -# Don't export internal function. -Patch1: elfutils-0.188-static-extract_section.patch -# Silence some compiler warnings -Patch2: elfutils-0.188-compile-warnings.patch -# The debuginfod_client object lifetime needs more careful handling -Patch3: elfutils-0.188-debuginfod-client-lifetime.patch -Patch1000: 1000-arch-support-loongarch64-platform.patch -Patch1001: 1001-backends-add-loongarch-support.patch +# elfcompress: Don't compress if section already compressed unless forced +Patch1: elfutils-0.189-elfcompress.patch +# libelf: Replace list of elf_getdata_rawchunk results with a tree +Patch2: elfutils-0.189-elf_getdata_rawchunk.patch +# PR29696: Removed secondary fd close in cache config causing race condition +Patch3: elfutils-0.189-debuginfod_config_cache-double-close.patch %description Elfutils is a collection of utilities, including stack (to show @@ -287,9 +284,9 @@ RPM_OPT_FLAGS="${RPM_OPT_FLAGS} -Wformat" trap 'cat config.log' EXIT %if 0%{?centos} >= 8 -%configure CFLAGS="$RPM_OPT_FLAGS -fexceptions" --enable-debuginfod-urls=https://debuginfod.centos.org/ +%configure CFLAGS="$RPM_OPT_FLAGS" --enable-debuginfod-urls=https://debuginfod.centos.org/ %else -%configure CFLAGS="$RPM_OPT_FLAGS -fexceptions" +%configure CFLAGS="$RPM_OPT_FLAGS" %endif trap '' EXIT %make_build @@ -464,8 +461,15 @@ exit 0 %systemd_postun_with_restart debuginfod.service %changelog -* Tue Jul 04 2023 Liwei Ge - 0.188-3.0.1 -- Support loongarch64 platform +* Wed Jun 28 2023 Mark Wielaard - 0.189-3 +- Add elfutils-0.189-elf_getdata_rawchunk.patch +- Add elfutils-0.189-debuginfod_config_cache-double-close.patch + +* Mon Apr 24 2023 Mark Wielaard - 0.189-2 +- Add elfutils-0.189-elfcompress.patch + +* Tue Apr 4 2023 Mark Wielaard - 0.189-1 +- Upgrade to upsteam elfutils 0.189. * Mon Nov 7 2022 Mark Wielaard - 0.188-3 - Add elfutils-0.188-compile-warnings.patch