forked from rust-lang/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Dsymutil][Debuginfo][NFC] Reland: Refactor dsymutil to separate DWAR…
…F optimizing part. rust-lang#2. Summary: This patch relands D71271. The problem with D71271 is that it has cyclic dependency: CodeGen->AsmPrinter->DebugInfoDWARF->CodeGen. To avoid cyclic dependency this patch puts implementation for DWARFOptimizer into separate library: lib/DWARFLinker. Thus the difference between this patch and D71271 is in that DWARFOptimizer renamed into DWARFLinker and it`s files are put into lib/DWARFLinker. Reviewers: JDevlieghere, friss, dblaikie, aprantl Reviewed By: JDevlieghere Subscribers: thegameg, merge_guards_bot, probinson, mgorny, hiraditya, llvm-commits Tags: #llvm, #debug-info Differential Revision: https://reviews.llvm.org/D71839
- Loading branch information
Showing
18 changed files
with
342 additions
and
215 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
//===- DWARFLinker.h --------------------------------------------*- C++ -*-===// | ||
// | ||
// 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLVM_DWARFLINKER_DWARFLINKER_H | ||
#define LLVM_DWARFLINKER_DWARFLINKER_H | ||
|
||
#include "llvm/CodeGen/NonRelocatableStringpool.h" | ||
#include "llvm/DWARFLinker/DWARFLinkerDeclContext.h" | ||
#include "llvm/DebugInfo/DWARF/DWARFCompileUnit.h" | ||
#include "llvm/DebugInfo/DWARF/DWARFContext.h" | ||
#include <map> | ||
|
||
namespace llvm { | ||
|
||
enum class DwarfLinkerClient { Dsymutil, LLD, General }; | ||
|
||
/// Partial address range. Besides an offset, only the | ||
/// HighPC is stored. The structure is stored in a map where the LowPC is the | ||
/// key. | ||
struct ObjFileAddressRange { | ||
/// Function HighPC. | ||
uint64_t HighPC; | ||
/// Offset to apply to the linked address. | ||
/// should be 0 for not-linked object file. | ||
int64_t Offset; | ||
|
||
ObjFileAddressRange(uint64_t EndPC, int64_t Offset) | ||
: HighPC(EndPC), Offset(Offset) {} | ||
|
||
ObjFileAddressRange() : HighPC(0), Offset(0) {} | ||
}; | ||
|
||
/// Map LowPC to ObjFileAddressRange. | ||
using RangesTy = std::map<uint64_t, ObjFileAddressRange>; | ||
|
||
/// AddressesMap represents information about valid addresses used | ||
/// by debug information. Valid addresses are those which points to | ||
/// live code sections. i.e. relocations for these addresses point | ||
/// into sections which would be/are placed into resulting binary. | ||
class AddressesMap { | ||
public: | ||
virtual ~AddressesMap(); | ||
|
||
/// Returns true if represented addresses are from linked file. | ||
/// Returns false if represented addresses are from not-linked | ||
/// object file. | ||
virtual bool areRelocationsResolved() const = 0; | ||
|
||
/// Checks that there are valid relocations against a .debug_info | ||
/// section. Reset current relocation pointer if neccessary. | ||
virtual bool hasValidRelocs(bool ResetRelocsPtr = true) = 0; | ||
|
||
/// Checks that there is a relocation against .debug_info | ||
/// table between \p StartOffset and \p NextOffset. | ||
/// | ||
/// This function must be called with offsets in strictly ascending | ||
/// order because it never looks back at relocations it already 'went past'. | ||
/// \returns true and sets Info.InDebugMap if it is the case. | ||
virtual bool hasValidRelocationAt(uint64_t StartOffset, uint64_t EndOffset, | ||
CompileUnit::DIEInfo &Info) = 0; | ||
|
||
/// Apply the valid relocations to the buffer \p Data, taking into | ||
/// account that Data is at \p BaseOffset in the debug_info section. | ||
/// | ||
/// This function must be called with monotonic \p BaseOffset values. | ||
/// | ||
/// \returns true whether any reloc has been applied. | ||
virtual bool applyValidRelocs(MutableArrayRef<char> Data, uint64_t BaseOffset, | ||
bool IsLittleEndian) = 0; | ||
|
||
/// Returns all valid functions address ranges(i.e., those ranges | ||
/// which points to sections with code). | ||
virtual RangesTy &getValidAddressRanges() = 0; | ||
|
||
/// Erases all data. | ||
virtual void clear() = 0; | ||
}; | ||
|
||
} // end namespace llvm | ||
|
||
#endif // LLVM_DWARFLINKER_DWARFLINKER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
add_llvm_component_library(LLVMDWARFLinker | ||
DWARFLinkerCompileUnit.cpp | ||
DWARFLinkerDeclContext.cpp | ||
DWARFLinker.cpp | ||
|
||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
//=== DWARFLinker.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 "llvm/DWARFLinker/DWARFLinker.h" | ||
|
||
namespace llvm { | ||
|
||
AddressesMap::~AddressesMap() {} | ||
|
||
} // namespace llvm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
;===- ./lib/DWARFLinker/LLVMBuild.txt ---------------*- Conf -*--===; | ||
; | ||
; 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 | ||
; | ||
;===------------------------------------------------------------------------===; | ||
; | ||
; This is an LLVMBuild description file for the components in this subdirectory. | ||
; | ||
; For more information on the LLVMBuild system, please see: | ||
; | ||
; http://llvm.org/docs/LLVMBuild.html | ||
; | ||
;===------------------------------------------------------------------------===; | ||
|
||
[component_0] | ||
type = Library | ||
name = DWARFLinker | ||
parent = Libraries | ||
required_libraries = DebugInfoDWARF AsmPrinter CodeGen MC Object Support |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ subdirectories = | |
CodeGen | ||
DebugInfo | ||
Demangle | ||
DWARFLinker | ||
ExecutionEngine | ||
Frontend | ||
FuzzMutate | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.