diff options
author | Julian Büning <julian.buening@rwth-aachen.de> | 2018-10-28 16:11:18 +0100 |
---|---|---|
committer | Cristian Cadar <c.cadar@imperial.ac.uk> | 2019-03-05 10:39:50 +0000 |
commit | 46463adc26e29075c4cf87cc8f51d5a191929938 (patch) | |
tree | b5b5636d879344e8cbd64ed66095425a240d5348 /lib/Core/Executor.cpp | |
parent | 44325801ed4840cb1c334b9810f16ea8d691e986 (diff) | |
download | klee-46463adc26e29075c4cf87cc8f51d5a191929938.tar.gz |
fix Executor::initializeGlobals for aliases pointing to another alias
Diffstat (limited to 'lib/Core/Executor.cpp')
-rw-r--r-- | lib/Core/Executor.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/Core/Executor.cpp b/lib/Core/Executor.cpp index ef996e7e..7aaaa87c 100644 --- a/lib/Core/Executor.cpp +++ b/lib/Core/Executor.cpp @@ -736,11 +736,19 @@ void Executor::initializeGlobals(ExecutionState &state) { } // link aliases to their definitions (if bound) - for (Module::alias_iterator i = m->alias_begin(), ie = m->alias_end(); - i != ie; ++i) { + for (auto i = m->alias_begin(), ie = m->alias_end(); i != ie; ++i) { // Map the alias to its aliasee's address. This works because we have - // addresses for everything, even undefined functions. - globalAddresses.insert(std::make_pair(&*i, evalConstant(i->getAliasee()))); + // addresses for everything, even undefined functions. + + // Alias may refer to other alias, not necessarily known at this point. + // Thus, resolve to real alias directly. + const GlobalAlias *alias = &*i; + while (const auto *ga = dyn_cast<GlobalAlias>(alias->getAliasee())) { + assert(ga != alias && "alias pointing to itself"); + alias = ga; + } + + globalAddresses.insert(std::make_pair(&*i, evalConstant(alias->getAliasee()))); } // once all objects are allocated, do the actual initialization |