Skip to content

Commit 506bc47

Browse files
committed
[Target] Allow BTFDebug in IO sandbox
1 parent 37afa44 commit 506bc47

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

llvm/lib/Target/BPF/BTFDebug.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "llvm/MC/MCSectionELF.h"
2626
#include "llvm/MC/MCStreamer.h"
2727
#include "llvm/Support/ErrorHandling.h"
28+
#include "llvm/Support/IOSandbox.h"
2829
#include "llvm/Support/LineIterator.h"
2930
#include "llvm/Support/MemoryBuffer.h"
3031
#include "llvm/Target/TargetLoweringObjectFile.h"
@@ -1108,12 +1109,17 @@ std::string BTFDebug::populateFileContent(const DIFile *File) {
11081109
std::string Line;
11091110
Content.push_back(Line); // Line 0 for empty string
11101111

1112+
auto LoadFile = [](StringRef FileName) {
1113+
// FIXME(sandboxing): Propagating vfs::FileSystem here is lots of work.
1114+
auto BypassSandbox = sys::sandbox::scopedDisable();
1115+
return MemoryBuffer::getFile(FileName);
1116+
};
1117+
11111118
std::unique_ptr<MemoryBuffer> Buf;
11121119
auto Source = File->getSource();
11131120
if (Source)
11141121
Buf = MemoryBuffer::getMemBufferCopy(*Source);
1115-
else if (ErrorOr<std::unique_ptr<MemoryBuffer>> BufOrErr =
1116-
MemoryBuffer::getFile(FileName))
1122+
else if (ErrorOr<std::unique_ptr<MemoryBuffer>> BufOrErr = LoadFile(FileName))
11171123
Buf = std::move(*BufOrErr);
11181124
if (Buf)
11191125
for (line_iterator I(*Buf, false), E; I != E; ++I)

0 commit comments

Comments
 (0)