[llvm] a3bf873 - [llvm-mc] --no-exec-stack: replace initSection with switchSection. NFC

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 18 23:36:19 PST 2024


Author: Fangrui Song
Date: 2024-12-18T23:36:13-08:00
New Revision: a3bf87357da3bae1a35c7a855988287b1fc7ca2f

URL: https://github.com/llvm/llvm-project/commit/a3bf87357da3bae1a35c7a855988287b1fc7ca2f
DIFF: https://github.com/llvm/llvm-project/commit/a3bf87357da3bae1a35c7a855988287b1fc7ca2f.diff

LOG: [llvm-mc] --no-exec-stack: replace initSection with switchSection. NFC

AsmParser will call initSection unless -n is specified.
It is not good to call initSection twice.

Added: 
    

Modified: 
    llvm/test/MC/ELF/noexec.s
    llvm/tools/llvm-mc/llvm-mc.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/test/MC/ELF/noexec.s b/llvm/test/MC/ELF/noexec.s
index dbfa45c5f428f5..a9ae5b24b4291b 100644
--- a/llvm/test/MC/ELF/noexec.s
+++ b/llvm/test/MC/ELF/noexec.s
@@ -14,3 +14,4 @@
 // CHECK-NEXT:     AddressAlignment: 1
 // CHECK-NEXT:     EntrySize: 0
 // CHECK-NEXT:   }
+nop

diff  --git a/llvm/tools/llvm-mc/llvm-mc.cpp b/llvm/tools/llvm-mc/llvm-mc.cpp
index fd93d7ed34c947..70f92d09aded7e 100644
--- a/llvm/tools/llvm-mc/llvm-mc.cpp
+++ b/llvm/tools/llvm-mc/llvm-mc.cpp
@@ -569,7 +569,7 @@ int main(int argc, char **argv) {
                : MAB->createObjectWriter(*OS),
         std::unique_ptr<MCCodeEmitter>(CE), *STI));
     if (NoExecStack)
-      Str->initSections(true, *STI);
+      Str->switchSection(Ctx.getAsmInfo()->getNonexecutableStackSection(Ctx));
     Str->emitVersionForTarget(TheTriple, VersionTuple(), nullptr,
                               VersionTuple());
   }


        


More information about the llvm-commits mailing list