mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-19 05:06:45 +00:00
Make Ctx a plain pointer again.
If a struct has a std::unique_ptr member, the logical interpretation is that that member will be destroyed with the struct. That is not the case for Ctx. It is has to be deleted earlier and its lifetime is defined by the functions where the AddressState is created. llvm-svn: 316378
This commit is contained in:
parent
7887238c7c
commit
089dac7be1
@ -356,7 +356,8 @@ void LinkerScript::processSectionCommands() {
|
||||
// This is needed as there are some cases where we cannot just
|
||||
// thread the current state through to a lambda function created by the
|
||||
// script parser.
|
||||
Ctx = make_unique<AddressState>();
|
||||
auto Deleter = make_unique<AddressState>();
|
||||
Ctx = Deleter.get();
|
||||
Ctx->OutSec = Aether;
|
||||
|
||||
DenseMap<SectionBase *, int> Order = buildSectionOrder();
|
||||
@ -803,11 +804,8 @@ void LinkerScript::assignAddresses() {
|
||||
// -image-base if set.
|
||||
Dot = Config->ImageBase ? *Config->ImageBase : 0;
|
||||
|
||||
// Ctx captures the local AddressState and makes it accessible
|
||||
// deliberately. This is needed as there are some cases where we cannot just
|
||||
// thread the current state through to a lambda function created by the
|
||||
// script parser.
|
||||
Ctx = make_unique<AddressState>();
|
||||
auto Deleter = make_unique<AddressState>();
|
||||
Ctx = Deleter.get();
|
||||
ErrorOnMissingSection = true;
|
||||
switchTo(Aether);
|
||||
|
||||
|
@ -222,7 +222,14 @@ class LinkerScript final {
|
||||
|
||||
void assignOffsets(OutputSection *Sec);
|
||||
|
||||
std::unique_ptr<AddressState> Ctx;
|
||||
// Ctx captures the local AddressState and makes it accessible
|
||||
// deliberately. This is needed as there are some cases where we cannot just
|
||||
// thread the current state through to a lambda function created by the
|
||||
// script parser.
|
||||
// This should remain a plain pointer as its lifetime is smaller than
|
||||
// LinkerScript.
|
||||
AddressState *Ctx = nullptr;
|
||||
|
||||
OutputSection *Aether;
|
||||
|
||||
uint64_t Dot;
|
||||
|
Loading…
x
Reference in New Issue
Block a user