Didn't someone recently submit a patch to allow relocation of .o files? That should have taken care of the issue, no?
> On Dec 4, 2017, at 5:01 AM, Pavel Labath via lldb-commits > <lldb-commits@lists.llvm.org> wrote: > > The reason you hit the assert there, is because you're running lldb on > an un-linked object file. When you link the file, the linker will > resolve these relocations and they will disappear. This is also the > reason you got those errors after removing the assert (you were > trying to parse unrelocated dwarf). To run your tests, you'll need to > run the object file through the linker (something like ld -shared -o > foo.so foo.o should suffice) > > The fact that we crash there is certainly a bug, but the bug may be > that we are even accepting these files in the first place. It might be > interesting to make lldb read these files, if for nothing else, then > for the sake of testing, but that is not a trivial task. Right now > that relocating code is completely wrong (e.g. it assumes all > relocations are x86 relocations). > > On 1 December 2017 at 20:49, Zachary Turner via Phabricator > <revi...@reviews.llvm.org> wrote: >> zturner created this revision. >> Herald added a subscriber: emaste. >> >> This is the bare minimum needed to dump `ClangASTContext`s via `lldb-test`. >> >> Within the first 10 seconds of using this, I already found a bug. A `FIXME` >> note and repro is included in the comments in this patch. >> >> With this, it should be possible to do deep testing of otherwise difficult >> to test scenarios involving `ClangASTContext`. >> >> >> https://reviews.llvm.org/D40745 >> >> Files: >> lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp >> lldb/tools/lldb-test/lldb-test.cpp >> >> >> Index: lldb/tools/lldb-test/lldb-test.cpp >> =================================================================== >> --- lldb/tools/lldb-test/lldb-test.cpp >> +++ lldb/tools/lldb-test/lldb-test.cpp >> @@ -10,11 +10,15 @@ >> #include "FormatUtil.h" >> #include "SystemInitializerTest.h" >> >> +#include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h" >> #include "lldb/Core/Debugger.h" >> #include "lldb/Core/Module.h" >> #include "lldb/Core/Section.h" >> #include "lldb/Initialization/SystemLifetimeManager.h" >> +#include "lldb/Symbol/ClangASTContext.h" >> +#include "lldb/Symbol/ClangASTImporter.h" >> #include "lldb/Utility/DataExtractor.h" >> +#include "lldb/Utility/StreamString.h" >> >> #include "llvm/ADT/StringRef.h" >> #include "llvm/Support/CommandLine.h" >> @@ -30,26 +34,48 @@ >> namespace opts { >> cl::SubCommand ModuleSubcommand("module-sections", >> "Display LLDB Module Information"); >> +cl::SubCommand ClangASTSubcommand("clang-ast", "Dump Clang AST for input >> file"); >> >> namespace module { >> cl::opt<bool> SectionContents("contents", >> cl::desc("Dump each section's contents"), >> cl::sub(ModuleSubcommand)); >> cl::list<std::string> InputFilenames(cl::Positional, cl::desc("<input >> files>"), >> cl::OneOrMore, >> cl::sub(ModuleSubcommand)); >> } // namespace module >> + >> +namespace clang_ast { >> +cl::list<std::string> InputFilenames(cl::Positional, cl::desc("<input >> files>"), >> + cl::OneOrMore, >> + cl::sub(ClangASTSubcommand)); >> +} >> } // namespace opts >> >> static llvm::ManagedStatic<SystemLifetimeManager> DebuggerLifetime; >> >> +static void dumpClangASTContext(Debugger &Dbg) { >> + for (const auto &File : opts::clang_ast::InputFilenames) { >> + ModuleSpec Spec{FileSpec(File, false)}; >> + Spec.GetSymbolFileSpec().SetFile(File, false); >> + >> + auto ModulePtr = std::make_shared<lldb_private::Module>(Spec); >> + >> + StreamString Stream; >> + ModulePtr->ParseAllDebugSymbols(); >> + ModulePtr->Dump(&Stream); >> + llvm::outs() << Stream.GetData() << "\n"; >> + llvm::outs().flush(); >> + } >> +} >> + >> static void dumpModules(Debugger &Dbg) { >> LinePrinter Printer(4, llvm::outs()); >> >> for (const auto &File : opts::module::InputFilenames) { >> ModuleSpec Spec{FileSpec(File, false)}; >> Spec.GetSymbolFileSpec().SetFile(File, false); >> >> - auto ModulePtr = std::make_shared<Module>(Spec); >> + auto ModulePtr = std::make_shared<lldb_private::Module>(Spec); >> SectionList *Sections = ModulePtr->GetSectionList(); >> if (!Sections) { >> llvm::errs() << "Could not load sections for module " << File << "\n"; >> @@ -92,6 +118,8 @@ >> >> if (opts::ModuleSubcommand) >> dumpModules(*Dbg); >> + else if (opts::ClangASTSubcommand) >> + dumpClangASTContext(*Dbg); >> >> DebuggerLifetime->Terminate(); >> return 0; >> Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp >> =================================================================== >> --- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp >> +++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp >> @@ -2764,6 +2764,14 @@ >> case R_386_32: >> case R_386_PC32: >> default: >> + // FIXME: This asserts with this input: >> + // >> + // foo.cpp >> + // int main(int argc, char **argv) { return 0; } >> + // >> + // clang++.exe --target=i686-unknown-linux-gnu -g -c foo.cpp -o >> foo.o >> + // >> + // and running this on the foo.o module. >> assert(false && "unexpected relocation type"); >> } >> } else { >> >> > _______________________________________________ > lldb-commits mailing list > lldb-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits