mirror of
https://github.com/mpv-player/mpv
synced 2025-03-06 14:17:46 +00:00
Change add_stub code to also work without -fomit-frame-pointer
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@21381 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
b2dce56aad
commit
383008da88
@ -5272,67 +5272,30 @@ struct libs libraries[]={
|
|||||||
|
|
||||||
static void ext_stubs(void)
|
static void ext_stubs(void)
|
||||||
{
|
{
|
||||||
// expects:
|
volatile int idx = 0xdeadabcd;
|
||||||
// ax position index
|
printf("Called unk_%s\n", export_names[idx]);
|
||||||
// cx address of printf function
|
|
||||||
#if 1
|
|
||||||
__asm__ __volatile__
|
|
||||||
(
|
|
||||||
"push %%edx \n\t"
|
|
||||||
"movl $0xdeadbeef, %%eax \n\t"
|
|
||||||
"movl $0xdeadbeef, %%edx \n\t"
|
|
||||||
"shl $5, %%eax \n\t" // ax * 32
|
|
||||||
"addl $0xdeadbeef, %%eax \n\t" // overwrite export_names
|
|
||||||
"pushl %%eax \n\t"
|
|
||||||
"pushl $0xdeadbeef \n\t" // overwrite called_unk
|
|
||||||
"call *%%edx \n\t" // printf (via dx)
|
|
||||||
"addl $8, %%esp \n\t"
|
|
||||||
"xorl %%eax, %%eax \n\t"
|
|
||||||
"pop %%edx \n\t"
|
|
||||||
:
|
|
||||||
:
|
|
||||||
: "eax"
|
|
||||||
);
|
|
||||||
#else
|
|
||||||
__asm__ __volatile__
|
|
||||||
(
|
|
||||||
"push %%edx \n\t"
|
|
||||||
"movl $0, %%eax \n\t"
|
|
||||||
"movl $0, %%edx \n\t"
|
|
||||||
"shl $5, %%eax \n\t" // ax * 32
|
|
||||||
"addl %0, %%eax \n\t"
|
|
||||||
"pushl %%eax \n\t"
|
|
||||||
"pushl %1 \n\t"
|
|
||||||
"call *%%edx \n\t" // printf (via dx)
|
|
||||||
"addl $8, %%esp \n\t"
|
|
||||||
"xorl %%eax, %%eax \n\t"
|
|
||||||
"pop %%edx \n\t"
|
|
||||||
::"m"(*export_names), "m"(*called_unk)
|
|
||||||
: "memory", "edx", "eax"
|
|
||||||
);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//static void add_stub(int pos)
|
//static void add_stub(int pos)
|
||||||
|
|
||||||
static int pos=0;
|
static int pos=0;
|
||||||
static char extcode[20000];// place for 200 unresolved exports
|
static char extcode[20000];// place for 200 unresolved exports
|
||||||
static const char* called_unk = "Called unk_%s\n";
|
|
||||||
|
|
||||||
static void* add_stub(void)
|
static void* add_stub(void)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
// generated code in runtime!
|
// generated code in runtime!
|
||||||
char* answ = (char*)extcode+pos*0x30;
|
char* answ = (char*)extcode+pos*0x30;
|
||||||
memcpy(answ, ext_stubs, 0x2f); // 0x2c is current size
|
memcpy(answ, ext_stubs, 0x2f); // 0x2c is current size
|
||||||
//answ[4] = 0xb8; // movl $0, eax (0xb8 0x00000000)
|
for (i = 0; i < 0x30 - 3; i++) {
|
||||||
*((int*) (answ + 5)) = pos;
|
if (*(int*)(answ + i) == 0xdeadabcd)
|
||||||
//answ[9] = 0xba; // movl $0, edx (0xba 0x00000000)
|
break;
|
||||||
*((long*) (answ + 10)) = (long)printf;
|
}
|
||||||
//answ[17] = 0x05; // addl $0, eax (0x05 0x00000000)
|
if (*(int*)(answ + i) != 0xdeadabcd) {
|
||||||
*((long*) (answ + 18)) = (long)export_names;
|
printf("magic code not found in ext_subs, expect crash\n");
|
||||||
//answ[23] = 0x68; // pushl $0 (0x68 0x00000000)
|
return NULL;
|
||||||
*((long*) (answ + 24)) = (long)called_unk;
|
}
|
||||||
|
*(int*)(answ + i) = pos;
|
||||||
pos++;
|
pos++;
|
||||||
return (void*)answ;
|
return (void*)answ;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user