Skip to content

Commit af42d37

Browse files
committed
rustllvm: Fix RustWrapper.cpp
1 parent f903ae9 commit af42d37

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

src/rustllvm/RustWrapper.cpp

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
//
1616
//===----------------------------------------------------------------------===
1717

18+
#include "llvm/IR/InlineAsm.h"
19+
#include "llvm/IR/LLVMContext.h"
1820
#include "llvm/Linker.h"
1921
#include "llvm/PassManager.h"
2022
#include "llvm/IR/InlineAsm.h"
@@ -152,7 +154,9 @@ class RustMCJITMemoryManager : public JITMemoryManager {
152154
unsigned SectionID);
153155

154156
virtual uint8_t *allocateDataSection(uintptr_t Size, unsigned Alignment,
155-
unsigned SectionID);
157+
unsigned SectionID, bool isReadOnly);
158+
159+
virtual bool applyPermissions(std::string *Str);
156160

157161
virtual void *getPointerToNamedFunction(const std::string &Name,
158162
bool AbortOnFailure = true);
@@ -240,18 +244,24 @@ bool RustMCJITMemoryManager::loadCrate(const char* file, std::string* err) {
240244
}
241245

242246
uint8_t *RustMCJITMemoryManager::allocateDataSection(uintptr_t Size,
243-
unsigned Alignment,
244-
unsigned SectionID) {
247+
unsigned Alignment,
248+
unsigned SectionID,
249+
bool isReadOnly) {
245250
if (!Alignment)
246251
Alignment = 16;
247252
uint8_t *Addr = (uint8_t*)calloc((Size + Alignment - 1)/Alignment, Alignment);
248253
AllocatedDataMem.push_back(sys::MemoryBlock(Addr, Size));
249254
return Addr;
250255
}
251256

257+
bool RustMCJITMemoryManager::applyPermissions(std::string *Str) {
258+
// Empty.
259+
return true;
260+
}
261+
252262
uint8_t *RustMCJITMemoryManager::allocateCodeSection(uintptr_t Size,
253-
unsigned Alignment,
254-
unsigned SectionID) {
263+
unsigned Alignment,
264+
unsigned SectionID) {
255265
if (!Alignment)
256266
Alignment = 16;
257267
unsigned NeedAllocate = Alignment * ((Size + Alignment - 1)/Alignment + 1);
@@ -485,13 +495,12 @@ LLVMRustWriteOutputFile(LLVMPassManagerRef PMR,
485495
}
486496

487497
extern "C" LLVMModuleRef LLVMRustParseAssemblyFile(const char *Filename) {
488-
489498
SMDiagnostic d;
490499
Module *m = ParseAssemblyFile(Filename, d, getGlobalContext());
491500
if (m) {
492501
return wrap(m);
493502
} else {
494-
LLVMRustError = d.getMessage().data();
503+
LLVMRustError = d.getMessage().str().c_str();
495504
return NULL;
496505
}
497506
}

0 commit comments

Comments
 (0)