VirtualBox

Changeset 34204 in vbox for trunk/src


Ignore:
Timestamp:
Nov 19, 2010 3:02:11 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
67946
Message:

crOpenGL: use jmp chain only when necessary

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/crOpenGL/fakedri_drv.c

    r34198 r34204  
    174174}
    175175
    176 #ifdef RT_ARCH_AMD64
    177 # define FAKEDRI_JMP64_PATCH_SIZE 13
    178 #endif
     176#define FAKEDRI_JMP64_PATCH_SIZE 13
    179177
    180178static void
     
    186184    void *alPatch;
    187185    void *pMesaEntry;
    188     char patch[5];
     186    char patch[FAKEDRI_JMP64_PATCH_SIZE];
    189187    void *shift;
    190188
     
    237235#endif
    238236    {
     237#ifdef RT_ARCH_AMD64
     238        int64_t offset;
     239#endif
    239240        /* Try to insert 5 bytes jmp/jmpq to our stub code */
    240241
     
    243244            if (crStrcmp(psFuncName, "glXCreateGLXPixmapMESA"))
    244245            {
    245                 crError("Can't patch size too small.(%s)", psFuncName);
     246                crError("Can't patch size is too small.(%s)", psFuncName);
    246247            }
    247248            return;
     
    249250
    250251        shift = (void*)((intptr_t)pStart-((intptr_t)dlip.dli_saddr+5));
    251 #ifndef VBOX_NO_MESA_PATCH_REPORTS
    252         crDebug("Inserting jmp[q] with shift %p instead", shift);
    253 #endif
    254 
    255252#ifdef RT_ARCH_AMD64
    256         {
    257             int64_t offset = (intptr_t)shift;
    258 
    259             if (offset>INT32_MAX || offset<INT32_MIN)
     253        offset = (intptr_t)shift;
     254        if (offset>INT32_MAX || offset<INT32_MIN)
     255        {
     256            /*try to insert 64bit abs jmp*/
     257            if (sym->st_size>=FAKEDRI_JMP64_PATCH_SIZE)
     258            {
     259# ifndef VBOX_NO_MESA_PATCH_REPORTS
     260                crDebug("Inserting movq/jmp instead");
     261# endif
     262                /*add 64bit abs jmp*/
     263                patch[0] = 0x49; /*movq %r11,imm64*/
     264                patch[1] = 0xBB;
     265                crMemcpy(&patch[2], &pStart, 8);
     266                patch[10] = 0x41; /*jmp *%r11*/
     267                patch[11] = 0xFF;
     268                patch[12] = 0xE3;
     269                pStart = &patch[0];
     270                pEnd = &patch[FAKEDRI_JMP64_PATCH_SIZE];
     271            }
     272            else
    260273            {
    261274                FAKEDRI_PatchNode *pNode;
     
    280293            }
    281294        }
    282 #endif
    283 
    284         patch[0] = 0xE9;
    285         crMemcpy(&patch[1], &shift, 4);
     295        else
     296#endif
     297        {
    286298#ifndef VBOX_NO_MESA_PATCH_REPORTS
    287         crDebug("Patch: E9 %x", *((int*)&patch[1]));
    288 #endif
    289         pStart = &patch[0];
    290         pEnd = &patch[5];
     299            crDebug("Inserting jmp[q] with shift %p instead", shift);
     300#endif
     301            patch[0] = 0xE9;
     302            crMemcpy(&patch[1], &shift, 4);
     303            pStart = &patch[0];
     304            pEnd = &patch[5];
     305        }
    291306    }
    292307
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette