Skip to content

Commit 61bc1d7

Browse files
committed
[RuntimeDyld] load all sections with ProcessAllSections
This patch tried to address the following use case. . bcc (https://github.com/iovisor/bcc) utilizes llvm JIT to compile for BTF target. . with -g, .BTF and .BTF.ext sections (BPF debug info) will be generated by LLVM. . .BTF does not have relocations and .BTF.ext has some relocations. . With ProcessAllSections, .BTF.ext is loaded by JIT dynamic linker and is available to application. But .BTF is not loaded. The bcc application needs both .BTF.ext and .BTF for debugging purpose, and .BTF is not loaded. This patch addressed this issue by iterating over all sections and loading any missing sections, after symbol/relocation processing in loadObjectImpl(). Signed-off-by: Yonghong Song <yhs@fb.com> Differential Revision: https://reviews.llvm.org/D55943 llvm-svn: 352432
1 parent 27fd307 commit 61bc1d7

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp

+19
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,25 @@ RuntimeDyldImpl::loadObjectImpl(const object::ObjectFile &Obj) {
381381
Checker->registerStubMap(Obj.getFileName(), SectionID, Stubs);
382382
}
383383

384+
// Process remaining sections
385+
if (ProcessAllSections) {
386+
LLVM_DEBUG(dbgs() << "Process remaining sections:\n");
387+
for (section_iterator SI = Obj.section_begin(), SE = Obj.section_end();
388+
SI != SE; ++SI) {
389+
390+
/* Ignore already loaded sections */
391+
if (LocalSections.find(*SI) != LocalSections.end())
392+
continue;
393+
394+
bool IsCode = SI->isText();
395+
if (auto SectionIDOrErr =
396+
findOrEmitSection(Obj, *SI, IsCode, LocalSections))
397+
LLVM_DEBUG(dbgs() << "\tSectionID: " << (*SectionIDOrErr) << "\n");
398+
else
399+
return SectionIDOrErr.takeError();
400+
}
401+
}
402+
384403
// Give the subclasses a chance to tie-up any loose ends.
385404
if (auto Err = finalizeLoad(Obj, LocalSections))
386405
return std::move(Err);

0 commit comments

Comments
 (0)