From ac32bbf5aca5280423b03930518bc68cab5c2237 Mon Sep 17 00:00:00 2001 From: Miao Wang Date: Mon, 15 Jan 2024 05:48:16 +0800 Subject: [PATCH] Import patchelf fixes This prevents a symbol with multiple unhidden verisons, and fixes .Net runtime library loading issue. Fixes #5 --- .../patchelf/0001-add-remap-symvers.patch | 21 ++++++++++--------- spec | 2 +- spec.main | 2 +- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/autobuild/patches/patchelf/0001-add-remap-symvers.patch b/autobuild/patches/patchelf/0001-add-remap-symvers.patch index 5cbd162..2c29bf8 100644 --- a/autobuild/patches/patchelf/0001-add-remap-symvers.patch +++ b/autobuild/patches/patchelf/0001-add-remap-symvers.patch @@ -1,13 +1,13 @@ -From 93eab40fdbaca0de3df82908ea2bf2ffb1f594f7 Mon Sep 17 00:00:00 2001 +From c40257c9b5a241c80a30fb423b6b80a95a355c3e Mon Sep 17 00:00:00 2001 From: Miao Wang Date: Fri, 12 Jan 2024 16:56:07 +0800 Subject: [PATCH] add remap-symvers --- src/elf.h | 2 + - src/patchelf.cc | 338 +++++++++++++++++++++++++++++++++++++++++++++++- + src/patchelf.cc | 339 +++++++++++++++++++++++++++++++++++++++++++++++- src/patchelf.h | 6 +- - 3 files changed, 341 insertions(+), 5 deletions(-) + 3 files changed, 342 insertions(+), 5 deletions(-) diff --git a/src/elf.h b/src/elf.h index 920e689..669fd2d 100644 @@ -23,7 +23,7 @@ index 920e689..669fd2d 100644 /* The ELF file header. This appears at the start of every ELF file. */ diff --git a/src/patchelf.cc b/src/patchelf.cc -index 82b4b46..9cf23e4 100644 +index 82b4b46..0b5f5d6 100644 --- a/src/patchelf.cc +++ b/src/patchelf.cc @@ -1234,8 +1234,14 @@ void ElfFile::rewriteHeaders(Elf_Addr phdrAddress) @@ -97,7 +97,7 @@ index 82b4b46..9cf23e4 100644 std::fill(ht.m_buckets.begin(), ht.m_buckets.end(), 0); std::fill(ht.m_chain.begin(), ht.m_chain.end(), 0); -@@ -2320,6 +2343,268 @@ void ElfFile::modifyExecstack(ExecstackMode op) +@@ -2320,6 +2343,269 @@ void ElfFile::modifyExecstack(ExecstackMode op) printf("execstack: %c\n", result); } @@ -337,7 +337,8 @@ index 82b4b46..9cf23e4 100644 + auto sym = it->second; + debug("Adding %s@%s to dynsym list\n", it->first.c_str(), mapTo.c_str()); + newDynsymSpan[i] = dynsyms[sym]; -+ wri(newVersymSpan[i], map_to_ndx); ++ bool is_hidden = rdi(newVersymSpan[sym]) & VERSYM_HIDDEN; ++ wri(newVersymSpan[i], map_to_ndx | (is_hidden ? VERSYM_HIDDEN : 0)); + wri(newVersymSpan[sym], rdi(newVersymSpan[sym]) | VERSYM_HIDDEN); + i += 1; + } @@ -366,7 +367,7 @@ index 82b4b46..9cf23e4 100644 template template void ElfFile::forAllStringReferences(const Elf_Shdr& strTabHdr, StrIdxCallback&& fn) -@@ -2384,6 +2669,10 @@ static bool noDefaultLib = false; +@@ -2384,6 +2670,10 @@ static bool noDefaultLib = false; static bool printExecstack = false; static bool clearExecstack = false; static bool setExecstack = false; @@ -377,7 +378,7 @@ index 82b4b46..9cf23e4 100644 template static void patchElf2(ElfFile && elfFile, const FileContents & fileContents, const std::string & fileName) -@@ -2441,6 +2730,9 @@ static void patchElf2(ElfFile && elfFile, const FileContents & fileContents, con +@@ -2441,6 +2731,9 @@ static void patchElf2(ElfFile && elfFile, const FileContents & fileContents, con if (renameDynamicSymbols) elfFile.renameDynamicSymbols(symbolsToRename); @@ -387,7 +388,7 @@ index 82b4b46..9cf23e4 100644 if (elfFile.isChanged()){ writeFile(fileName, elfFile.fileContents); } else if (alwaysWrite) { -@@ -2505,6 +2797,8 @@ static void showHelp(const std::string & progName) +@@ -2505,6 +2798,8 @@ static void showHelp(const std::string & progName) [--clear-execstack]\n\ [--set-execstack]\n\ [--rename-dynamic-symbols NAME_MAP_FILE]\tRenames dynamic symbols. The map file should contain two symbols (old_name new_name) per line\n\ @@ -396,7 +397,7 @@ index 82b4b46..9cf23e4 100644 [--output FILE]\n\ [--debug]\n\ [--version]\n\ -@@ -2661,6 +2955,44 @@ static int mainWrapped(int argc, char * * argv) +@@ -2661,6 +2956,44 @@ static int mainWrapped(int argc, char * * argv) symbolsToRename[*symbolsToRenameKeys.insert(from).first] = to; } } diff --git a/spec b/spec index 3ed9e13..34cdfed 100644 --- a/spec +++ b/spec @@ -1,6 +1,6 @@ # AUTOGENERATED FILE from spec.main using genspec VER=0.1.1 -REL=0~pre1 +REL=0~pre2 _mirror="http://pkg.loongnix.cn/loongnix" ### For pkgs from outside loongnix repo diff --git a/spec.main b/spec.main index da988c1..270faf2 100644 --- a/spec.main +++ b/spec.main @@ -1,5 +1,5 @@ VER=0.1.1 -REL=0~pre1 +REL=0~pre2 _mirror="http://pkg.loongnix.cn/loongnix" ### For pkgs from outside loongnix repo