diff --git a/1000-arch-support-loongarch64-platform.patch b/1000-arch-support-loongarch64-platform.patch index ba22b3de6e435b82e4ac81247266e24cec2c85ae..5ffada9264860a105df7ca0dcbcd7b061d4ed292 100644 --- a/1000-arch-support-loongarch64-platform.patch +++ b/1000-arch-support-loongarch64-platform.patch @@ -1,120 +1,8 @@ -From 4b04fbef561c02ee9a7f3a868f0c8a544bce3bf0 Mon Sep 17 00:00:00 2001 -From: Liwei Ge -Date: Fri, 9 Sep 2022 17:08:06 +0800 -Subject: [PATCH 1000/1001] arch: support loongarch64 platform - ---- - libdwelf/dwelf_elf_e_machine_string.c | 3 +- - libelf/elf.h | 68 ++++++++++++++++++++++++++- - src/elflint.c | 2 +- - 3 files changed, 70 insertions(+), 3 deletions(-) - -diff --git a/libdwelf/dwelf_elf_e_machine_string.c b/libdwelf/dwelf_elf_e_machine_string.c -index 387648e..21f2756 100644 ---- a/libdwelf/dwelf_elf_e_machine_string.c -+++ b/libdwelf/dwelf_elf_e_machine_string.c -@@ -396,7 +396,8 @@ dwelf_elf_e_machine_string (int machine) - return "BPF"; - case EM_CSKY: - return "C-SKY"; -- -+ case EM_LOONGARCH: -+ return "LoongArch"; - case EM_ALPHA: - return "Alpha"; - -diff --git a/libelf/elf.h b/libelf/elf.h -index 8e3e618..30bdda8 100644 ---- a/libelf/elf.h -+++ b/libelf/elf.h -@@ -357,8 +357,9 @@ typedef struct - - #define EM_BPF 247 /* Linux BPF -- in-kernel virtual machine */ - #define EM_CSKY 252 /* C-SKY */ -+#define EM_LOONGARCH 258 /* LoongArch */ - --#define EM_NUM 253 -+#define EM_NUM 259 - - /* Old spellings/synonyms. */ - -@@ -4034,6 +4035,71 @@ enum - #define R_NDS32_TLS_TPOFF 102 - #define R_NDS32_TLS_DESC 119 - -+/* LoongArch ELF Flags */ -+#define EF_LARCH_ABI 0x07 -+#define EF_LARCH_ABI_LP64D 0x03 -+ -+/* LoongArch specific dynamic relocations */ -+#define R_LARCH_NONE 0 -+#define R_LARCH_32 1 -+#define R_LARCH_64 2 -+#define R_LARCH_RELATIVE 3 -+#define R_LARCH_COPY 4 -+#define R_LARCH_JUMP_SLOT 5 -+#define R_LARCH_TLS_DTPMOD32 6 -+#define R_LARCH_TLS_DTPMOD64 7 -+#define R_LARCH_TLS_DTPREL32 8 -+#define R_LARCH_TLS_DTPREL64 9 -+#define R_LARCH_TLS_TPREL32 10 -+#define R_LARCH_TLS_TPREL64 11 -+#define R_LARCH_IRELATIVE 12 -+ -+/* Reserved for future relocs that the dynamic linker must understand. */ -+ -+/* used by the static linker for relocating .text. */ -+#define R_LARCH_MARK_LA 20 -+#define R_LARCH_MARK_PCREL 21 -+#define R_LARCH_SOP_PUSH_PCREL 22 -+#define R_LARCH_SOP_PUSH_ABSOLUTE 23 -+#define R_LARCH_SOP_PUSH_DUP 24 -+#define R_LARCH_SOP_PUSH_GPREL 25 -+#define R_LARCH_SOP_PUSH_TLS_TPREL 26 -+#define R_LARCH_SOP_PUSH_TLS_GOT 27 -+#define R_LARCH_SOP_PUSH_TLS_GD 28 -+#define R_LARCH_SOP_PUSH_PLT_PCREL 29 -+#define R_LARCH_SOP_ASSERT 30 -+#define R_LARCH_SOP_NOT 31 -+#define R_LARCH_SOP_SUB 32 -+#define R_LARCH_SOP_SL 33 -+#define R_LARCH_SOP_SR 34 -+#define R_LARCH_SOP_ADD 35 -+#define R_LARCH_SOP_AND 36 -+#define R_LARCH_SOP_IF_ELSE 37 -+#define R_LARCH_SOP_POP_32_S_10_5 38 -+#define R_LARCH_SOP_POP_32_U_10_12 39 -+#define R_LARCH_SOP_POP_32_S_10_12 40 -+#define R_LARCH_SOP_POP_32_S_10_16 41 -+#define R_LARCH_SOP_POP_32_S_10_16_S2 42 -+#define R_LARCH_SOP_POP_32_S_5_20 43 -+#define R_LARCH_SOP_POP_32_S_0_5_10_16_S2 44 -+#define R_LARCH_SOP_POP_32_S_0_10_10_16_S2 45 -+#define R_LARCH_SOP_POP_32_U 46 -+ -+/* used by the static linker for relocating non .text. */ -+#define R_LARCH_ADD8 47 -+#define R_LARCH_ADD16 48 -+#define R_LARCH_ADD24 49 -+#define R_LARCH_ADD32 50 -+#define R_LARCH_ADD64 51 -+#define R_LARCH_SUB8 52 -+#define R_LARCH_SUB16 53 -+#define R_LARCH_SUB24 54 -+#define R_LARCH_SUB32 55 -+#define R_LARCH_SUB64 56 -+#define R_LARCH_GNU_VTINHERIT 57 -+#define R_LARCH_GNU_VTENTRY 58 -+ -+ - /* ARCompact/ARCv2 specific relocs. */ - #define R_ARC_NONE 0x0 - #define R_ARC_8 0x1 diff --git a/src/elflint.c b/src/elflint.c -index ef7725c..e5f64cf 100644 +index 565cffd..a23d6e6 100644 --- a/src/elflint.c +++ b/src/elflint.c -@@ -330,7 +330,7 @@ static const int valid_e_machine[] = +@@ -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, @@ -123,6 +11,3 @@ index ef7725c..e5f64cf 100644 }; #define nvalid_e_machine \ (sizeof (valid_e_machine) / sizeof (valid_e_machine[0])) --- -2.27.0 - diff --git a/1001-backends-add-loongarch-support.patch b/1001-backends-add-loongarch-support.patch index 5b41acd24a913aec58a609ad282d49c1e3769994..89ede5b23eca9c167594a367739443d2edb12f94 100644 --- a/1001-backends-add-loongarch-support.patch +++ b/1001-backends-add-loongarch-support.patch @@ -38,9 +38,9 @@ index 62916c9..9cb45c0 100644 i386_SRCS = i386_init.c i386_symbol.c i386_corenote.c i386_cfi.c \ i386_retval.c i386_regs.c i386_auxv.c \ -@@ -58,6 +58,10 @@ alpha_SRCS = alpha_init.c alpha_symbol.c alpha_retval.c alpha_regs.c \ - 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 +@@ -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 \ @@ -49,7 +49,7 @@ index 62916c9..9cb45c0 100644 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 -@@ -98,7 +102,7 @@ csky_SRCS = csky_attrs.c csky_init.c csky_symbol.c csky_cfi.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) \ @@ -80,19 +80,19 @@ index 7028fb0..e115b9a 100644 libebl_backends_a_OBJECTS = $(am_libebl_backends_a_OBJECTS) libebl_backends_pic_a_AR = $(AR) $(ARFLAGS) libebl_backends_pic_a_LIBADD = -@@ -207,6 +211,10 @@ am__depfiles_remade = ./$(DEPDIR)/aarch64_cfi.Po \ - ./$(DEPDIR)/arm_corenote.Po ./$(DEPDIR)/arm_init.Po \ - ./$(DEPDIR)/arm_initreg.Po ./$(DEPDIR)/arm_regs.Po \ - ./$(DEPDIR)/arm_retval.Po ./$(DEPDIR)/arm_symbol.Po \ +@@ -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_init.Po ./$(DEPDIR)/bpf_regs.Po \ - ./$(DEPDIR)/bpf_symbol.Po ./$(DEPDIR)/csky_attrs.Po \ - ./$(DEPDIR)/csky_cfi.Po ./$(DEPDIR)/csky_corenote.Po \ -@@ -518,7 +526,7 @@ textrel_msg = echo "WARNING: TEXTREL found in '$@'" - textrel_check = if $(READELF) -d $@ | fgrep -q TEXTREL; then $(textrel_found); fi + ./$(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 @@ -100,9 +100,9 @@ index 7028fb0..e115b9a 100644 i386_SRCS = i386_init.c i386_symbol.c i386_corenote.c i386_cfi.c \ i386_retval.c i386_regs.c i386_auxv.c \ -@@ -536,6 +544,10 @@ alpha_SRCS = alpha_init.c alpha_symbol.c alpha_retval.c alpha_regs.c \ - 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 +@@ -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 \ @@ -111,16 +111,16 @@ index 7028fb0..e115b9a 100644 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 -@@ -575,7 +587,7 @@ csky_SRCS = csky_attrs.c csky_init.c csky_symbol.c csky_cfi.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)\ ++ $(ppc64_SRCS) $(s390_SRCS) $(loongarch_SRCS) \ $(m68k_SRCS) $(bpf_SRCS) $(riscv_SRCS) $(csky_SRCS) libebl_backends_pic_a_SOURCES = -@@ -660,6 +672,13 @@ distclean-compile: +@@ -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 @@ -134,7 +134,7 @@ index 7028fb0..e115b9a 100644 @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 -@@ -916,6 +935,13 @@ distclean: distclean-am +@@ -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 @@ -148,7 +148,7 @@ index 7028fb0..e115b9a 100644 -rm -f ./$(DEPDIR)/bpf_init.Po -rm -f ./$(DEPDIR)/bpf_regs.Po -rm -f ./$(DEPDIR)/bpf_symbol.Po -@@ -1070,6 +1096,13 @@ maintainer-clean: maintainer-clean-am +@@ -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 diff --git a/download b/download index c3faabfff1aee4d5609eaad26c4ec1574aa890d7..3ea225322b2201d5f29add00a411759ac1a55877 100644 --- a/download +++ b/download @@ -1 +1 @@ -cc04f07b53a71616b22553c0a458cf4b elfutils-0.187.tar.bz2 +efb25a91873b2eec4df9f31e6a4f4e5c elfutils-0.188.tar.bz2 diff --git a/elfutils-0.187-csh-profile.patch b/elfutils-0.187-csh-profile.patch deleted file mode 100644 index 6f26815b2e56050dff799a0f1b65a06ab878e987..0000000000000000000000000000000000000000 --- a/elfutils-0.187-csh-profile.patch +++ /dev/null @@ -1,28 +0,0 @@ -commit f1252e4dbe781f75d806ce0b990779548eeeb7a9 -Author: Mark Wielaard -Date: Tue May 3 17:48:55 2022 +0200 - - config: Move the 2>/dev/null inside the sh -c '' quotes for profile.csh. - - csh/tcsh would warn about "Ambiguous output redirect" if not done inside - the sh -c command. - - Fix-by: наб - - https://bugzilla.redhat.com/show_bug.cgi?id=2080957 - - Signed-off-by: Mark Wielaard - -diff --git a/config/profile.csh.in b/config/profile.csh.in -index 012e243a..74c20c99 100644 ---- a/config/profile.csh.in -+++ b/config/profile.csh.in -@@ -6,7 +6,7 @@ - - if (! $?DEBUGINFOD_URLS) then - set prefix="@prefix@" -- set DEBUGINFOD_URLS=`sh -c 'cat "$0"/*.urls; :' "@sysconfdir@/debuginfod" 2>/dev/null | tr '\n' ' '` -+ set DEBUGINFOD_URLS=`sh -c 'cat "$0"/*.urls 2>/dev/null; :' "@sysconfdir@/debuginfod" | tr '\n' ' '` - if ( "$DEBUGINFOD_URLS" != "" ) then - setenv DEBUGINFOD_URLS "$DEBUGINFOD_URLS" - else diff --git a/elfutils-0.187-debuginfod-client-fd-leak.patch b/elfutils-0.187-debuginfod-client-fd-leak.patch deleted file mode 100644 index 2f6b78be023b1285878aae24b7e71d98a54f0717..0000000000000000000000000000000000000000 --- a/elfutils-0.187-debuginfod-client-fd-leak.patch +++ /dev/null @@ -1,98 +0,0 @@ -commit 59158656f3b0b99d8784ddc82c15778813000edc -Author: Frank Ch. Eigler -Date: Wed May 4 10:26:42 2022 -0400 - - PR29117: fix fd leak in debuginfod client for cache-miss files - - Correct a nasty fd leak and a few less nasty leaks in the debuginfod - client code. The nasty one impacts long-lived apps such as debuginfod - servers. - - Signed-off-by: Mark Wielaard - Signed-off-by: Frank Ch. Eigler - -diff --git a/debuginfod/debuginfod-client.c b/debuginfod/debuginfod-client.c -index ea6e461a..521972e4 100644 ---- a/debuginfod/debuginfod-client.c -+++ b/debuginfod/debuginfod-client.c -@@ -243,7 +243,13 @@ debuginfod_config_cache(char *config_path, - return -errno; - - if (dprintf(fd, "%ld", cache_config_default_s) < 0) -- return -errno; -+ { -+ int ret = -errno; -+ close (fd); -+ return ret; -+ } -+ -+ close (fd); - } - - long cache_config; -@@ -284,7 +290,13 @@ debuginfod_init_cache (char *cache_path, char *interval_path, char *maxage_path) - return -errno; - - if (dprintf(fd, "%ld", cache_clean_default_interval_s) < 0) -- return -errno; -+ { -+ int ret = -errno; -+ close (fd); -+ return ret; -+ } -+ -+ close (fd); - - /* init max age config file. */ - if (stat(maxage_path, &st) != 0 -@@ -292,8 +304,13 @@ debuginfod_init_cache (char *cache_path, char *interval_path, char *maxage_path) - return -errno; - - if (dprintf(fd, "%ld", cache_default_max_unused_age_s) < 0) -- return -errno; -+ { -+ int ret = -errno; -+ close (fd); -+ return ret; -+ } - -+ close (fd); - return 0; - } - -@@ -812,18 +829,17 @@ debuginfod_query_server (debuginfod_client *c, - has passed since the last attempt. */ - time_t cache_miss; - time_t target_mtime = st.st_mtime; -+ -+ close(fd); /* no need to hold onto the negative-hit file descriptor */ -+ - rc = debuginfod_config_cache(cache_miss_path, - cache_miss_default_s, &st); - if (rc < 0) -- { -- close(fd); -- goto out; -- } -+ goto out; - - cache_miss = (time_t)rc; - if (time(NULL) - target_mtime <= cache_miss) - { -- close(fd); - rc = -ENOENT; - goto out; - } -diff --git a/debuginfod/debuginfod-find.c b/debuginfod/debuginfod-find.c -index 3e8ab203..f60b5463 100644 ---- a/debuginfod/debuginfod-find.c -+++ b/debuginfod/debuginfod-find.c -@@ -231,6 +231,8 @@ main(int argc, char** argv) - fprintf(stderr, "Server query failed: %s\n", strerror(-rc)); - return 1; - } -+ else -+ close (rc); - - printf("%s\n", cache_name); - free (cache_name); diff --git a/elfutils-0.187-mhd_epoll.patch b/elfutils-0.187-mhd_epoll.patch deleted file mode 100644 index fbbbdac7f2f0df723e8195940b6a68329f609818..0000000000000000000000000000000000000000 --- a/elfutils-0.187-mhd_epoll.patch +++ /dev/null @@ -1,51 +0,0 @@ -commit 28f9d86ea89f88b24f1d12c8e9d5ddc3f77da194 -Author: Mark Wielaard -Date: Fri May 6 00:29:28 2022 +0200 - - debuginfod: Use MHD_USE_EPOLL for libmicrohttpd version 0.9.51 or higher - - Also disable MHD_USE_THREAD_PER_CONNECTION when using MHD_USE_EPOLL. - - https://sourceware.org/bugzilla/show_bug.cgi?id=29123 - - Signed-off-by: Mark Wielaard - -diff --git a/debuginfod/debuginfod.cxx b/debuginfod/debuginfod.cxx -index c02540f1..d4f47bf7 100644 ---- a/debuginfod/debuginfod.cxx -+++ b/debuginfod/debuginfod.cxx -@@ -1,6 +1,6 @@ - /* Debuginfo-over-http server. - Copyright (C) 2019-2021 Red Hat, Inc. -- Copyright (C) 2021 Mark J. Wielaard -+ Copyright (C) 2021, 2022 Mark J. Wielaard - This file is part of elfutils. - - This file is free software; you can redistribute it and/or modify -@@ -3899,7 +3899,14 @@ main (int argc, char *argv[]) - } - } - -- unsigned int mhd_flags = ((connection_pool -+ /* Note that MHD_USE_EPOLL and MHD_USE_THREAD_PER_CONNECTION don't -+ work together. */ -+ unsigned int use_epoll = 0; -+#if MHD_VERSION >= 0x00095100 -+ use_epoll = MHD_USE_EPOLL; -+#endif -+ -+ unsigned int mhd_flags = ((connection_pool || use_epoll - ? 0 : MHD_USE_THREAD_PER_CONNECTION) - #if MHD_VERSION >= 0x00095300 - | MHD_USE_INTERNAL_POLLING_THREAD -@@ -3907,9 +3914,7 @@ main (int argc, char *argv[]) - | MHD_USE_SELECT_INTERNALLY - #endif - | MHD_USE_DUAL_STACK --#ifdef MHD_USE_EPOLL -- | MHD_USE_EPOLL --#endif -+ | use_epoll - #if MHD_VERSION >= 0x00095200 - | MHD_USE_ITC - #endif diff --git a/elfutils-0.187-mhd_no_dual_stack.patch b/elfutils-0.187-mhd_no_dual_stack.patch deleted file mode 100644 index 3f38e36d6205d078ebb81f4682238ebfcbfdf6ae..0000000000000000000000000000000000000000 --- a/elfutils-0.187-mhd_no_dual_stack.patch +++ /dev/null @@ -1,118 +0,0 @@ -commit ba675ed25a26fd425ffd19b02cf18babf4291b4f -Author: Mark Wielaard -Date: Thu May 5 23:59:57 2022 +0200 - - debuginfod: Try without MHD_USE_DUAL_STACK if MHD_start_daemon fails - - On a systems that have ipv6 disabled debuginfod doesn't start up - anymore because libhttpd MHD_USE_DUAL_STACK only works if it can - open an ipv6 socket. If MHD_start_daemon with MHD_USE_DUAL_STACK - fails try again without that flag set. - - https://sourceware.org/bugzilla/show_bug.cgi?id=29122 - - Signed-off-by: Mark Wielaard - -diff --git a/debuginfod/debuginfod.cxx b/debuginfod/debuginfod.cxx -index 4aaf41c0..c02540f1 100644 ---- a/debuginfod/debuginfod.cxx -+++ b/debuginfod/debuginfod.cxx -@@ -3899,40 +3899,67 @@ main (int argc, char *argv[]) - } - } - -- // Start httpd server threads. Use a single dual-homed pool. -- MHD_Daemon *d46 = MHD_start_daemon ((connection_pool ? 0 : MHD_USE_THREAD_PER_CONNECTION) -+ unsigned int mhd_flags = ((connection_pool -+ ? 0 : MHD_USE_THREAD_PER_CONNECTION) - #if MHD_VERSION >= 0x00095300 -- | MHD_USE_INTERNAL_POLLING_THREAD -+ | MHD_USE_INTERNAL_POLLING_THREAD - #else -- | MHD_USE_SELECT_INTERNALLY -+ | MHD_USE_SELECT_INTERNALLY - #endif -+ | MHD_USE_DUAL_STACK - #ifdef MHD_USE_EPOLL -- | MHD_USE_EPOLL -+ | MHD_USE_EPOLL - #endif -- | MHD_USE_DUAL_STACK - #if MHD_VERSION >= 0x00095200 -- | MHD_USE_ITC -+ | MHD_USE_ITC - #endif -- | MHD_USE_DEBUG, /* report errors to stderr */ -- http_port, -- NULL, NULL, /* default accept policy */ -- handler_cb, NULL, /* handler callback */ -- MHD_OPTION_EXTERNAL_LOGGER, error_cb, NULL, -- (connection_pool ? MHD_OPTION_THREAD_POOL_SIZE : MHD_OPTION_END), -- (connection_pool ? (int)connection_pool : MHD_OPTION_END), -- MHD_OPTION_END); -+ | MHD_USE_DEBUG); /* report errors to stderr */ - -+ // Start httpd server threads. Use a single dual-homed pool. -+ MHD_Daemon *d46 = MHD_start_daemon (mhd_flags, http_port, -+ NULL, NULL, /* default accept policy */ -+ handler_cb, NULL, /* handler callback */ -+ MHD_OPTION_EXTERNAL_LOGGER, -+ error_cb, NULL, -+ (connection_pool -+ ? MHD_OPTION_THREAD_POOL_SIZE -+ : MHD_OPTION_END), -+ (connection_pool -+ ? (int)connection_pool -+ : MHD_OPTION_END), -+ MHD_OPTION_END); -+ -+ MHD_Daemon *d4 = NULL; - if (d46 == NULL) - { -- sqlite3 *database = db; -- sqlite3 *databaseq = dbq; -- db = dbq = 0; // for signal_handler not to freak -- sqlite3_close (databaseq); -- sqlite3_close (database); -- error (EXIT_FAILURE, 0, "cannot start http server at port %d", http_port); -- } -+ // Cannot use dual_stack, use ipv4 only -+ mhd_flags &= ~(MHD_USE_DUAL_STACK); -+ d4 = MHD_start_daemon (mhd_flags, http_port, -+ NULL, NULL, /* default accept policy */ -+ handler_cb, NULL, /* handler callback */ -+ MHD_OPTION_EXTERNAL_LOGGER, -+ error_cb, NULL, -+ (connection_pool -+ ? MHD_OPTION_THREAD_POOL_SIZE -+ : MHD_OPTION_END), -+ (connection_pool -+ ? (int)connection_pool -+ : MHD_OPTION_END), -+ MHD_OPTION_END); -+ if (d4 == NULL) -+ { -+ sqlite3 *database = db; -+ sqlite3 *databaseq = dbq; -+ db = dbq = 0; // for signal_handler not to freak -+ sqlite3_close (databaseq); -+ sqlite3_close (database); -+ error (EXIT_FAILURE, 0, "cannot start http server at port %d", -+ http_port); -+ } - -- obatched(clog) << "started http server on IPv4 IPv6 " -+ } -+ obatched(clog) << "started http server on" -+ << (d4 != NULL ? " IPv4 " : " IPv4 IPv6 ") - << "port=" << http_port << endl; - - // add maxigroom sql if -G given -@@ -4053,6 +4080,7 @@ main (int argc, char *argv[]) - - /* Stop all the web service threads. */ - if (d46) MHD_stop_daemon (d46); -+ if (d4) MHD_stop_daemon (d4); - - if (! passive_p) - { diff --git a/elfutils-0.188-compile-warnings.patch b/elfutils-0.188-compile-warnings.patch new file mode 100644 index 0000000000000000000000000000000000000000..397583fa122727c2fc7ee6f5c64e25422fcae353 --- /dev/null +++ b/elfutils-0.188-compile-warnings.patch @@ -0,0 +1,109 @@ +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 new file mode 100644 index 0000000000000000000000000000000000000000..4c8f735a874839f6e088da66fd6ebd8416fe3c73 --- /dev/null +++ b/elfutils-0.188-debuginfod-client-lifetime.patch @@ -0,0 +1,171 @@ +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 new file mode 100644 index 0000000000000000000000000000000000000000..6305b3e15c0f278b8e6899df9a62668f12ac5a9e --- /dev/null +++ b/elfutils-0.188-static-extract_section.patch @@ -0,0 +1,24 @@ +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.spec b/elfutils.spec index 6e4d086d782b3c5d876f3b6baa59eb0720045716..913ab23bff73f69812fd7d98ef004b9ae1066678 100644 --- a/elfutils.spec +++ b/elfutils.spec @@ -1,7 +1,7 @@ %define anolis_release .0.1 Name: elfutils -Version: 0.187 -%global baserelease 4 +Version: 0.188 +%global baserelease 3 Release: %{baserelease}%{anolis_release}%{?dist} URL: http://elfutils.org/ %global source_url ftp://sourceware.org/pub/elfutils/%{version}/ @@ -48,6 +48,8 @@ BuildRequires: iproute BuildRequires: procps BuildRequires: bsdtar BuildRequires: curl +# For run-debuginfod-response-headers.sh test case +BuildRequires: socat BuildRequires: automake BuildRequires: autoconf @@ -63,14 +65,13 @@ BuildRequires: gettext-devel %endif # Patches -# https://bugzilla.redhat.com/show_bug.cgi?id=2080957 -Patch1: elfutils-0.187-csh-profile.patch -# https://sourceware.org/bugzilla/show_bug.cgi?id=29117 -Patch2: elfutils-0.187-debuginfod-client-fd-leak.patch -# https://sourceware.org/bugzilla/show_bug.cgi?id=29122 -Patch3: elfutils-0.187-mhd_no_dual_stack.patch -# https://sourceware.org/bugzilla/show_bug.cgi?id=29123 -Patch4: elfutils-0.187-mhd_epoll.patch + +# 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 @@ -442,8 +443,9 @@ fi %{_bindir}/debuginfod %config(noreplace) %{_sysconfdir}/sysconfig/debuginfod %{_unitdir}/debuginfod.service -%{_sysconfdir}/sysconfig/debuginfod -%{_mandir}/man8/debuginfod.8* +%{_mandir}/man8/debuginfod*.8* +%{_mandir}/man7/debuginfod*.7* + %dir %attr(0700,debuginfod,debuginfod) %{_localstatedir}/cache/debuginfod %ghost %attr(0600,debuginfod,debuginfod) %{_localstatedir}/cache/debuginfod/debuginfod.sqlite @@ -462,9 +464,17 @@ exit 0 %systemd_postun_with_restart debuginfod.service %changelog -* Thu Dec 29 2022 Liwei Ge - 0.187-4.0.1 +* Tue Jul 04 2023 Liwei Ge - 0.188-3.0.1 - Support loongarch64 platform +* Mon Nov 7 2022 Mark Wielaard - 0.188-3 +- Add elfutils-0.188-compile-warnings.patch +- Add elfutils-0.188-debuginfod-client-lifetime.patch + +* Wed Nov 2 2022 Mark Wielaard - 0.188-1 +- Upgrade to upsteam elfutils 0.188. +- Add elfutils-0.188-static-extract_section.patch. + * Fri May 6 2022 Mark Wielaard - 0.187-4 - Upgrade to elfutils 0.187 - debuginfod: Support -C option for connection thread pooling.