簡體   English   中英

堅持將 64 位 masm 實現的 OpenGL API 加載器移植到 32 位實現的加載器

[英]Stuck on porting OpenGL API loader implemented by 64-bit masm to that implemented by 32-bit

我最近在移植一個64位masm實現的OpenGL API loader到32位的loader,64位的部分源碼如下:

.code

extrn __blue_glCore_glMultiDrawArraysIndirectBindlessCountNV: qword
glMultiDrawArraysIndirectBindlessCountNV proc
    mov r11, __blue_glCore_glMultiDrawArraysIndirectBindlessCountNV
    jmp r11
glMultiDrawArraysIndirectBindlessCountNV endp

extrn __blue_glCore_glCopyTexImage1D: qword
glCopyTexImage1D proc
    mov r11, __blue_glCore_glCopyTexImage1D
    jmp r11
glCopyTexImage1D endp
...

例如,外部符號__blue_glCore_glMultiDrawArraysIndirectBindlessCountNV將在調用glMultiDrawArraysIndirectBindlessCountNV時加載。 我的 32 位修改(將所有qword更改為dword ,將所有r11更改為eax )是:

.model flat
.code

extrn __blue_glCore_glMultiDrawArraysIndirectBindlessCountNV: dword
glMultiDrawArraysIndirectBindlessCountNV proc
    mov eax, __blue_glCore_glMultiDrawArraysIndirectBindlessCountNV
    jmp eax
glMultiDrawArraysIndirectBindlessCountNV endp

extrn __blue_glCore_glCopyTexImage1D: dword
glCopyTexImage1D proc
    mov eax, __blue_glCore_glCopyTexImage1D
    jmp eax
glCopyTexImage1D endp

當其他目標在編譯期間鏈接此加載器時,編譯器(我使用 Visual Studio 2019)會抱怨未解決的外部符號錯誤。 我其實對MASM知之甚少,誰能幫幫我?

更新1
我在這個repo中創建了一個迷你演示來重現這個問題,可以直接用 Visual Studio 和 cmake 構建。 特別是,這些讓我感到困惑:

GLint major = 0, minor = 0;
//these two symbol are found
glGetIntegerv(GL_MAJOR_VERSION, &major);
glGetIntegerv(GL_MINOR_VERSION, &minor);
//this symbol is missed
glActiveTexture(0);

為什么只加載了 opengl1.0 和 1.1(opengl32.lib) 的符號而其他符號則未加載?

更新 2 我的 Visual Studio linker抱怨:

Severity    Code    Description Project File    Line    Suppression State
Error   LNK1120 1 unresolved externals  test_bluegl E:\CPPCode\projects\bluegl\build\Debug\test_bluegl.exe  1   
Error   LNK2019 unresolved external symbol _glActiveTexture@4 referenced in function "private: virtual void __thiscall bluegl::BlueGLTest_GetVersion_Test::TestBody(void)" (?TestBody@BlueGLTest_GetVersion_Test@bluegl@@EAEXXZ)    test_bluegl E:\CPPCode\projects\bluegl\build\test_bluegl.obj    1   

然后我使用dumpbin.exe檢查bluegl.lib中生成的符號:

...
55DF0 _glActiveTexture@0
...

所以我將相應的proc更改為:

extrn __blue_glCore_glActiveTexture: dword
glActiveTexture proc param : dword
    mov edx, __blue_glCore_glActiveTexture
    jmp edx
glActiveTexture endp

現在生成的符號是正確的並且鏈接正常,但是出現了新問題:

  1. Visual Studio 將報告:
    Severity    Code    Description Project File    Line    Suppression State
    Error   LNK2026 module unsafe for SAFESEH image.    test_bluegl E:\CPPCode\projects\bluegl\build\bluegl.lib(BlueGLCoreWindowsImpl.obj)  1   
    Error   LNK1281 Unable to generate SAFESEH image.   test_bluegl E:\CPPCode\projects\bluegl\build\Debug\test_bluegl.exe  1

沒有為 masm 源設置/safeseh屬性。
2 每個api的append參數列表太重了,不知道為什么64位masm不需要參數列表。

Select 一個 C 實現作為解決方法,但仍然對 masm32 實現感興趣。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM