~ubuntu-branches/ubuntu/trusty/virtualbox-ose/trusty

« 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: 2009-12-18 16:44:29 UTC
  • mfrom: (0.3.3 upstream) (0.4.6 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091218164429-jd34ccexpv5na11a
Tags: 3.1.2-dfsg-1ubuntu1
* Merge from Debian unstable (LP: #498219), remaining changes:
  - Disable update action
    - debian/patches/u01-disable-update-action.dpatch
  - 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
* Fixes the following bugs:
  - Kernel module fails to build with Linux >= 2.6.32 (LP: #474625)
  - X.Org drivers need to be rebuilt against X-Server 1.7 (LP: #495935)
  - The *-source packages try to build the kernel modules even though the
    kernel headers aren't available (LP: #473334)
* Replace *-source packages with transitional packages for *-dkms.
* Adapt u01-disable-update-action.dpatch and u02-lp-integration.dpatch for
  new upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
81
81
#define PAGESIZE 4096
82
82
#endif
83
83
 
 
84
#ifdef RT_ARCH_AMD64
 
85
# define DRI_ELFSYM Elf64_Sym
 
86
#else
 
87
# define DRI_ELFSYM Elf32_Sym
 
88
#endif
 
89
 
84
90
static struct _glapi_table vbox_glapi_table;
85
91
fakedri_glxapi_table glxim;
86
92
 
129
135
vboxPatchMesaExport(const char* psFuncName, const void *pStart, const void *pEnd)
130
136
{
131
137
    Dl_info dlip;
132
 
    Elf32_Sym* sym=0;
 
138
    DRI_ELFSYM* sym=0;
133
139
    int rv;
134
140
    void *alPatch;
135
141
    void *pMesaEntry;
 
142
#ifdef RT_ARCH_AMD64
 
143
    char patch[5];
 
144
    void *shift;
 
145
#endif
136
146
 
137
147
#ifndef VBOX_NO_MESA_PATCH_REPORTS
 
148
    crDebug("");
138
149
    crDebug("vboxPatchMesaExport: %s", psFuncName);
139
150
#endif
140
151
 
156
167
#if VBOX_OGL_GLX_USE_CSTUBS
157
168
    {
158
169
        Dl_info dlip1;
159
 
        Elf32_Sym* sym1=0;
 
170
        DRI_ELFSYM* sym1=0;
160
171
        int rv;
161
172
 
162
173
        rv = dladdr1(pStart, &dlip1, (void**)&sym1, RTLD_DL_SYMENT);
178
189
 
179
190
    if (sym->st_size<(pEnd-pStart))
180
191
    {
 
192
#ifdef RT_ARCH_AMD64
 
193
        /* Try to insert 5 bytes jmpq to our stub code */
 
194
 
 
195
        if (5>(pEnd-pStart))
 
196
        {
 
197
            crDebug("Can't patch size too small.(%s)", psFuncName);
 
198
            return;
 
199
        }
 
200
 
 
201
        shift = pStart-(dlip.dli_saddr+5);
 
202
# ifndef VBOX_NO_MESA_PATCH_REPORTS
 
203
        crDebug("Size is small, inserting jmpq with shift %p instead", shift);
 
204
# endif
 
205
 
 
206
        if ( ((((long)shift)&0x00000000) != 0) 
 
207
             && ((((long)shift)&0x00000000) != 0xFFFFFFFF00000000))
 
208
        {
 
209
            crDebug("Can't patch offset is too big.(%s)", psFuncName);
 
210
            return;
 
211
        }
 
212
 
 
213
        patch[0] = 0xE9;
 
214
        patch[1] = ((char*)&shift)[0];
 
215
        patch[2] = ((char*)&shift)[1];
 
216
        patch[3] = ((char*)&shift)[2];
 
217
        patch[4] = ((char*)&shift)[3];
 
218
 
 
219
# ifndef VBOX_NO_MESA_PATCH_REPORTS
 
220
        crDebug("Patch: E9 %x", *((int*)&patch[1]));
 
221
# endif
 
222
        pStart = &patch[0];
 
223
        pEnd = &patch[5];
 
224
#else
181
225
        crDebug("Can't patch size too small.(%s)", psFuncName);
182
226
        return;
 
227
#endif //ifdef RT_ARCH_AMD64
183
228
    }
184
229
 
185
230
    /* Get aligned start adress we're going to patch*/