summaryrefslogtreecommitdiff
path: root/ELF/Symbols.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ELF/Symbols.cpp')
-rw-r--r--ELF/Symbols.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/ELF/Symbols.cpp b/ELF/Symbols.cpp
index 5dce71a32c9c..e8cd662c69ac 100644
--- a/ELF/Symbols.cpp
+++ b/ELF/Symbols.cpp
@@ -159,6 +159,21 @@ bool SymbolBody::isPreemptible() const {
return true;
}
+// Overwrites all attributes except symbol name with Other's so that
+// this symbol becomes an alias to Other. This is useful for handling
+// some options such as --wrap.
+//
+// The reason why we want to keep the symbol name is because, if we
+// copy symbol names, we'll end up having symbol tables in resulting
+// executables or DSOs containing two or more identical symbols, which
+// is just inconvenient.
+void SymbolBody::copy(SymbolBody *Other) {
+ StringRef S = Name;
+ memcpy(symbol()->Body.buffer, Other->symbol()->Body.buffer,
+ sizeof(Symbol::Body));
+ Name = S;
+}
+
uint64_t SymbolBody::getVA(int64_t Addend) const {
uint64_t OutVA = getSymVA(*this, Addend);
return OutVA + Addend;