1 //=== DWARFLinkerImpl.cpp -------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "DWARFLinkerImpl.h"
12 namespace dwarflinker_parallel
{
14 /// Similar to DWARFUnitSection::getUnitForOffset(), but returning our
15 /// CompileUnit object instead.
17 DWARFLinkerImpl::LinkContext::getUnitForOffset(CompileUnit
&CurrentCU
,
18 uint64_t Offset
) const {
19 if (CurrentCU
.isClangModule())
22 auto CU
= llvm::upper_bound(
24 [](uint64_t LHS
, const std::unique_ptr
<CompileUnit
> &RHS
) {
25 return LHS
< RHS
->getOrigUnit().getNextUnitOffset();
28 return CU
!= CompileUnits
.end() ? CU
->get() : nullptr;
31 Error
DWARFLinkerImpl::createEmitter(const Triple
&TheTriple
,
32 OutputFileType FileType
,
33 raw_pwrite_stream
&OutFile
) {
35 TheDwarfEmitter
= std::make_unique
<DwarfEmitterImpl
>(
36 FileType
, OutFile
, OutputStrings
.getTranslator(), WarningHandler
);
38 return TheDwarfEmitter
->init(TheTriple
, "__DWARF");
41 ExtraDwarfEmitter
*DWARFLinkerImpl::getEmitter() {
42 return TheDwarfEmitter
.get();
45 } // end of namespace dwarflinker_parallel