Mercurial > projects > ldc
comparison runtime/internal/memory.d @ 1289:4a5eea0334e5
Add runtime support for darwin x86_64
author | Benjamin Kramer <benny.kra@gmail.com> |
---|---|
date | Sat, 02 May 2009 16:39:26 +0200 |
parents | 3cf0066e6faf |
children |
comparison
equal
deleted
inserted
replaced
1288:e109e4031e8a | 1289:4a5eea0334e5 |
---|---|
118 } | 118 } |
119 } | 119 } |
120 else version( darwin ) | 120 else version( darwin ) |
121 { | 121 { |
122 // darwin has a fixed stack bottom | 122 // darwin has a fixed stack bottom |
123 return cast(void*) 0xc0000000; | 123 version(X86_64) |
124 return cast(void*) 0x7fff5fc00000; | |
125 else | |
126 return cast(void*) 0xc0000000; | |
124 } | 127 } |
125 else version( solaris ) | 128 else version( solaris ) |
126 { | 129 { |
127 version(X86_64) { | 130 version(X86_64) { |
128 return _userlimit; | 131 return _userlimit; |
527 int cpusubtype; | 530 int cpusubtype; |
528 uint filetype; | 531 uint filetype; |
529 uint ncmds; | 532 uint ncmds; |
530 uint sizeofcmds; | 533 uint sizeofcmds; |
531 uint flags; | 534 uint flags; |
535 version(X86_64) | |
536 uint reserved; | |
532 } | 537 } |
533 | 538 |
534 struct section | 539 struct section |
535 { | 540 { |
536 char[16] sectname; | 541 char[16] sectname; |
537 char[16] segname; | 542 char[16] segname; |
538 uint addr; | 543 version(X86_64) |
539 uint size; | 544 { |
545 ulong addr; | |
546 ulong size; | |
547 } | |
548 else | |
549 { | |
550 uint addr; | |
551 uint size; | |
552 } | |
540 uint offset; | 553 uint offset; |
541 uint align_; | 554 uint align_; |
542 uint reloff; | 555 uint reloff; |
543 uint nreloc; | 556 uint nreloc; |
544 uint flags; | 557 uint flags; |
545 uint reserved1; | 558 uint reserved1; |
546 uint reserved2; | 559 uint reserved2; |
560 version(X86_64) | |
561 uint reserved3; | |
547 } | 562 } |
548 | 563 |
549 alias extern (C) void function (mach_header* mh, ptrdiff_t vmaddr_slide) DyldFuncPointer; | 564 alias extern (C) void function (mach_header* mh, ptrdiff_t vmaddr_slide) DyldFuncPointer; |
550 | 565 |
551 extern (C) /*const*/ section* getsectbynamefromheader(/*const*/ mach_header* mhp, /*const*/ char* segname, /*const*/ char* sectname); | 566 version(X86_64) |
567 extern (C) /*const*/ section* getsectbynamefromheader_64(/*const*/ mach_header* mhp, /*const*/ char* segname, /*const*/ char* sectname); | |
568 else | |
569 extern (C) /*const*/ section* getsectbynamefromheader(/*const*/ mach_header* mhp, /*const*/ char* segname, /*const*/ char* sectname); | |
552 extern (C) void _dyld_register_func_for_add_image(DyldFuncPointer func); | 570 extern (C) void _dyld_register_func_for_add_image(DyldFuncPointer func); |
553 extern (C) void _dyld_register_func_for_remove_image(DyldFuncPointer func); | 571 extern (C) void _dyld_register_func_for_remove_image(DyldFuncPointer func); |
554 | 572 |
555 const SegmentSection[3] GC_dyld_sections = [SegmentSection(SEG_DATA, SECT_DATA), SegmentSection(SEG_DATA, SECT_BSS), SegmentSection(SEG_DATA, SECT_COMMON)]; | 573 const SegmentSection[3] GC_dyld_sections = [SegmentSection(SEG_DATA, SECT_DATA), SegmentSection(SEG_DATA, SECT_BSS), SegmentSection(SEG_DATA, SECT_COMMON)]; |
556 | 574 |
560 void* end; | 578 void* end; |
561 /*const*/ section* sec; | 579 /*const*/ section* sec; |
562 | 580 |
563 foreach (s ; GC_dyld_sections) | 581 foreach (s ; GC_dyld_sections) |
564 { | 582 { |
565 sec = getsectbynamefromheader(hdr, s.segment, s.section); | 583 version(X86_64) |
584 sec = getsectbynamefromheader_64(hdr, s.segment, s.section); | |
585 else | |
586 sec = getsectbynamefromheader(hdr, s.segment, s.section); | |
566 | 587 |
567 if (sec == null || sec.size == 0) | 588 if (sec == null || sec.size == 0) |
568 continue; | 589 continue; |
569 | 590 |
570 start = cast(void*) (sec.addr + slide); | 591 start = cast(void*) (sec.addr + slide); |
580 void* end; | 601 void* end; |
581 /*const*/ section* sec; | 602 /*const*/ section* sec; |
582 | 603 |
583 foreach (s ; GC_dyld_sections) | 604 foreach (s ; GC_dyld_sections) |
584 { | 605 { |
585 sec = getsectbynamefromheader(hdr, s.segment, s.section); | 606 version(X86_64) |
607 sec = getsectbynamefromheader_64(hdr, s.segment, s.section); | |
608 else | |
609 sec = getsectbynamefromheader(hdr, s.segment, s.section); | |
586 | 610 |
587 if (sec == null || sec.size == 0) | 611 if (sec == null || sec.size == 0) |
588 continue; | 612 continue; |
589 | 613 |
590 start = cast(void*) (sec.addr + slide); | 614 start = cast(void*) (sec.addr + slide); |