@@ -62,6 +62,14 @@ class ELFLinkGraphBuilder : public ELFLinkGraphBuilderBase {
62
62
StringRef FileName,
63
63
LinkGraph::GetEdgeKindNameFunction GetEdgeKindName);
64
64
65
+ // / Debug sections are included in the graph by default. Use
66
+ // / setProcessDebugSections(false) to ignore them if debug info is not
67
+ // / needed.
68
+ ELFLinkGraphBuilder &setProcessDebugSections (bool ProcessDebugSections) {
69
+ this ->ProcessDebugSections = ProcessDebugSections;
70
+ return *this ;
71
+ }
72
+
65
73
// / Attempt to construct and return the LinkGraph.
66
74
Expected<std::unique_ptr<LinkGraph>> buildGraph ();
67
75
@@ -115,8 +123,7 @@ class ELFLinkGraphBuilder : public ELFLinkGraphBuilderBase {
115
123
// /
116
124
template <typename RelocHandlerMethod>
117
125
Error forEachRelaRelocation (const typename ELFT::Shdr &RelSect,
118
- RelocHandlerMethod &&Func,
119
- bool ProcessDebugSections = false );
126
+ RelocHandlerMethod &&Func);
120
127
121
128
// / Traverse all matching ELFT::Rel relocation records in the given section.
122
129
// / The handler function Func should be callable with this signature:
@@ -125,44 +132,40 @@ class ELFLinkGraphBuilder : public ELFLinkGraphBuilderBase {
125
132
// /
126
133
template <typename RelocHandlerMethod>
127
134
Error forEachRelRelocation (const typename ELFT::Shdr &RelSect,
128
- RelocHandlerMethod &&Func,
129
- bool ProcessDebugSections = false );
135
+ RelocHandlerMethod &&Func);
130
136
131
137
// / Traverse all matching rela relocation records in the given section.
132
138
// / Convenience wrapper to allow passing a member function for the handler.
133
139
// /
134
140
template <typename ClassT, typename RelocHandlerMethod>
135
141
Error forEachRelaRelocation (const typename ELFT::Shdr &RelSect,
136
- ClassT *Instance, RelocHandlerMethod &&Method,
137
- bool ProcessDebugSections = false ) {
142
+ ClassT *Instance, RelocHandlerMethod &&Method) {
138
143
return forEachRelaRelocation (
139
144
RelSect,
140
145
[Instance, Method](const auto &Rel, const auto &Target, auto &GS) {
141
146
return (Instance->*Method)(Rel, Target, GS);
142
- },
143
- ProcessDebugSections);
147
+ });
144
148
}
145
149
146
150
// / Traverse all matching rel relocation records in the given section.
147
151
// / Convenience wrapper to allow passing a member function for the handler.
148
152
// /
149
153
template <typename ClassT, typename RelocHandlerMethod>
150
154
Error forEachRelRelocation (const typename ELFT::Shdr &RelSect,
151
- ClassT *Instance, RelocHandlerMethod &&Method,
152
- bool ProcessDebugSections = false ) {
155
+ ClassT *Instance, RelocHandlerMethod &&Method) {
153
156
return forEachRelRelocation (
154
157
RelSect,
155
158
[Instance, Method](const auto &Rel, const auto &Target, auto &GS) {
156
159
return (Instance->*Method)(Rel, Target, GS);
157
- },
158
- ProcessDebugSections);
160
+ });
159
161
}
160
162
161
163
const ELFFile &Obj;
162
164
163
165
typename ELFFile::Elf_Shdr_Range Sections;
164
166
const typename ELFFile::Elf_Shdr *SymTabSec = nullptr ;
165
167
StringRef SectionStringTab;
168
+ bool ProcessDebugSections = true ;
166
169
167
170
// Maps ELF section indexes to LinkGraph Blocks.
168
171
// Only SHF_ALLOC sections will have graph blocks.
@@ -318,7 +321,7 @@ template <typename ELFT> Error ELFLinkGraphBuilder<ELFT>::graphifySections() {
318
321
319
322
// If the name indicates that it's a debug section then skip it: We don't
320
323
// support those yet.
321
- if (isDwarfSection (*Name)) {
324
+ if (!ProcessDebugSections && isDwarfSection (*Name)) {
322
325
LLVM_DEBUG ({
323
326
dbgs () << " " << SecIndex << " : \" " << *Name
324
327
<< " \" is a debug section: "
@@ -522,8 +525,7 @@ template <typename ELFT> Error ELFLinkGraphBuilder<ELFT>::graphifySymbols() {
522
525
template <typename ELFT>
523
526
template <typename RelocHandlerFunction>
524
527
Error ELFLinkGraphBuilder<ELFT>::forEachRelaRelocation(
525
- const typename ELFT::Shdr &RelSect, RelocHandlerFunction &&Func,
526
- bool ProcessDebugSections) {
528
+ const typename ELFT::Shdr &RelSect, RelocHandlerFunction &&Func) {
527
529
// Only look into sections that store relocation entries.
528
530
if (RelSect.sh_type != ELF::SHT_RELA)
529
531
return Error::success ();
@@ -569,8 +571,7 @@ Error ELFLinkGraphBuilder<ELFT>::forEachRelaRelocation(
569
571
template <typename ELFT>
570
572
template <typename RelocHandlerFunction>
571
573
Error ELFLinkGraphBuilder<ELFT>::forEachRelRelocation(
572
- const typename ELFT::Shdr &RelSect, RelocHandlerFunction &&Func,
573
- bool ProcessDebugSections) {
574
+ const typename ELFT::Shdr &RelSect, RelocHandlerFunction &&Func) {
574
575
// Only look into sections that store relocation entries.
575
576
if (RelSect.sh_type != ELF::SHT_REL)
576
577
return Error::success ();
0 commit comments