aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/MC/MCMachOStreamer.cpp
diff options
context:
space:
mode:
authorFangrui Song <i@maskray.me>2024-07-20 10:43:52 -0700
committerFangrui Song <i@maskray.me>2024-07-20 10:43:52 -0700
commitaa86f4f18549583f9227276cd116dbaf5625aa78 (patch)
tree0643d1862f68b6f0dc72eb584d4698458659ea8e /llvm/lib/MC/MCMachOStreamer.cpp
parent29be889c2c9c9a92e7ed89bd71d141961517d7e5 (diff)
downloadllvm-aa86f4f18549583f9227276cd116dbaf5625aa78.zip
llvm-aa86f4f18549583f9227276cd116dbaf5625aa78.tar.gz
llvm-aa86f4f18549583f9227276cd116dbaf5625aa78.tar.bz2
[MC] Remove unnecessary DWARFMustBeAtTheEnd check
36a15cb975334403216e6145d4abece3026af17a introduced the DWARFMustBeAtTheEnd check to ensure DWARF sections were placed after all text sections to help avoid out-of-range branches for Darwin ARM. The commit removed a Darwin ARM hack from 20e5f5ed7930efdf2bd34bf099f24ac88798c5ea (2009), likely due to a no-longer-relevant assembler limitation. However, this check is no longer relevant due to the following: * Our CodeGen approach reliably places DWARF sections at the end. * Darwin AArch32 is less relevant today. Removing this check also addresses a minor clang cc1as crash that could occur when text sections were placed after DWARF sections (e9ad54b3ee905ea3a77c35ca7d6e843b2c552e0b (2015)).
Diffstat (limited to 'llvm/lib/MC/MCMachOStreamer.cpp')
-rw-r--r--llvm/lib/MC/MCMachOStreamer.cpp56
1 files changed, 5 insertions, 51 deletions
diff --git a/llvm/lib/MC/MCMachOStreamer.cpp b/llvm/lib/MC/MCMachOStreamer.cpp
index c8bc819..5231d10 100644
--- a/llvm/lib/MC/MCMachOStreamer.cpp
+++ b/llvm/lib/MC/MCMachOStreamer.cpp
@@ -54,9 +54,6 @@ private:
/// need for local relocations. False by default.
bool LabelSections;
- bool DWARFMustBeAtTheEnd;
- bool CreatedADWARFSection;
-
/// HasSectionLabel - map of which sections have already had a non-local
/// label emitted to them. Used so we don't emit extraneous linker local
/// labels in the middle of the section.
@@ -70,16 +67,13 @@ private:
public:
MCMachOStreamer(MCContext &Context, std::unique_ptr<MCAsmBackend> MAB,
std::unique_ptr<MCObjectWriter> OW,
- std::unique_ptr<MCCodeEmitter> Emitter,
- bool DWARFMustBeAtTheEnd, bool label)
+ std::unique_ptr<MCCodeEmitter> Emitter, bool label)
: MCObjectStreamer(Context, std::move(MAB), std::move(OW),
std::move(Emitter)),
- LabelSections(label), DWARFMustBeAtTheEnd(DWARFMustBeAtTheEnd),
- CreatedADWARFSection(false) {}
+ LabelSections(label) {}
/// state management
void reset() override {
- CreatedADWARFSection = false;
HasSectionLabel.clear();
MCObjectStreamer::reset();
}
@@ -141,48 +135,9 @@ public:
} // end anonymous namespace.
-static bool canGoAfterDWARF(const MCSectionMachO &MSec) {
- // These sections are created by the assembler itself after the end of
- // the .s file.
- StringRef SegName = MSec.getSegmentName();
- StringRef SecName = MSec.getName();
-
- if (SegName == "__LD" && SecName == "__compact_unwind")
- return true;
-
- if (SegName == "__IMPORT") {
- if (SecName == "__jump_table")
- return true;
-
- if (SecName == "__pointers")
- return true;
- }
-
- if (SegName == "__TEXT" && SecName == "__eh_frame")
- return true;
-
- if (SegName == "__DATA" &&
- (SecName == "__llvm_addrsig" || SecName == "__nl_symbol_ptr" ||
- SecName == "__thread_ptr"))
- return true;
- if (SegName == "__LLVM" && (SecName == "__cg_profile"))
- return true;
-
- if (SegName == "__DATA" && SecName == "__auth_ptr")
- return true;
-
- return false;
-}
-
void MCMachOStreamer::changeSection(MCSection *Section, uint32_t Subsection) {
// Change the section normally.
- bool Created = changeSectionImpl(Section, Subsection);
- const MCSectionMachO &MSec = *cast<MCSectionMachO>(Section);
- StringRef SegName = MSec.getSegmentName();
- if (SegName == "__DWARF")
- CreatedADWARFSection = true;
- else if (Created && DWARFMustBeAtTheEnd && !canGoAfterDWARF(MSec))
- assert(!CreatedADWARFSection && "Creating regular section after DWARF");
+ changeSectionImpl(Section, Subsection);
// Output a linker-local symbol so we don't need section-relative local
// relocations. The linker hates us when we do that.
@@ -576,9 +531,8 @@ MCStreamer *llvm::createMachOStreamer(MCContext &Context,
std::unique_ptr<MCCodeEmitter> &&CE,
bool DWARFMustBeAtTheEnd,
bool LabelSections) {
- MCMachOStreamer *S =
- new MCMachOStreamer(Context, std::move(MAB), std::move(OW), std::move(CE),
- DWARFMustBeAtTheEnd, LabelSections);
+ MCMachOStreamer *S = new MCMachOStreamer(
+ Context, std::move(MAB), std::move(OW), std::move(CE), LabelSections);
const Triple &Target = Context.getTargetTriple();
S->emitVersionForTarget(
Target, Context.getObjectFileInfo()->getSDKVersion(),