This patch creates skeleton implementation for the DWARFLinkerParallel. It also integrates DWARFLinkerParallel into dsymutil and llvm-dwarfutil, so that empty DWARFLinker::link() can be called. To do this new command line option is added "--linker apple/llvm". Additionally it changes existing DWARFLinker interfaces/implementations to be compatible: use Error for error reporting for the DWARFStreamer, make DWARFFile to owner of referenced resources, other small refactorings. Differential Revision: https://reviews.llvm.org/D147952
47 lines
1.5 KiB
C++
47 lines
1.5 KiB
C++
//=== DWARFLinkerImpl.cpp -------------------------------------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "DWARFLinkerImpl.h"
|
|
|
|
namespace llvm {
|
|
namespace dwarflinker_parallel {
|
|
|
|
/// Similar to DWARFUnitSection::getUnitForOffset(), but returning our
|
|
/// CompileUnit object instead.
|
|
CompileUnit *
|
|
DWARFLinkerImpl::LinkContext::getUnitForOffset(CompileUnit &CurrentCU,
|
|
uint64_t Offset) const {
|
|
if (CurrentCU.isClangModule())
|
|
return &CurrentCU;
|
|
|
|
auto CU = llvm::upper_bound(
|
|
CompileUnits, Offset,
|
|
[](uint64_t LHS, const std::unique_ptr<CompileUnit> &RHS) {
|
|
return LHS < RHS->getOrigUnit().getNextUnitOffset();
|
|
});
|
|
|
|
return CU != CompileUnits.end() ? CU->get() : nullptr;
|
|
}
|
|
|
|
Error DWARFLinkerImpl::createEmitter(const Triple &TheTriple,
|
|
OutputFileType FileType,
|
|
raw_pwrite_stream &OutFile) {
|
|
|
|
TheDwarfEmitter = std::make_unique<DwarfEmitterImpl>(
|
|
FileType, OutFile, OutputStrings.getTranslator(), WarningHandler);
|
|
|
|
return TheDwarfEmitter->init(TheTriple, "__DWARF");
|
|
}
|
|
|
|
ExtraDwarfEmitter *DWARFLinkerImpl::getEmitter() {
|
|
return TheDwarfEmitter.get();
|
|
}
|
|
|
|
} // end of namespace dwarflinker_parallel
|
|
} // namespace llvm
|