Skip to content

Commit

Permalink
Do not indiscriminately create text section (dotnet#312)
Browse files Browse the repository at this point in the history
If we ended up with nothing in the text section, this line would error LLVM out in:

https://github.com/dotnet/llvm-project/blob/3db8d68195c17386557f1a258312bbae4051dc05/llvm/lib/MC/ELFObjectWriter.cpp#L1458-L1459

Because we generate a reference to the empty text section in the `aranges` section.

I double checked and debugging on Linux still works fine without this. `SetCodeSectionAttribute` is an objwriter API and we have access to it from the managed side. We should be calling it from there if it's needed for something that I didn't realize (we do call it from the managed side for the `.managed` section, but that one actually has debug information generated, unlike `.text`).
  • Loading branch information
MichalStrehovsky authored and filipnavara committed Nov 16, 2022
1 parent 0643adf commit e3457ac
Showing 1 changed file with 0 additions and 2 deletions.
2 changes: 0 additions & 2 deletions llvm/tools/objwriter/objwriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,6 @@ bool ObjectWriter::Init(llvm::StringRef ObjectFilePath, const char* tripleName)
FrameOpened = false;
FuncId = 1;

SetCodeSectionAttribute("text", CustomSectionAttributes_Executable, nullptr);

if (OutContext->getObjectFileType() == MCContext::IsCOFF) {
TypeBuilder.reset(new UserDefinedCodeViewTypesBuilder());
} else {
Expand Down

0 comments on commit e3457ac

Please sign in to comment.