Date: Tue, 11 May 2004 08:49:48 -0700 (PDT) From: Andrew Reisse <areisse@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 52672 for review Message-ID: <200405111549.i4BFnm4O076474@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=52672 Change 52672 by areisse@areisse_ibook on 2004/05/11 08:49:22 Use a different allocator if the linker is called before tasks are initialized. Affected files ... .. //depot/projects/trustedbsd/sedarwin73/apsl/cctools/ld/ld.h#3 edit Differences ... ==== //depot/projects/trustedbsd/sedarwin73/apsl/cctools/ld/ld.h#3 (text+ko) ==== @@ -361,3 +361,47 @@ #ifdef DEBUG __private_extern__ unsigned long debug; /* link-editor debugging */ #endif /* DEBUG */ + +#if (defined (KLD) && defined (RLD) && defined (__STATIC__)) + +#include <mach/mach.h> +#include <mach/kern_return.h> +#include <mach/vm_map.h> + +extern int kth_started; + +static inline kern_return_t rkld_alloc (mach_port_t kport, size_t size, void **addr, int flags) +{ + if (kth_started) + return vm_allocate (kport, addr, size, flags); + else + { + *addr = kalloc (size); + return (*addr == 0); + } +} + +static inline kern_return_t rkld_free (mach_port_t kport, size_t size, void *addr) +{ + if (kth_started) + return vm_deallocate (kport, addr, size); + else + { + kfree (addr, size); + return 0; + } +} + +static inline kern_return_t rkld_protect (mach_port_t kport, void *addr, size_t size, int a, int b) +{ + if (kth_started) + return vm_protect (kport, addr, size, a, b); + else + return 0; +} + +#define vm_allocate(kport,addr,size,flags) rkld_alloc (kport, size, addr, flags) +#define vm_deallocate(kport,addr,size) rkld_free (kport, size, addr) +#define vm_protect(kport,addr,size,f1,f2) rkld_protect (kport, addr, size, f1, f2) + +#endif
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200405111549.i4BFnm4O076474>