aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/MC/MCStreamer.cpp
diff options
context:
space:
mode:
authorFangrui Song <i@maskray.me>2024-12-22 22:03:44 -0800
committerFangrui Song <i@maskray.me>2024-12-22 22:03:44 -0800
commit7b23f413d1f76532825e470b523e971818d453ca (patch)
treeb779423632651f381b48960e85219debc2bc385d /llvm/lib/MC/MCStreamer.cpp
parent158a60051d2d41bc255224ccb57d076efb75822e (diff)
downloadllvm-7b23f413d1f76532825e470b523e971818d453ca.zip
llvm-7b23f413d1f76532825e470b523e971818d453ca.tar.gz
llvm-7b23f413d1f76532825e470b523e971818d453ca.tar.bz2
MCAsmStreamer: Omit initial ".text"
llvm-mc --assemble prints an initial `.text` from `initSections`. This is weird for quick assembly tasks that do not specify `.text`. Omit the .text by moving section directive printing from `changeSection` to `switchSection`. switchSectionNoPrint now correctly calls the `changeSection` hook (needed by MachO). The initial directives of clang -S are now reordered. On ELF targets, we get `.file "a.c"; .text` instead of `.text; .file "a.c"`. If there is no function, `.text` will be omitted.
Diffstat (limited to 'llvm/lib/MC/MCStreamer.cpp')
-rw-r--r--llvm/lib/MC/MCStreamer.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/llvm/lib/MC/MCStreamer.cpp b/llvm/lib/MC/MCStreamer.cpp
index 5703cfd0..ccf65df 100644
--- a/llvm/lib/MC/MCStreamer.cpp
+++ b/llvm/lib/MC/MCStreamer.cpp
@@ -414,7 +414,7 @@ void MCStreamer::emitEHSymAttributes(const MCSymbol *Symbol,
}
void MCStreamer::initSections(bool NoExecStack, const MCSubtargetInfo &STI) {
- switchSection(getContext().getObjectFileInfo()->getTextSection());
+ switchSectionNoPrint(getContext().getObjectFileInfo()->getTextSection());
}
void MCStreamer::emitLabel(MCSymbol *Symbol, SMLoc Loc) {
@@ -1332,7 +1332,10 @@ bool MCStreamer::switchSection(MCSection *Section, const MCExpr *SubsecExpr) {
void MCStreamer::switchSectionNoPrint(MCSection *Section) {
SectionStack.back().second = SectionStack.back().first;
SectionStack.back().first = MCSectionSubPair(Section, 0);
- CurFrag = &Section->getDummyFragment();
+ changeSection(Section, 0);
+ MCSymbol *Sym = Section->getBeginSymbol();
+ if (Sym && !Sym->isInSection())
+ emitLabel(Sym);
}
MCSymbol *MCStreamer::endSection(MCSection *Section) {