[llvm] [llvm-mc] Don't print initial .text (PR #120185)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 16 21:55:27 PST 2024
https://github.com/MaskRay created https://github.com/llvm/llvm-project/pull/120185
Omit the initial `.text` for --disassemble.
```
% echo 90 | myllvm-mc -triple=x86_64 --disassemble --hex
nop
```
>From de901197ddd7c473027405f073ff166a1bc85e5f Mon Sep 17 00:00:00 2001
From: Fangrui Song <i at maskray.me>
Date: Mon, 16 Dec 2024 21:54:56 -0800
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
=?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Created using spr 1.3.5-bogner
---
llvm/test/MC/Disassembler/AArch64/colored.txt | 1 +
llvm/test/tools/llvm-mc/line_end_with_space.test | 2 +-
llvm/tools/llvm-mc/Disassembler.cpp | 2 +-
3 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/llvm/test/MC/Disassembler/AArch64/colored.txt b/llvm/test/MC/Disassembler/AArch64/colored.txt
index 3293de8a8748f4..1379c552d85cc3 100644
--- a/llvm/test/MC/Disassembler/AArch64/colored.txt
+++ b/llvm/test/MC/Disassembler/AArch64/colored.txt
@@ -1,6 +1,7 @@
# UNSUPPORTED: system-windows
# RUN: llvm-mc -triple=aarch64 -mattr=+all --cdis %s | FileCheck %s --strict-whitespace --match-full-lines
+# CHECK-NOT:{{.}}
0xa1 0x00 0x00 0x54
# CHECK: b.ne [0;31m#20[0m
0x00 0x7c 0x00 0x13
diff --git a/llvm/test/tools/llvm-mc/line_end_with_space.test b/llvm/test/tools/llvm-mc/line_end_with_space.test
index 5ad5a8382edfae..b9f44afc43bb4d 100644
--- a/llvm/test/tools/llvm-mc/line_end_with_space.test
+++ b/llvm/test/tools/llvm-mc/line_end_with_space.test
@@ -1,3 +1,3 @@
# Test that llvm-mc doesn't crash when disassembling a line that ends with a
# space.
-RUN: echo -n ' ' | llvm-mc -disassemble
+RUN: echo -n ' ' | llvm-mc -disassemble | count 0
diff --git a/llvm/tools/llvm-mc/Disassembler.cpp b/llvm/tools/llvm-mc/Disassembler.cpp
index 30577fe631d62e..d02445e21e4c31 100644
--- a/llvm/tools/llvm-mc/Disassembler.cpp
+++ b/llvm/tools/llvm-mc/Disassembler.cpp
@@ -169,7 +169,7 @@ int Disassembler::disassemble(const Target &T, const std::string &Triple,
}
// Set up initial section manually here
- Streamer.initSections(false, STI);
+ Streamer.switchSectionNoPrint(Ctx.getObjectFileInfo()->getTextSection());
bool ErrorOccurred = false;
More information about the llvm-commits
mailing list