[PATCH] D39458: Do not access beyond the end of local symbols.
Rui Ueyama via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 31 14:27:15 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL317039: Do not access beyond the end of local symbols. (authored by ruiu).
Changed prior to commit:
https://reviews.llvm.org/D39458?vs=121006&id=121063#toc
Repository:
rL LLVM
https://reviews.llvm.org/D39458
Files:
lld/trunk/COFF/SymbolTable.cpp
Index: lld/trunk/COFF/SymbolTable.cpp
===================================================================
--- lld/trunk/COFF/SymbolTable.cpp
+++ lld/trunk/COFF/SymbolTable.cpp
@@ -106,7 +106,17 @@
// A weak alias may have been resolved, so check for that.
if (Defined *D = Undef->getWeakAlias()) {
- memcpy(Sym, D, sizeof(SymbolUnion));
+ // We want to replace Sym with D. However, we can't just blindly
+ // copy sizeof(SymbolUnion) bytes from D to Sym because D may be an
+ // internal symbol, and internal symbols are stored as "unparented"
+ // Symbols. For that reason we need to check which type of symbol we
+ // are dealing with and copy the correct number of bytes.
+ if (isa<DefinedRegular>(D))
+ memcpy(Sym, D, sizeof(DefinedRegular));
+ else if (isa<DefinedAbsolute>(D))
+ memcpy(Sym, D, sizeof(DefinedAbsolute));
+ else
+ memcpy(Sym, D, sizeof(SymbolUnion));
continue;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39458.121063.patch
Type: text/x-patch
Size: 976 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171031/e6f656bc/attachment.bin>
More information about the llvm-commits
mailing list