Make it possible to create common symbols from bitcode.
Since the only missing bit was the size, I just replaced the Elf_Sym
with the size.
llvm-svn: 256384
diff --git a/lld/ELF/Symbols.cpp b/lld/ELF/Symbols.cpp
index c3515d1..4443417 100644
--- a/lld/ELF/Symbols.cpp
+++ b/lld/ELF/Symbols.cpp
@@ -58,10 +58,10 @@
if (isCommon()) {
if (!Other->isCommon())
return -1;
- auto *ThisC = cast<DefinedCommon<ELFT>>(this);
- auto *OtherC = cast<DefinedCommon<ELFT>>(Other);
+ auto *ThisC = cast<DefinedCommon>(this);
+ auto *OtherC = cast<DefinedCommon>(Other);
uintX_t Align = std::max(ThisC->MaxAlignment, OtherC->MaxAlignment);
- if (ThisC->Sym.st_size >= OtherC->Sym.st_size) {
+ if (ThisC->Size >= OtherC->Size) {
ThisC->MaxAlignment = Align;
return 1;
}
@@ -101,6 +101,13 @@
: Defined(SymbolBody::DefinedSyntheticKind, N, false, STV_DEFAULT, false),
Value(Value), Section(Section) {}
+DefinedCommon::DefinedCommon(StringRef N, uint64_t Size, uint64_t Alignment,
+ bool IsWeak, uint8_t Visibility)
+ : Defined(SymbolBody::DefinedCommonKind, N, IsWeak, Visibility, false) {
+ MaxAlignment = Alignment;
+ this->Size = Size;
+}
+
std::unique_ptr<InputFile> Lazy::getMember() {
MemoryBufferRef MBRef = File->getMember(&Sym);