-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This prevents a symbol with multiple unhidden verisons, and fixes .Net runtime library loading issue. Fixes #5
- Loading branch information
1 parent
87e712c
commit ac32bbf
Showing
3 changed files
with
13 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <[email protected]> | ||
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<ElfFileParamNames>::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<ElfFileParamNames>::modifyExecstack(ExecstackMode op) | ||
@@ -2320,6 +2343,269 @@ void ElfFile<ElfFileParamNames>::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<ElfFileParams> | ||
template<class StrIdxCallback> | ||
void ElfFile<ElfFileParamNames>::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<class ElfFile> | ||
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; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters