~ubuntu-branches/ubuntu/vivid/virtualbox-ose/vivid

« back to all changes in this revision

Viewing changes to src/VBox/Additions/common/crOpenGL/fakedri_drv.c

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2010-03-11 17:16:37 UTC
  • mfrom: (0.3.4 upstream) (0.4.8 sid)
  • Revision ID: james.westby@ubuntu.com-20100311171637-43z64ia3ccpj8vqn
Tags: 3.1.4-dfsg-2ubuntu1
* Merge from Debian unstable (LP: #528561), remaining changes:
  - VirtualBox should go in Accessories, not in System tools (LP: #288590)
    - debian/virtualbox-ose-qt.files/virtualbox-ose.desktop
  - Add Apport hook
    - debian/virtualbox-ose.files/source_virtualbox-ose.py
    - debian/virtualbox-ose.install
  - Add Launchpad integration
    - debian/control
    - debian/lpi-bug.xpm
    - debian/patches/u02-lp-integration.dpatch
  - Replace *-source packages with transitional packages for *-dkms
* Fix crash in vboxvideo_drm with kernel 2.6.33 / backported drm code
  (LP: #535297)
* Add a list of linux-headers packages to the apport hook
* Update debian/patches/u02-lp-integration.dpatch with a
  DEP-3 compliant header
* Add ${misc:Depends} to virtualbox-ose-source and virtualbox-ose-guest-source
  Depends

Show diffs side-by-side

added added

removed removed

Lines of Context:
139
139
    int rv;
140
140
    void *alPatch;
141
141
    void *pMesaEntry;
142
 
#ifdef RT_ARCH_AMD64
143
142
    char patch[5];
144
143
    void *shift;
145
 
#endif
146
144
 
147
145
#ifndef VBOX_NO_MESA_PATCH_REPORTS
148
 
    crDebug("");
149
 
    crDebug("vboxPatchMesaExport: %s", psFuncName);
 
146
    crDebug("\nvboxPatchMesaExport: %s", psFuncName);
150
147
#endif
151
148
 
152
149
    pMesaEntry = dlsym(RTLD_DEFAULT, psFuncName);
171
168
        int rv;
172
169
 
173
170
        rv = dladdr1(pStart, &dlip1, (void**)&sym1, RTLD_DL_SYMENT);
174
 
        if (!rv || !sym)
 
171
        if (!rv || !sym1)
175
172
        {
176
173
            crError("Failed to get size for %p", pStart);
177
174
            return;
187
184
    crDebug("Vbox code: start: %p, end %p, size: %i", pStart, pEnd, pEnd-pStart);
188
185
#endif
189
186
 
 
187
#ifndef VBOX_OGL_GLX_USE_CSTUBS
190
188
    if (sym->st_size<(pEnd-pStart))
 
189
#endif
191
190
    {
192
 
#ifdef RT_ARCH_AMD64
193
 
        /* Try to insert 5 bytes jmpq to our stub code */
 
191
        /* Try to insert 5 bytes jmp/jmpq to our stub code */
194
192
 
195
193
        if (5>(pEnd-pStart))
196
194
        {
198
196
            return;
199
197
        }
200
198
 
201
 
        shift = pStart-(dlip.dli_saddr+5);
 
199
        shift = (void*)((intptr_t)pStart-((intptr_t)dlip.dli_saddr+5));
202
200
# ifndef VBOX_NO_MESA_PATCH_REPORTS
203
 
        crDebug("Size is small, inserting jmpq with shift %p instead", shift);
 
201
        crDebug("Inserting jmp[q] with shift %p instead", shift);
204
202
# endif
205
203
 
206
 
        if ( ((((long)shift)&0x00000000) != 0) 
207
 
             && ((((long)shift)&0x00000000) != 0xFFFFFFFF00000000))
 
204
#ifdef RT_ARCH_AMD64
208
205
        {
209
 
            crDebug("Can't patch offset is too big.(%s)", psFuncName);
210
 
            return;
 
206
            int64_t offset = (intptr_t)shift;
 
207
 
 
208
            if (offset>INT32_MAX || offset<INT32_MIN)
 
209
            {
 
210
                crDebug("Can't patch offset is too big.(%s)", psFuncName);
 
211
                return;
 
212
            }
211
213
        }
 
214
#endif
212
215
 
213
216
        patch[0] = 0xE9;
214
217
        patch[1] = ((char*)&shift)[0];
221
224
# endif
222
225
        pStart = &patch[0];
223
226
        pEnd = &patch[5];
224
 
#else
225
 
        crDebug("Can't patch size too small.(%s)", psFuncName);
226
 
        return;
227
 
#endif //ifdef RT_ARCH_AMD64
228
227
    }
229
228
 
230
229
    /* Get aligned start adress we're going to patch*/