https://github.com/jansvoboda11 updated 
https://github.com/llvm/llvm-project/pull/172920

>From 0498b336cd66bfdde5592aeb8bb7dd02eed817bc Mon Sep 17 00:00:00 2001
From: Jan Svoboda <[email protected]>
Date: Thu, 18 Dec 2025 14:03:11 -0800
Subject: [PATCH] [llvm][clang] Work around sandbox violation in `.incbin`
 directives

---
 clang/test/CodeGen/asm_incbin.c       | 10 ++++++++++
 llvm/lib/Object/ModuleSymbolTable.cpp |  8 +++++++-
 2 files changed, 17 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/CodeGen/asm_incbin.c

diff --git a/clang/test/CodeGen/asm_incbin.c b/clang/test/CodeGen/asm_incbin.c
new file mode 100644
index 0000000000000..d69b98ddc7e13
--- /dev/null
+++ b/clang/test/CodeGen/asm_incbin.c
@@ -0,0 +1,10 @@
+// This provides coverage for file inclusion logic in asm directives.
+
+// RUN: split-file %s %t
+//--- foo.h
+//--- tu.c
+asm(".incbin \"foo.h\"");
+// RUN: cd %t
+// RUN: %clang -c -emit-llvm %t/tu.c -o %t/tu.ll
+// RUN: llvm-dis %t/tu.ll -o - | FileCheck %s
+// CHECK: module asm ".incbin \22foo.h\22"
diff --git a/llvm/lib/Object/ModuleSymbolTable.cpp 
b/llvm/lib/Object/ModuleSymbolTable.cpp
index 9442becdb7d33..2063254f519e8 100644
--- a/llvm/lib/Object/ModuleSymbolTable.cpp
+++ b/llvm/lib/Object/ModuleSymbolTable.cpp
@@ -36,9 +36,11 @@
 #include "llvm/Object/SymbolicFile.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/IOSandbox.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/SMLoc.h"
 #include "llvm/Support/SourceMgr.h"
+#include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/TargetParser/Triple.h"
 #include <cassert>
@@ -100,7 +102,11 @@ initializeRecordStreamer(const Module &M,
 
   std::unique_ptr<MemoryBuffer> Buffer(
       MemoryBuffer::getMemBuffer(InlineAsm, "<inline asm>"));
-  SourceMgr SrcMgr;
+  SourceMgr SrcMgr([] {
+    // FIXME(sandboxing): Propagate the client's VFS here.
+    auto BypassSandbox = sys::sandbox::scopedDisable();
+    return vfs::getRealFileSystem();
+  }());
   SrcMgr.AddNewSourceBuffer(std::move(Buffer), SMLoc());
 
   MCContext MCCtx(TT, MAI.get(), MRI.get(), STI.get(), &SrcMgr);

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to