Ticket #514: mp.patch
| File mp.patch, 13.0 KB (added by , 20 years ago) |
|---|
-
help/help_mp-en.h
diff -rNbu MPlayer-1.0pre82/help/help_mp-en.h MPlayer-1.0pre8/help/help_mp-en.h
old new 1814 1814 // libvo/vo_xv.c 1815 1815 1816 1816 #define MSGTR_LIBVO_XV_DrawFrameCalled "[VO_XV] draw_frame() called!!!!!!\n" 1817 1818 // loader/ldt_keeper.c 1819 1820 #define MSGTR_LOADER_DYLD_Warning "WARNING: Attempting to use DLL codecs but environment variable DYLD_BIND_AT_LAUNCH not set.\nThis will likely crash.\n" -
loader/Makefile
diff -rNbu MPlayer-1.0pre82/loader/Makefile MPlayer-1.0pre8/loader/Makefile
old new 9 9 else 10 10 LIB_OBJECTS= ldt_keeper.o pe_image.o module.o ext.o win32.o \ 11 11 driver.o pe_resource.o resource.o registry.o \ 12 elfdll.o afl.o vfl.o wrapper.o 12 elfdll.o afl.o vfl.o mmap_anon.o 13 14 # QTX emulation is not supported in Darwin 15 ifneq ($(TARGET_OS),Darwin) 16 LIB_OBJECTS+=wrapper.o 17 endif 18 19 endif 20 21 # stubs_bsd.s for OpenBSD and Darwin, and stubs.s for the rest 22 ifeq ($(TARGET_OS),Darwin) 23 LIB_OBJECTS+=stubs_bsd.o 24 else 25 ifeq ($(TARGET_OS),OpenBSD) 26 LIB_OBJECTS+=stubs_bsd.o 27 else 28 LIB_OBJECTS+=stubs.o 29 endif 13 30 endif 14 31 15 32 # gcc-3.0 produces buggy code for acmStreamOpen() with … … 34 51 .c.o: 35 52 $(CC) $(CFLAGS) $(DEFINES) -c $< 36 53 37 libloader.a: $(LIB_OBJECTS) stubs.s 38 $(CC) -c ./stubs.s -o stubs.o 39 ifeq ($(TARGET_OS),OpenBSD) 40 ./loader_objfix.sh 41 endif 42 $(AR) -r libloader.a $(LIB_OBJECTS) stubs.o 54 libloader.a: $(LIB_OBJECTS) 55 $(AR) -r libloader.a $(LIB_OBJECTS) 43 56 $(RANLIB) libloader.a 44 57 45 58 dep: -
loader/ext.c
diff -rNbu MPlayer-1.0pre82/loader/ext.c MPlayer-1.0pre8/loader/ext.c
old new 26 26 #include <stdarg.h> 27 27 #include <ctype.h> 28 28 29 #include <mmap_anon.h> 30 29 31 #include "wine/windef.h" 30 32 #include "wine/winbase.h" 31 33 #include "wine/debugtools.h" … … 233 235 234 236 //#define MAP_PRIVATE 235 237 //#define MAP_SHARED 236 #undef MAP_ANON237 238 LPVOID FILE_dommap( int unix_handle, LPVOID start, 238 239 DWORD size_high, DWORD size_low, 239 240 DWORD offset_high, DWORD offset_low, … … 248 249 249 250 if (unix_handle == -1) 250 251 { 251 #ifdef MAP_ANON 252 // printf("Anonymous\n"); 253 flags |= MAP_ANON; 254 #else 255 static int fdzero = -1; 256 257 if (fdzero == -1) 258 { 259 if ((fdzero = open( "/dev/zero", O_RDONLY )) == -1) 260 { 261 perror( "Cannot open /dev/zero for READ. Check permissions! error: " ); 262 exit(1); 252 ret = mmap_anon( start, size_low, prot, flags, offset_low, &fd ); 263 253 } 254 else { 255 fd = unix_handle; 256 ret = mmap( start, size_low, prot, flags, fd, offset_low ); 264 257 } 265 fd = fdzero; 266 #endif /* MAP_ANON */ 267 /* Linux EINVAL's on us if we don't pass MAP_PRIVATE to an anon mmap */ 268 #ifdef MAP_SHARED 269 flags &= ~MAP_SHARED; 270 #endif 271 #ifdef MAP_PRIVATE 272 flags |= MAP_PRIVATE; 273 #endif 274 } 275 else fd = unix_handle; 276 // printf("fd %x, start %x, size %x, pos %x, prot %x\n",fd,start,size_low, offset_low, prot); 277 // if ((ret = mmap( start, size_low, prot, 278 // flags, fd, offset_low )) != (LPVOID)-1) 279 if ((ret = mmap( start, size_low, prot, 280 MAP_PRIVATE | MAP_FIXED, fd, offset_low )) != (LPVOID)-1) 258 259 if (ret != (LPVOID)-1) 281 260 { 282 261 // printf("address %08x\n", *(int*)ret); 283 262 // printf("%x\n", ret); … … 370 349 LPVOID answer; 371 350 int anon=0; 372 351 int mmap_access=0; 352 373 353 if(hFile<0) 374 {375 354 anon=1; 376 hFile=open("/dev/zero", O_RDWR); 377 if(hFile<0){ 378 perror( "Cannot open /dev/zero for READ+WRITE. Check permissions! error: " ); 379 return 0; 380 } 381 } 355 382 356 if(!anon) 383 357 { 384 358 len=lseek(hFile, 0, SEEK_END); … … 391 365 else 392 366 mmap_access |=PROT_READ|PROT_WRITE; 393 367 394 answer=mmap(NULL, len, mmap_access, MAP_PRIVATE, hFile, 0);395 368 if(anon) 369 answer=mmap_anon(NULL, len, mmap_access, MAP_PRIVATE, 0, &hFile); 370 else 371 answer=mmap(NULL, len, mmap_access, MAP_PRIVATE, hFile, 0); 372 373 if(anon && hFile != -1) 396 374 close(hFile); 397 375 if(answer!=(LPVOID)-1) 398 376 { … … 418 396 fm->name=NULL; 419 397 fm->mapping_size=len; 420 398 421 if(anon )399 if(anon && hFile != -1) 422 400 close(hFile); 423 401 return (HANDLE)answer; 424 402 } … … 471 449 472 450 if ((type&(MEM_RESERVE|MEM_COMMIT)) == 0) return NULL; 473 451 474 fd=open("/dev/zero", O_RDWR);475 if(fd<0){476 perror( "Cannot open /dev/zero for READ+WRITE. Check permissions! error: " );477 return NULL;478 }479 480 452 if (type&MEM_RESERVE && (unsigned)address&0xffff) { 481 453 size += (unsigned)address&0xffff; 482 454 address = (unsigned)address&~0xffff; … … 513 485 && ((unsigned)address+size<=(unsigned)str->address+str->mapping_size) 514 486 && (type & MEM_COMMIT)) 515 487 { 516 close(fd);517 488 return address; //returning previously reserved memory 518 489 } 519 490 //printf(" VirtualAlloc(...) does not commit or not entirely within reserved, and\n"); 520 491 } 521 492 /*printf(" VirtualAlloc(...) (0x%08X, %u) overlaps with (0x%08X, %u, state=%d)\n", 522 493 (unsigned)address, size, (unsigned)str->address, str->mapping_size, str->state);*/ 523 close(fd);524 494 return NULL; 525 495 } 526 496 } 527 497 528 answer=mmap(address, size, PROT_READ | PROT_WRITE | PROT_EXEC, 529 MAP_PRIVATE, fd, 0); 498 answer=mmap_anon(address, size, PROT_READ | PROT_WRITE | PROT_EXEC, 499 MAP_PRIVATE, 0, &fd); 500 530 501 // answer=FILE_dommap(-1, address, 0, size, 0, 0, 531 502 // PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE); 503 if (fd != -1) 532 504 close(fd); 533 505 if (answer != (void *)-1 && address && answer != address) { 534 506 /* It is dangerous to try mmap() with MAP_FIXED since it does not -
loader/ldt_keeper.c
diff -rNbu MPlayer-1.0pre82/loader/ldt_keeper.c MPlayer-1.0pre8/loader/ldt_keeper.c
old new 28 28 #include <sys/types.h> 29 29 #include <stdio.h> 30 30 #include <unistd.h> 31 32 #include <mmap_anon.h> 33 #include <mp_msg.h> 34 #include <help_mp.h> 35 31 36 #ifdef __linux__ 32 37 #include <asm/unistd.h> 33 38 #include <asm/ldt.h> … … 102 107 #define LDT_SEL(idx) ((idx) << 3 | 1 << 2 | 3) 103 108 104 109 /* i got this value from wine sources, it's the first free LDT entry */ 105 #if defined(__FreeBSD__) && defined(LDT_AUTO_ALLOC)110 #if (defined(__APPLE__) || defined(__FreeBSD__)) && defined(LDT_AUTO_ALLOC) 106 111 #define TEB_SEL_IDX LDT_AUTO_ALLOC 112 #define USE_LDT_AA 107 113 #endif 108 114 109 115 #ifndef TEB_SEL_IDX … … 167 173 #endif 168 174 #endif 169 175 170 #if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) 176 #if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(__APPLE__) 171 177 static void LDT_EntryToBytes( unsigned long *buffer, const struct modify_ldt_ldt_s *content ) 172 178 { 173 179 *buffer++ = ((content->base_addr & 0x0000ffff) << 16) | … … 194 200 if (!ldt_fs) 195 201 return NULL; 196 202 197 ldt_fs->fd = open("/dev/zero", O_RDWR); 198 if (ldt_fs->fd<0){199 perror( "Cannot open /dev/zero for READ+WRITE. Check permissions! error: ");200 return NULL; 201 } 203 #ifdef __APPLE__ 204 if (getenv("DYLD_BIND_AT_LAUNCH") == NULL) 205 mp_msg(MSGT_LOADER, MSGL_WARN, MSGTR_LOADER_DYLD_Warning); 206 #endif /* __APPLE__ */ 207 202 208 fs_seg= 203 ldt_fs->fs_seg = mmap (NULL, getpagesize(), PROT_READ | PROT_WRITE, MAP_PRIVATE,204 ldt_fs->fd, 0);209 ldt_fs->fs_seg = mmap_anon(NULL, getpagesize(), PROT_READ | PROT_WRITE, MAP_PRIVATE, 210 0, &ldt_fs->fd); 205 211 if (ldt_fs->fs_seg == (void*)-1) 206 212 { 207 213 perror("ERROR: Couldn't allocate memory for fs segment"); … … 229 235 } 230 236 #endif /*linux*/ 231 237 232 #if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) 238 #if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(__APPLE__) 233 239 { 234 240 unsigned long d[2]; 235 241 236 242 LDT_EntryToBytes( d, &array ); 237 #if defined(__FreeBSD__) && defined(LDT_AUTO_ALLOC)243 #ifdef USE_LDT_AA 238 244 ret = i386_set_ldt(LDT_AUTO_ALLOC, (union descriptor *)d, 1); 239 245 array.entry_number = ret; 240 246 fs_ldt = ret; … … 251 257 #endif 252 258 } 253 259 } 254 #endif /* __NetBSD__ || __FreeBSD__ || __OpenBSD__ || __DragonFly__ */260 #endif /* __NetBSD__ || __FreeBSD__ || __OpenBSD__ || __DragonFly__ || __APPLE__ */ 255 261 256 262 #if defined(__svr4__) 257 263 { … … 286 292 free(ldt_fs->prev_struct); 287 293 munmap((char*)ldt_fs->fs_seg, getpagesize()); 288 294 ldt_fs->fs_seg = 0; 295 if (ldt_fs->fd != -1) 289 296 close(ldt_fs->fd); 290 297 free(ldt_fs); 291 298 } -
loader/mmap_anon.c
diff -rNbu MPlayer-1.0pre82/loader/mmap_anon.c MPlayer-1.0pre8/loader/mmap_anon.c
old new 1 /* 2 * mmap_anon.c: provide a compatible anonymous space mapping function 3 */ 4 5 #include <sys/mman.h> 6 #include <stdio.h> 7 #include <unistd.h> 8 #include <fcntl.h> 9 10 /* 11 * mmap() anonymous space, depending on the system's mmap() style. On systems 12 * that use the /dev/zero mapping idiom, zerofd will be set to the file descriptor 13 * of the opened /dev/zero. 14 */ 15 void *mmap_anon(void *addr, size_t len, int prot, int flags, off_t offset, int *zerofd) 16 { 17 int fd; 18 void *result; 19 20 /* From loader/ext.c: 21 * "Linux EINVAL's on us if we don't pass MAP_PRIVATE to an anon mmap" 22 * Therefore we preserve the same behavior on all platforms, ie. no 23 * shared mappings of anon space (if the concepts are supported). */ 24 #if defined(MAP_SHARED) && defined(MAP_PRIVATE) 25 flags = (flags & ~MAP_SHARED) | MAP_PRIVATE; 26 #endif /* defined(MAP_SHARED) && defined(MAP_PRIVATE) */ 27 28 #ifdef __APPLE__ 29 /* BSD-style anonymous mapping */ 30 fd = -1; 31 result = mmap(addr, len, prot, flags | MAP_ANON, -1, offset); 32 #else 33 /* SysV-style anonymous mapping */ 34 fd = open("/dev/zero", O_RDWR); 35 if(fd < 0){ 36 perror( "Cannot open /dev/zero for READ+WRITE. Check permissions! error: "); 37 return NULL; 38 } 39 40 result = mmap(addr, len, prot, flags, fd, offset); 41 #endif /* __APPLE__ */ 42 43 if (zerofd) 44 *zerofd = fd; 45 46 return result; 47 } 48 -
loader/mmap_anon.h
diff -rNbu MPlayer-1.0pre82/loader/mmap_anon.h MPlayer-1.0pre8/loader/mmap_anon.h
old new 1 #ifndef _OSDEP_MMAP_ANON_H_ 2 #define _OSDEP_MMAP_ANON_H_ 3 4 #include <sys/types.h> 5 6 void *mmap_anon(void *, size_t, int, int, off_t, int *); 7 8 #endif /* _OSDEP_MMAP_ANON_H_ */ -
loader/module.c
diff -rNbu MPlayer-1.0pre82/loader/module.c MPlayer-1.0pre8/loader/module.c
old new 10 10 */ 11 11 12 12 // define for quicktime calls debugging and/or MacOS-level emulation: 13 // (not supported on OS X yet) 14 #ifndef __APPLE__ 13 15 #define EMU_QTX_API 16 #endif /* __APPLE__ */ 14 17 15 18 // define for quicktime debugging (verbose logging): 16 19 //#define DEBUG_QTX_API -
loader/stubs_bsd.s
diff -rNbu MPlayer-1.0pre82/loader/stubs_bsd.s MPlayer-1.0pre8/loader/stubs_bsd.s
old new 1 .data 2 .LC0: .asciz "Called unk_%s\n" 3 .p2align 2 4 .globl _unk_exp1 5 _unk_exp1: 6 pushl %ebp 7 movl %esp,%ebp 8 subl $4,%esp 9 movl $1,-4(%ebp) 10 movl -4(%ebp),%eax 11 movl %eax,%ecx 12 movl %ecx,%edx 13 sall $4,%edx 14 subl %eax,%edx 15 leal 0(,%edx,2),%eax 16 movl %eax,%edx 17 addl $_export_names,%edx 18 pushl %edx 19 pushl $.LC0 20 call _printf 21 addl $8,%esp 22 xorl %eax,%eax 23 leave 24 ret 25 .globl _exp_EH_prolog 26 _exp_EH_prolog: 27 pushl $0xff 28 pushl %eax 29 pushl %fs:0 30 movl %esp, %fs:0 31 movl 12(%esp), %eax 32 movl %ebp, 12(%esp) 33 leal 12(%esp), %ebp 34 pushl %eax 35 ret -
loader/wine/poppack.h
diff -rNbu MPlayer-1.0pre82/loader/wine/poppack.h MPlayer-1.0pre8/loader/wine/poppack.h
old new 1 1 #ifdef __WINE_PSHPACK_H 2 2 #undef __WINE_PSHPACK_H 3 3 4 #if defined(__GNUC__) || defined(__SUNPRO_C)4 #if (defined(__GNUC__) || defined(__SUNPRO_C)) && !defined(__APPLE__) 5 5 #pragma pack() 6 #elif defined(__SUNPRO_CC) 6 #elif defined(__SUNPRO_CC) || defined(__APPLE__) 7 7 #warning "Assumes default alignment is 4" 8 8 #pragma pack(4) 9 9 #elif !defined(RC_INVOKED) -
MPlayer-1.
diff -rNbu MPlayer-1.0pre82/mp_msg.h MPlayer-1.0pre8/mp_msg.h
old new 97 97 98 98 #define MSGT_IDENTIFY 41 // -identify output 99 99 100 #define MSGT_LOADER 42 // dll loader messages 101 100 102 #define MSGT_MAX 64 101 103 102 104 void mp_msg_init(void);
