Skip to content

Commit 7c6e230

Browse files
Add ObjWriter API to set DWARF version (llvm#161)
Contributes to https://github.com/dotnet/runtimelab/issues/1738.
1 parent 340aa3d commit 7c6e230

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

llvm/tools/objwriter/objwriter.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,10 @@ void ObjectWriter::Finish() {
204204
Streamer->Finish();
205205
}
206206

207+
void ObjectWriter::SetDwarfVersion(uint16_t v) {
208+
Streamer->getContext().setDwarfVersion(v);
209+
}
210+
207211
void ObjectWriter::SwitchSection(const char *SectionName,
208212
CustomSectionAttributes attributes,
209213
const char *ComdatName) {

llvm/tools/objwriter/objwriter.exports

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
InitObjWriter
22
FinishObjWriter
3+
SetDwarfVersion
34
SwitchSection
45
SetCodeSectionAttribute
56
EmitAlignment

llvm/tools/objwriter/objwriter.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ class ObjectWriter {
7070
bool Init(StringRef FunctionName, const char* tripleName = nullptr);
7171
void Finish();
7272

73+
void SetDwarfVersion(uint16_t v);
7374
void SwitchSection(const char *SectionName,
7475
CustomSectionAttributes attributes,
7576
const char *ComdatName);
@@ -213,6 +214,11 @@ DLL_EXPORT STDMETHODCALLTYPE void FinishObjWriter(ObjectWriter *OW) {
213214
delete OW;
214215
}
215216

217+
DLL_EXPORT STDMETHODCALLTYPE void SetDwarfVersion(ObjectWriter *OW, uint16_t v) {
218+
assert(OW && "ObjWriter is null");
219+
OW->SetDwarfVersion(v);
220+
}
221+
216222
DLL_EXPORT STDMETHODCALLTYPE void SwitchSection(ObjectWriter *OW, const char *SectionName,
217223
CustomSectionAttributes attributes,
218224
const char *ComdatName) {

0 commit comments

Comments
 (0)