mirror of
https://github.com/intel/llvm.git
synced 2026-01-16 21:55:39 +08:00
Add support for weak undefined symbols.
llvm-svn: 244640
This commit is contained in:
@@ -83,7 +83,8 @@ SymbolBody *elf2::ObjectFile<ELFT>::createSymbolBody(StringRef StringTable,
|
||||
return new (Alloc) Undefined(Name);
|
||||
return new (Alloc) DefinedRegular(Name);
|
||||
case STB_WEAK:
|
||||
// FIXME: add support for weak undefined
|
||||
if (Sym->isUndefined())
|
||||
return new (Alloc) UndefinedWeak(Name);
|
||||
return new (Alloc) DefinedWeak(Name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ int SymbolBody::compare(SymbolBody *Other) {
|
||||
return 0;
|
||||
case DefinedWeakKind:
|
||||
case UndefinedKind:
|
||||
case UndefinedWeakKind:
|
||||
return 1;
|
||||
}
|
||||
llvm_unreachable("unknown symbol kind");
|
||||
|
||||
@@ -39,7 +39,8 @@ public:
|
||||
DefinedRegularKind = 0,
|
||||
DefinedWeakKind = 1,
|
||||
DefinedLast = 1,
|
||||
UndefinedKind = 2
|
||||
UndefinedWeakKind = 2,
|
||||
UndefinedKind = 3
|
||||
};
|
||||
|
||||
Kind kind() const { return static_cast<Kind>(SymbolKind); }
|
||||
@@ -112,6 +113,15 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class UndefinedWeak : public SymbolBody {
|
||||
public:
|
||||
explicit UndefinedWeak(StringRef N) : SymbolBody(UndefinedWeakKind, N) {}
|
||||
|
||||
static bool classof(const SymbolBody *S) {
|
||||
return S->kind() == UndefinedWeakKind;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace elf2
|
||||
} // namespace lld
|
||||
|
||||
|
||||
@@ -13,3 +13,6 @@ local:
|
||||
foo:
|
||||
|
||||
.long bar
|
||||
|
||||
.weak zed
|
||||
.long zed
|
||||
|
||||
Reference in New Issue
Block a user