NewWorldComingSoon / llvm-msvc-issues

Issues about llvm-msvc can be sent here
https://llvm-msvc.win
GNU General Public License v3.0
5 stars 0 forks source link

llvm-msvc-kernelmode 2.6 开发驱动,对函数静态自定义类型对象的初始化仍然有页故障问题 #60

Closed fgmailbox closed 1 year ago

fgmailbox commented 1 year ago

template < ULONG tag > class TestClass { int value = 0; public: TestClass(int value = 0) : value(value){}; };

template < ULONG tag > void test() {

ifdef clang

pragma data_seg(".data")

endif

static int cnt { [](int val) { return val; }(tag) };
int *p_cnt = &cnt;

using TestClass = TestClass<tag>;
// 以下用llvm-msvc-kernelmode 2.6 开发驱动,必定会发生页故障, 
//但是wdk驱动开发工具是不会发生的,
static TestClass testClass1(tag+100);

static  TestClass testClass2(tag + 200);

static  TestClass testClass4 {[](int val) { return val; }(tag)};

ifdef clang

static thread_local int thr_cnt = [](auto val) { return val; }(tag + 1000);
int *p_thr_cnt = &thr_cnt;
static thread_local int thr_cnt2 = tag + 1000;
int *p_thr_cnt2 = &thr_cnt2;

static thread_local TestClass testClass3(tag + 300);

endif

ifdef clang

pragma data_seg()

endif

}

extern "C" NTSTATUS DriverEntry( IN PDRIVER_OBJECT driverObject, IN PUNICODE_STRING registryPath ) { test<128>(); }

fgmailbox commented 1 year ago

c++里面的自定义的静态类型初始化都会发生这样的问题

fgmailbox commented 1 year ago

llvm-msvc-kernel-driver.cpp.txt

fgmailbox commented 1 year ago

DriverTest2.zip