X-Git-Url: http://git.megacz.com/?p=org.ibex.core.git;a=blobdiff_plain;f=upstream%2Fdarwin-linker%2Fpatches%2Fcctools.patch;h=0ce718bae7de4a5f2c0e5c9f2c5532838b651229;hp=7c5e114295f405bfa43170eacd0281e93fc1c689;hb=f3963fe569c7563fad38667e40a3884165e67021;hpb=3b3a1b49edb899d7d5397c557765b314b663d2f4 diff --git a/upstream/darwin-linker/patches/cctools.patch b/upstream/darwin-linker/patches/cctools.patch index 7c5e114..0ce718b 100644 --- a/upstream/darwin-linker/patches/cctools.patch +++ b/upstream/darwin-linker/patches/cctools.patch @@ -937,176 +937,698 @@ diff -rub ./misc/Makefile ./misc/Makefile shlib_clean: -rm -f \ ---- ld/fake-mach.c Sat Sep 6 21:32:56 2003 -+++ ld/fake-mach.c Tue Aug 26 11:40:24 2003 -@@ -0,0 +1,160 @@ -+/** fake-mach.c - A half baked implementation of mach kernel functions using the POSIX UNIX API. -+* -+* This was used to port Apple's Darwin linker (ld) to Linux. This allows Mac OS X applications to -+* be cross complied on Linux. */ +--- ld/makeUser.c Sat Sep 6 21:52:24 2003 ++++ ld/makeUser.c Mon Aug 25 22:54:46 2003 +@@ -0,0 +1,305 @@ ++/* ++ * IDENTIFICATION: ++ * stub generated Mon Aug 25 15:06:30 2003 ++ * with a MiG generated Tue Nov 5 01:17:50 PST 2002 by root@brixen ++ * OPTIONS: ++ */ ++#include "make.h" + -+#include -+#include -+#include -+#include -+#include + -+#include ++#ifndef mig_internal ++#define mig_internal static ++#endif /* mig_internal */ + -+#include ++#ifndef mig_external ++#define mig_external ++#endif /* mig_external */ + -+// Mach include files for typedefs, return values, etc -+//~ #include -+#include -+#include -+#include -+#include -+#include ++#ifndef TypeCheck ++#define TypeCheck 0 ++#endif /* TypeCheck */ + -+/** The port for the current task. Ignored in this implementation. */ -+mach_port_t mach_task_self_ = 0; ++#ifndef LimitCheck ++#define LimitCheck 0 ++#endif /* LimitCheck */ + -+/** The bootstrap port. Ignored in this implementation. */ -+mach_port_t bootstrap_port = 0; ++#ifndef min ++#define min(a,b) ( ((a) < (b))? (a): (b) ) ++#endif /* min */ + -+#include ++#ifndef UseStaticTemplates ++#define UseStaticTemplates 0 ++#endif /* UseStaticTemplates */ + -+/** Maps the file descriptor into memory. Free the memory using vm_deallocate. Ignores findspace and offset. */ -+kern_return_t map_fd( int fd, vm_offset_t offset, vm_offset_t *va, boolean_t findspace, vm_size_t size) -+{ -+ void* space = NULL; ++#define _WALIGN_(x) (((x) + 3) & ~3) ++#define _WALIGNSZ_(x) _WALIGN_(sizeof(x)) ++#ifndef __MachMsgErrorWithTimeout ++#define __MachMsgErrorWithTimeout(_R_) { \ ++ switch (_R_) { \ ++ case MACH_SEND_INVALID_REPLY: \ ++ case MACH_RCV_INVALID_NAME: \ ++ case MACH_RCV_PORT_DIED: \ ++ case MACH_RCV_PORT_CHANGED: \ ++ case MACH_RCV_TIMED_OUT: \ ++ mig_dealloc_reply_port(InP->Head.msgh_reply_port); \ ++ break; \ ++ default: \ ++ mig_put_reply_port(InP->Head.msgh_reply_port); \ ++ } \ ++} ++#endif /* __MachMsgErrorWithTimeout */ + -+ assert( fd > 0 ); -+ assert( offset == 0 ); -+ //~ assert( *va == 0 ); -+ assert( findspace == TRUE ); -+ -+ //~ // Allocate memory -+ //~ space = malloc( size ); -+ //~ assert( space != NULL ); -+ -+ //~ // Read file into space -+ //~ bytes = read( fd, space, size ); -+ //~ assert( bytes == size ); -+ -+ space = mmap( (void*) offset, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0 ); -+ // No permission: try to make it read only -+ if ( space == (void*) -1 && errno == EACCES ) -+ { -+ space = mmap( (void*) offset, size, PROT_READ, MAP_SHARED, fd, 0 ); -+ } -+ assert( space != NULL && space != (void*) -1 ); -+ -+ // Copy back the pointer -+ *va = (vm_offset_t) space; -+ -+ // Return success -+ return KERN_SUCCESS; ++#ifndef __MachMsgErrorWithoutTimeout ++#define __MachMsgErrorWithoutTimeout(_R_) { \ ++ switch (_R_) { \ ++ case MACH_SEND_INVALID_REPLY: \ ++ case MACH_RCV_INVALID_NAME: \ ++ case MACH_RCV_PORT_DIED: \ ++ case MACH_RCV_PORT_CHANGED: \ ++ mig_dealloc_reply_port(InP->Head.msgh_reply_port); \ ++ break; \ ++ default: \ ++ mig_put_reply_port(InP->Head.msgh_reply_port); \ ++ } \ +} ++#endif /* __MachMsgErrorWithoutTimeout */ + -+/** Returns a string appropriate to the error argument given. */ -+char* mach_error_string( int error_value ) ++#ifndef __DeclareSendRpc ++#define __DeclareSendRpc(_NUM_, _NAME_) ++#endif /* __DeclareSendRpc */ ++ ++#ifndef __BeforeSendRpc ++#define __BeforeSendRpc(_NUM_, _NAME_) ++#endif /* __BeforeSendRpc */ ++ ++#ifndef __AfterSendRpc ++#define __AfterSendRpc(_NUM_, _NAME_) ++#endif /* __AfterSendRpc */ ++ ++#ifndef __DeclareSendSimple ++#define __DeclareSendSimple(_NUM_, _NAME_) ++#endif /* __DeclareSendSimple */ ++ ++#ifndef __BeforeSendSimple ++#define __BeforeSendSimple(_NUM_, _NAME_) ++#endif /* __BeforeSendSimple */ ++ ++#ifndef __AfterSendSimple ++#define __AfterSendSimple(_NUM_, _NAME_) ++#endif /* __AfterSendSimple */ ++ ++#define msgh_request_port msgh_remote_port ++#define msgh_reply_port msgh_local_port ++ ++ ++ ++/* SimpleRoutine alert_old */ ++mig_external kern_return_t make_alert_old ++( ++ mach_port_t makePort, ++ int eventType, ++ make_string_t functionName, ++ mach_msg_type_number_t functionNameCnt, ++ make_string_t fileName, ++ mach_msg_type_number_t fileNameCnt, ++ int line, ++ make_string_t message, ++ mach_msg_type_number_t messageCnt ++) +{ -+ char errorString[] = "Some fake mach error string."; -+ -+ return errorString; ++ { ++ typedef struct { ++ mach_msg_header_t Head; ++ NDR_record_t NDR; ++ int eventType; ++ mach_msg_type_number_t functionNameCnt; ++ char functionName[1024]; ++ mach_msg_type_number_t fileNameCnt; ++ char fileName[1024]; ++ int line; ++ mach_msg_type_number_t messageCnt; ++ char message[1024]; ++ } Request; ++ ++ /* ++ * typedef struct { ++ * mach_msg_header_t Head; ++ * NDR_record_t NDR; ++ * kern_return_t RetCode; ++ * } mig_reply_error_t; ++ */ ++ ++ union { ++ Request In; ++ } Mess; ++ ++ register Request *InP = &Mess.In; ++ ++ mach_msg_return_t msg_result; ++ unsigned int msgh_size; ++ unsigned int msgh_size_delta; ++ __DeclareSendSimple(100, "alert_old") ++ ++ InP->NDR = NDR_record; ++ ++ InP->eventType = eventType; ++ ++ if (functionNameCnt > 1024) { ++ { return MIG_ARRAY_TOO_LARGE; } ++ } ++ (void)memcpy((char *) InP->functionName, (const char *) functionName, functionNameCnt); ++ ++ InP->functionNameCnt = functionNameCnt; ++ ++ msgh_size_delta = _WALIGN_(functionNameCnt); ++ msgh_size = (sizeof(Request) - 3072) + msgh_size_delta; ++ InP = (Request *) ((pointer_t) InP + msgh_size_delta - 1024); ++ ++ if (fileNameCnt > 1024) { ++ { return MIG_ARRAY_TOO_LARGE; } ++ } ++ (void)memcpy((char *) InP->fileName, (const char *) fileName, fileNameCnt); ++ ++ InP->fileNameCnt = fileNameCnt; ++ ++ msgh_size_delta = _WALIGN_(fileNameCnt); ++ msgh_size += msgh_size_delta; ++ InP = (Request *) ((pointer_t) InP + msgh_size_delta - 1024); ++ ++ InP->line = line; ++ ++ if (messageCnt > 1024) { ++ { return MIG_ARRAY_TOO_LARGE; } ++ } ++ (void)memcpy((char *) InP->message, (const char *) message, messageCnt); ++ ++ InP->messageCnt = messageCnt; ++ ++ msgh_size += _WALIGN_(messageCnt); ++ InP = &Mess.In; ++ InP->Head.msgh_bits = ++ MACH_MSGH_BITS(19, 0); ++ /* msgh_size passed as argument */ ++ InP->Head.msgh_request_port = makePort; ++ InP->Head.msgh_reply_port = MACH_PORT_NULL; ++ InP->Head.msgh_id = 100; ++ ++ __BeforeSendSimple(100, "alert_old") ++ msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, msgh_size, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); ++ __AfterSendSimple(100, "alert_old") ++ return msg_result; ++ } +} + -+/** Returns the mach port for the current host. We fake it by returning zero. */ -+mach_port_t mach_host_self( void ) ++/* SimpleRoutine alert */ ++mig_external kern_return_t make_alert ++( ++ mach_port_t makePort, ++ int eventType, ++ make_string_t functionName, ++ mach_msg_type_number_t functionNameCnt, ++ make_string_t fileName, ++ mach_msg_type_number_t fileNameCnt, ++ make_string_t directory, ++ mach_msg_type_number_t directoryCnt, ++ int line, ++ make_string_t message, ++ mach_msg_type_number_t messageCnt ++) +{ -+ return 0; -+} ++ { ++ typedef struct { ++ mach_msg_header_t Head; ++ NDR_record_t NDR; ++ int eventType; ++ mach_msg_type_number_t functionNameCnt; ++ char functionName[1024]; ++ mach_msg_type_number_t fileNameCnt; ++ char fileName[1024]; ++ mach_msg_type_number_t directoryCnt; ++ char directory[1024]; ++ int line; ++ mach_msg_type_number_t messageCnt; ++ char message[1024]; ++ } Request; + -+/** Returns the mach port for the current task. We fake it by returning zero. */ -+//~ mach_port_t mach_task_self( void ) -+//~ { -+ //~ return 0; -+//~ } ++ /* ++ * typedef struct { ++ * mach_msg_header_t Head; ++ * NDR_record_t NDR; ++ * kern_return_t RetCode; ++ * } mig_reply_error_t; ++ */ + -+/**The function vm_allocate allocates a region of virtual memory, placing it in the specified task's address space. Anywhere must be true, as the memory will be allocated anywhere. */ -+extern kern_return_t vm_allocate( mach_port_t target_task, vm_address_t *address, vm_size_t size, boolean_t anywhere ) -+{ -+ assert( anywhere == TRUE ); -+ -+ // Anonymous memory map -+ *address = (vm_address_t) mmap( NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE|MAP_ANON, 0, 0 ); -+ //~ *address = (vm_address_t) malloc( size ); -+ assert( address != (vm_address_t) NULL ); -+ -+ return KERN_SUCCESS; ++ union { ++ Request In; ++ } Mess; ++ ++ register Request *InP = &Mess.In; ++ ++ mach_msg_return_t msg_result; ++ unsigned int msgh_size; ++ unsigned int msgh_size_delta; ++ __DeclareSendSimple(101, "alert") ++ ++ InP->NDR = NDR_record; ++ ++ InP->eventType = eventType; ++ ++ if (functionNameCnt > 1024) { ++ { return MIG_ARRAY_TOO_LARGE; } ++ } ++ (void)memcpy((char *) InP->functionName, (const char *) functionName, functionNameCnt); ++ ++ InP->functionNameCnt = functionNameCnt; ++ ++ msgh_size_delta = _WALIGN_(functionNameCnt); ++ msgh_size = (sizeof(Request) - 4096) + msgh_size_delta; ++ InP = (Request *) ((pointer_t) InP + msgh_size_delta - 1024); ++ ++ if (fileNameCnt > 1024) { ++ { return MIG_ARRAY_TOO_LARGE; } ++ } ++ (void)memcpy((char *) InP->fileName, (const char *) fileName, fileNameCnt); ++ ++ InP->fileNameCnt = fileNameCnt; ++ ++ msgh_size_delta = _WALIGN_(fileNameCnt); ++ msgh_size += msgh_size_delta; ++ InP = (Request *) ((pointer_t) InP + msgh_size_delta - 1024); ++ ++ if (directoryCnt > 1024) { ++ { return MIG_ARRAY_TOO_LARGE; } ++ } ++ (void)memcpy((char *) InP->directory, (const char *) directory, directoryCnt); ++ ++ InP->directoryCnt = directoryCnt; ++ ++ msgh_size_delta = _WALIGN_(directoryCnt); ++ msgh_size += msgh_size_delta; ++ InP = (Request *) ((pointer_t) InP + msgh_size_delta - 1024); ++ ++ InP->line = line; ++ ++ if (messageCnt > 1024) { ++ { return MIG_ARRAY_TOO_LARGE; } ++ } ++ (void)memcpy((char *) InP->message, (const char *) message, messageCnt); ++ ++ InP->messageCnt = messageCnt; ++ ++ msgh_size += _WALIGN_(messageCnt); ++ InP = &Mess.In; ++ InP->Head.msgh_bits = ++ MACH_MSGH_BITS(19, 0); ++ /* msgh_size passed as argument */ ++ InP->Head.msgh_request_port = makePort; ++ InP->Head.msgh_reply_port = MACH_PORT_NULL; ++ InP->Head.msgh_id = 101; ++ ++ __BeforeSendSimple(101, "alert") ++ msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_MSG_OPTION_NONE, msgh_size, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); ++ __AfterSendSimple(101, "alert") ++ return msg_result; ++ } +} +diff -bur ./Makefile /home/megacz/xwt/upstream/darwin-linker/src/cctools/as/Makefile +--- as/Makefile Fri Sep 6 18:27:10 2002 ++++ as/Makefile Sat Sep 6 23:52:22 2003 +@@ -2,7 +2,7 @@ + export USE_APPLE_PB_SUPPORT = all + OFLAG = -O + ifeq "macos" "$(RC_OS)" +- X_CFLAGS := $(shell if [ "$(RC_RELEASE)" != "Beaker" ] && \ ++ X_CFLAGS := $(shell if [ `uname` != "Linux" ] && [ "$(RC_RELEASE)" != "Beaker" ] && \ + [ "$(RC_RELEASE)" != "Bunsen" ] && \ + [ "$(RC_RELEASE)" != "Gonzo" ] && \ + [ "$(RC_RELEASE)" != "Kodiak" ]; then \ +@@ -11,10 +11,14 @@ + endif + + ifneq "mwccppc" "$(notdir $(CC))" ++ ifeq "Linux" "$(shell uname)" ++ GCC_FLAGS = -Wall $(X_CFLAGS) -D__LITTLE_ENDIAN__ -U__BIG_ENDIAN__ -D__ppc__ -I/usr/include -I../../../macosx-include ++ else + GCC_FLAGS = -Wall -Wno-precomp $(X_CFLAGS) ++ endif + endif + +-USE_DEPENDENCY_FILE := $(shell if [ "$(notdir $(CC))" != "mwccppc" ]; then \ ++USE_DEPENDENCY_FILE := $(shell if [ `uname` != "Linux" ] && [ "$(notdir $(CC))" != "mwccppc" ]; then \ + echo YES ; else echo NO ; \ + fi; ) + +diff -bur ./app.h /home/megacz/xwt/upstream/darwin-linker/src/cctools/as/app.h +--- as/app.h Tue Apr 30 00:37:17 2002 ++++ as/app.h Sat Sep 6 23:49:28 2003 +@@ -1,4 +1,4 @@ +-#import ++#include + + extern FILE *scrub_file; + extern char *scrub_string; +diff -bur ./as.h /home/megacz/xwt/upstream/darwin-linker/src/cctools/as/as.h +--- as/as.h Tue Apr 30 00:37:17 2002 ++++ as/as.h Sat Sep 6 23:49:28 2003 +@@ -43,10 +43,10 @@ + */ + #undef SUSPECT + +-/* These #imports are for type definitions etc. */ +-#import +-#import +-#import ++/* These #includes are for type definitions etc. */ ++#include ++#include ++#include + + /* These defines are potentially useful */ + #undef FALSE +Only in /home/megacz/xwt/upstream/darwin-linker/src/cctools/as: asparc_dir +diff -bur ./atof-ieee.h /home/megacz/xwt/upstream/darwin-linker/src/cctools/as/atof-ieee.h +--- as/atof-ieee.h Tue Apr 30 00:37:17 2002 ++++ as/atof-ieee.h Sat Sep 6 23:49:28 2003 +@@ -1,4 +1,4 @@ +-#import "flonum.h" ++#include "flonum.h" + + extern char *atof_ieee( + char *str, +diff -bur ./bignum.h /home/megacz/xwt/upstream/darwin-linker/src/cctools/as/bignum.h +--- as/bignum.h Tue Apr 30 00:37:17 2002 ++++ as/bignum.h Sat Sep 6 23:53:27 2003 +@@ -28,6 +28,8 @@ + * Bignums are >= 0. * + * * + \***********************************************************************/ ++#ifndef __BIGNUM_H__ ++#define __BIGNUM_H__ + + #define LITTLENUM_NUMBER_OF_BITS (16) + #define LITTLENUM_RADIX (1 << LITTLENUM_NUMBER_OF_BITS) +@@ -44,3 +46,4 @@ + /* JF truncated this to get around a problem with GCC */ + #define LOG_TO_BASE_2_OF_10 (3.3219280948873623478703194294893901758651) + /* WARNING: I haven't checked that the trailing digits are correct! */ ++#endif +diff -bur ./expr.h /home/megacz/xwt/upstream/darwin-linker/src/cctools/as/expr.h +--- as/expr.h Fri Sep 6 18:27:10 2002 ++++ as/expr.h Sat Sep 6 23:49:28 2003 +@@ -19,9 +19,9 @@ + along with GAS; see the file COPYING. If not, write to + the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +-#import "struc-symbol.h" +-#import "bignum.h" +-#import "flonum.h" ++#include "struc-symbol.h" ++#include "bignum.h" ++#include "flonum.h" + + /* + * This table describes the use of segments as EXPRESSION types. +diff -bur ./flonum.h /home/megacz/xwt/upstream/darwin-linker/src/cctools/as/flonum.h +--- as/flonum.h Fri Sep 6 18:27:10 2002 ++++ as/flonum.h Sat Sep 6 23:49:28 2003 +@@ -32,7 +32,7 @@ + * * + \***********************************************************************/ + +-#import "bignum.h" ++#include "bignum.h" + + /***********************************************************************\ + * * +diff -bur ./frags.h /home/megacz/xwt/upstream/darwin-linker/src/cctools/as/frags.h +--- as/frags.h Tue Jan 14 23:35:18 2003 ++++ as/frags.h Sat Sep 6 23:49:28 2003 +@@ -19,8 +19,8 @@ + along with GAS; see the file COPYING. If not, write to + the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +-#import "relax.h" +-#import "struc-symbol.h" ++#include "relax.h" ++#include "struc-symbol.h" + + /* + * A code fragment (frag) is some known number of chars, followed by some +diff -bur ./md.h /home/megacz/xwt/upstream/darwin-linker/src/cctools/as/md.h +--- as/md.h Tue Apr 30 00:37:17 2002 ++++ as/md.h Sat Sep 6 23:49:29 2003 +@@ -19,13 +19,13 @@ + in a file named COPYING. Among other things, the copyright + notice and this notice must be preserved on all copies. */ + +-#import +-#import "stuff/bytesex.h" +-#import "frags.h" +-#import "relax.h" +-#import "struc-symbol.h" +-#import "fixes.h" +-#import "read.h" ++#include ++#include "stuff/bytesex.h" ++#include "frags.h" ++#include "relax.h" ++#include "struc-symbol.h" ++#include "fixes.h" ++#include "read.h" + + /* These are the default cputype and cpusubtype for this target MACHINE */ + extern const cpu_type_t md_cputype; +diff -bur ./read.h /home/megacz/xwt/upstream/darwin-linker/src/cctools/as/read.h +--- as/read.h Fri Sep 6 18:27:13 2002 ++++ as/read.h Sat Sep 6 23:49:29 2003 +@@ -19,7 +19,7 @@ + along with GAS; see the file COPYING. If not, write to + the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +-#import "expr.h" ++#include "expr.h" + + #define PERMIT_WHITESPACE /* Define to make whitespace be allowed in */ + /* many syntactically unnecessary places. */ +diff -bur ./relax.h /home/megacz/xwt/upstream/darwin-linker/src/cctools/as/relax.h +--- as/relax.h Tue Apr 30 00:37:17 2002 ++++ as/relax.h Sat Sep 6 23:53:35 2003 +@@ -1,3 +1,5 @@ ++#ifndef __RELAX_H__ ++#define __RELAX_H__ + /* The type used for a target address */ + typedef unsigned long relax_addressT; + +@@ -42,3 +44,4 @@ + relax_substateT rlx_more; /* Next longer relax-state. */ + /* 0 means there is no 'next' relax-state. */ + } relax_typeS; ++#endif +diff -bur ./sections.h /home/megacz/xwt/upstream/darwin-linker/src/cctools/as/sections.h +--- as/sections.h Tue Apr 30 00:37:17 2002 ++++ as/sections.h Sat Sep 6 23:49:29 2003 +@@ -17,8 +17,8 @@ + along with GAS; see the file COPYING. If not, write to + the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +-#import +-#import "struc-symbol.h" ++#include ++#include "struc-symbol.h" + + /* + * For every section the user mentions in the assembley program, we make one +diff -bur ./struc-symbol.h /home/megacz/xwt/upstream/darwin-linker/src/cctools/as/struc-symbol.h +--- as/struc-symbol.h Fri Sep 6 18:27:14 2002 ++++ as/struc-symbol.h Sat Sep 6 23:49:29 2003 +@@ -20,7 +20,7 @@ + the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + + #ifdef NeXT_MOD +-#import ++#include + #else /* !defined(NeXT_MOD) */ + #ifndef VMS + #include "a.out.h" /* Needed to define struct nlist. Sigh. */ +diff -bur ./symbols.h /home/megacz/xwt/upstream/darwin-linker/src/cctools/as/symbols.h +--- as/symbols.h Tue Apr 30 00:37:17 2002 ++++ as/symbols.h Sat Sep 6 23:49:29 2003 +@@ -17,8 +17,8 @@ + along with GAS; see the file COPYING. If not, write to + the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +-#import "struc-symbol.h" +-#import "hash.h" ++#include "struc-symbol.h" ++#include "hash.h" + + extern struct hash_control *sy_hash; + extern struct obstack notes; +--- as/make.h Sun Sep 7 00:01:26 2003 ++++ as/make.h Sat Sep 6 23:55:11 2003 +@@ -0,0 +1,161 @@ ++#ifndef _make_user_ ++#define _make_user_ ++ ++/* Module make */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#ifdef AUTOTEST ++#ifndef FUNCTION_PTR_T ++#define FUNCTION_PTR_T ++typedef void (*function_ptr_t)(mach_port_t, char *, mach_msg_type_number_t); ++typedef struct { ++ char *name; ++ function_ptr_t function; ++} function_table_entry; ++typedef function_table_entry *function_table_t; ++#endif /* FUNCTION_PTR_T */ ++#endif /* AUTOTEST */ ++ ++#ifndef make_MSG_COUNT ++#define make_MSG_COUNT 2 ++#endif /* make_MSG_COUNT */ ++ ++#include ++#include ++#include "make_defs.h" ++ ++#ifdef __BeforeMigUserHeader ++__BeforeMigUserHeader ++#endif /* __BeforeMigUserHeader */ ++ ++ ++/* SimpleRoutine alert_old */ ++#ifdef mig_external ++mig_external ++#else ++extern ++#endif /* mig_external */ ++kern_return_t make_alert_old ++( ++ mach_port_t makePort, ++ int eventType, ++ make_string_t functionName, ++ mach_msg_type_number_t functionNameCnt, ++ make_string_t fileName, ++ mach_msg_type_number_t fileNameCnt, ++ int line, ++ make_string_t message, ++ mach_msg_type_number_t messageCnt ++); ++ ++/* SimpleRoutine alert */ ++#ifdef mig_external ++mig_external ++#else ++extern ++#endif /* mig_external */ ++kern_return_t make_alert ++( ++ mach_port_t makePort, ++ int eventType, ++ make_string_t functionName, ++ mach_msg_type_number_t functionNameCnt, ++ make_string_t fileName, ++ mach_msg_type_number_t fileNameCnt, ++ make_string_t directory, ++ mach_msg_type_number_t directoryCnt, ++ int line, ++ make_string_t message, ++ mach_msg_type_number_t messageCnt ++); ++/* typedefs for all requests */ ++ ++#ifndef __Request__make_subsystem__defined ++#define __Request__make_subsystem__defined ++ typedef struct { ++ mach_msg_header_t Head; ++ NDR_record_t NDR; ++ int eventType; ++ mach_msg_type_number_t functionNameCnt; ++ char functionName[1024]; ++ mach_msg_type_number_t fileNameCnt; ++ char fileName[1024]; ++ int line; ++ mach_msg_type_number_t messageCnt; ++ char message[1024]; ++ } __Request__alert_old_t; ++ ++ typedef struct { ++ mach_msg_header_t Head; ++ NDR_record_t NDR; ++ int eventType; ++ mach_msg_type_number_t functionNameCnt; ++ char functionName[1024]; ++ mach_msg_type_number_t fileNameCnt; ++ char fileName[1024]; ++ mach_msg_type_number_t directoryCnt; ++ char directory[1024]; ++ int line; ++ mach_msg_type_number_t messageCnt; ++ char message[1024]; ++ } __Request__alert_t; + -+/**vm_deallocate relinquishes access to a region of a task's address space, causing further access to that memory to fail. This memory must have been allocated with vm_allocate. size is ignored. */ -+kern_return_t vm_deallocate( mach_port_t target_task, vm_address_t address, vm_size_t size ) -+{ -+ int ret = 0; -+ -+ assert( address != (vm_address_t) NULL ); -+ -+ // Free the memory -+ ret = munmap( (void*) address, size ); -+ assert( ret == 0 ); -+ -+ //~ free( (void*) address ); -+ -+ return KERN_SUCCESS; -+} ++#endif /* !__Request__make_subsystem__defined */ + -+/** The function mach_port_allocate_name creates a new right in the specified task, with a specified name for the new right. In this implementation it does nothing. */ -+kern_return_t mach_port_allocate_name (mach_port_t task, mach_port_right_t right, mach_port_t name) -+{ -+ return KERN_SUCCESS; -+} ++/* union of all requests */ + -+/** The function mach_port_deallocate releases a user reference for a right in task's IPC name space. In this implementation it does nothing. */ -+kern_return_t mach_port_deallocate (mach_port_t task, mach_port_t name) -+{ -+ return KERN_SUCCESS; -+} ++#ifndef __RequestUnion__make_make_subsystem__defined ++#define __RequestUnion__make_make_subsystem__defined ++union __RequestUnion__make_make_subsystem { ++ __Request__alert_old_t Request_make_alert_old; ++ __Request__alert_t Request_make_alert; ++}; ++#endif /* !__RequestUnion__make_make_subsystem__defined */ ++/* typedefs for all replies */ + -+/** host_info returns information about the host. It is not implemented in this implementation. */ -+kern_return_t host_info( host_t host, host_flavor_t flavor, host_info_t host_info_out, mach_msg_type_number_t *host_info_outCnt ) -+{ -+ assert( 0 ); -+ return KERN_FAILURE; -+} ++#ifndef __Reply__make_subsystem__defined ++#define __Reply__make_subsystem__defined ++ typedef struct { ++ mach_msg_header_t Head; ++ NDR_record_t NDR; ++ kern_return_t RetCode; ++ } __Reply__alert_old_t; + -+/** vm_msync unimplemented: It does nothing. */ -+kern_return_t vm_msync ( vm_map_t target_task, vm_address_t address, vm_size_t size, vm_sync_t sync_flags ) -+{ -+ //~ assert( address != (vm_address_t) NULL ); -+ //~ int ret = 0; -+ //~ ret = msync( (void*) address, size, int flags); -+ //~ assert( 0 ); -+ return KERN_SUCCESS; -+} ++ typedef struct { ++ mach_msg_header_t Head; ++ NDR_record_t NDR; ++ kern_return_t RetCode; ++ } __Reply__alert_t; + -+/** bootstrap_look_up unimplemented. */ -+kern_return_t bootstrap_look_up( mach_port_t bootstrap_port, name_t service_name, mach_port_t *service_port ) -+{ -+ assert( 0 ); -+ return KERN_FAILURE; -+} ++#endif /* !__Reply__make_subsystem__defined */ + -+/** mach_msg unimplemented. Send and/or receive a message. If the message operation -+ * is interrupted, and the user did not request an indication -+ * of that fact, then restart the appropriate parts of the -+ * operation silently (trap version does not restart). -+ */ -+mach_msg_return_t mach_msg( mach_msg_header_t *msg, mach_msg_option_t option, mach_msg_size_t send_size, -+ mach_msg_size_t rcv_size, mach_port_name_t rcv_name, mach_msg_timeout_t timeout, mach_port_name_t notify) -+{ -+ //~ assert( 0 ); -+ return KERN_SUCCESS; -+} -\ No newline at end of file ---- ld/makeUser.c Sat Sep 6 21:52:24 2003 -+++ ld/makeUser.c Mon Aug 25 22:54:46 2003 ++/* union of all replies */ ++ ++#ifndef __ReplyUnion__make_make_subsystem__defined ++#define __ReplyUnion__make_make_subsystem__defined ++union __ReplyUnion__make_make_subsystem { ++ __Reply__alert_old_t Reply_make_alert_old; ++ __Reply__alert_t Reply_make_alert; ++}; ++#endif /* !__RequestUnion__make_make_subsystem__defined */ ++ ++#ifndef subsystem_to_name_map_make ++#define subsystem_to_name_map_make \ ++ { "alert_old", 100 },\ ++ { "alert", 101 } ++#endif ++ ++#ifdef __AfterMigUserHeader ++__AfterMigUserHeader ++#endif /* __AfterMigUserHeader */ ++ ++#endif /* _make_user_ */ +--- as/makeUser.c Sun Sep 7 00:01:26 2003 ++++ as/makeUser.c Sat Sep 6 23:55:11 2003 @@ -0,0 +1,305 @@ +/* + * IDENTIFICATION: -+ * stub generated Mon Aug 25 15:06:30 2003 ++ * stub generated Sat Sep 6 23:50:34 2003 + * with a MiG generated Tue Nov 5 01:17:50 PST 2002 by root@brixen + * OPTIONS: + */ @@ -1409,3 +1931,414 @@ diff -rub ./misc/Makefile ./misc/Makefile + return msg_result; + } +} +--- ar/contents.c 30 Apr 2002 07:37:17 -0000 1.1.1.1 ++++ ar/contents.c 7 Sep 2003 08:55:11 -0000 +@@ -76,7 +76,6 @@ + #include + #include + #include +-#include + #include + + #include "archive.h" +@@ -103,12 +102,14 @@ + else if (!(file = files(argv))) + goto next; + if (options & AR_V) { ++/* + (void)strmode(chdr.mode, buf); + (void)printf("%s %6d/%-6d %8qd ", + buf + 1, chdr.uid, chdr.gid, chdr.size); + tp = localtime(&chdr.date); + (void)strftime(buf, sizeof(buf), "%b %e %H:%M %Y", tp); + (void)printf("%s %s\n", buf, file); ++*/ + } else + (void)printf("%s\n", file); + if (!all && !*argv) +--- ar/misc.c 30 Apr 2002 07:37:17 -0000 1.1.1.1 ++++ ar/misc.c 7 Sep 2003 08:55:11 -0000 +@@ -68,6 +68,7 @@ + #endif /* not lint */ + + #include ++#define EFTYPE 79 /* Inappropriate file type or format */ + + #include + #include +--- ar/vers_string Sun Sep 7 01:55:10 2003 ++++ ar/vers_string Sun Sep 7 01:53:23 2003 +@@ -0,0 +1,125 @@ ++#!/bin/sh ++## ++# Copyright (c) 1999 Apple Computer, Inc. All rights reserved. ++# ++# @APPLE_LICENSE_HEADER_START@ ++# ++# "Portions Copyright (c) 1999 Apple Computer, Inc. All Rights ++# Reserved. This file contains Original Code and/or Modifications of ++# Original Code as defined in and that are subject to the Apple Public ++# Source License Version 1.0 (the 'License'). You may not use this file ++# except in compliance with the License. Please obtain a copy of the ++# License at http://www.apple.com/publicsource and read it before using ++# this file. ++# ++# The Original Code and all software distributed under the License are ++# distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER ++# EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, ++# INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, ++# FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the ++# License for the specific language governing rights and limitations ++# under the License." ++# ++# @APPLE_LICENSE_HEADER_END@ ++## ++# ++# vers_string PROGRAM [STAMPED_NAME] ++# ++# Output a string suitable for use as a version identifier ++# ++ ++## ++# Usage ++## ++ ++program=$(basename $0); ++ ++usage () ++{ ++ echo "Usage: ${program} [] []"; ++ echo " : ???"; ++ echo " : ???"; ++ echo "Options: ???"; ++} ++ ++## ++# Handle command line ++## ++ ++ Date=$(date); ++Format=''\''PROGRAM:'\''"${Program}"'\'' PROJECT:'\''"${Version}"'\'' DEVELOPER:'\''"${USER}"'\'' BUILT:'\''"${Date}"'\'''\'''; ++ ++if ! args=$(getopt cflBn $*); then usage; fi; ++set -- ${args}; ++for option; do ++ case "${option}" in ++ -c) ++ Format=''\''#include ++#ifndef __IDSTRING ++#define __IDSTRING(name,string) \ ++ static const char name[] __attribute__((__unused__)) = string ++#endif ++__IDSTRING(SGS_VERS,"@(#)PROGRAM:'\''"${Program}"'\'' PROJECT:'\''"${Version}"'\'' DEVELOPER:'\''"${USER}"'\'' BUILT:'\''"${Date}"'\''\n"); ++__IDSTRING(VERS_NUM,"'\''${Revision}'\''");'\'''; ++ shift; ++ ;; ++ -f) ++ Format='"${Program}"'\''-'\''"${Revision}"'; ++ shift; ++ ;; ++ -l) ++ Format=''\''#include ++#ifndef __IDSTRING ++#define __IDSTRING(name,string) \ ++ const char name[] __attribute__((__unused__)) = string ++#endif ++__IDSTRING(SGS_VERS,"@(#)LIBRARY:'\''"${Program}"'\'' PROJECT:'\''"${Version}"'\'' DEVELOPER:'\''"${USER}"'\'' BUILT:'\''"${Date}"'\''\n");'\'''; ++ shift; ++ ;; ++ -B) ++ date="NO DATE SET (-B used)"; ++ shift; ++ ;; ++ -n) ++ Format='"${Revision}"'; ++ shift; ++ ;; ++ --) ++ shift; ++ break; ++ ;; ++ esac; ++done; ++ ++Program=$1; if [ $# != 0 ]; then shift; fi; ++Version=$1; if [ $# != 0 ]; then shift; fi; ++ ++if [ $# != 0 ]; then usage; fi; ++ ++if [ -z "${Program}" ]; then Program="Unknown"; fi; ++ ++if [ -n "${Version}" ]; then ++ if ! Revision=$(expr "${Version}" : '.*-\(.*\)'); then ++ echo "${program}: No hyphen in project root ${Version}" >&2 ++ exit 1; ++ fi; ++else ++ CurrentDir=$(/bin/pwd); ++ Version=$(basename "${CurrentDir}"); ++ while [ "${Version}" != "${CurrentDir}" ]; do ++ if Revision=$(expr "${Version}" : '.*-\(.*\)'); then break; fi; ++ CurrentDir=$(dirname "${CurrentDir}"); ++ Version=$(basename "${CurrentDir}"); ++ done; ++ if [ "${Version}" = "${CurrentDir}" ]; then ++ CurrentDir=$(/bin/pwd); ++ echo "${program}: No hyphen in project root ${CurrentDir}" >&2 ++ echo "${program}: Could not determine version" >&2 ++ Version="Unknown"; ++ Revision=""; ++ fi; ++fi; ++ ++if [ -z "${USER}" ]; then USER=$(whoami); fi; ++ ++echo "$(eval echo "${Format}")"; +--- ar/Makefile 7 Sep 2002 01:27:09 -0000 1.1.1.2 ++++ ar/Makefile 7 Sep 2003 09:03:52 -0000 +@@ -2,12 +2,16 @@ + ifeq "mwccppc" "$(notdir $(CC))" + CFLAGS = -g $(OFLAG) -I$(SRCROOT)/../include + else +- CFLAGS = -g $(OFLAG) -Wall -Wno-precomp -I$(SRCROOT)/../include ++ ifeq "Linux" "$(shell uname)" ++ CFLAGS = -Wall $(X_CFLAGS) -D__LITTLE_ENDIAN__ -U__BIG_ENDIAN__ -D__ppc__ -I/usr/include -I../../macosx-include -I../include ++ else ++ CFLAGS = -g $(OFLAG) -Wall -Wno-precomp -I$(SRCROOT)/../include ++ endif + endif + + LIBSTUFF = -L$(SYMROOT)/../libstuff -lstuff + +-USE_DEPENDENCY_FILE := $(shell if [ "$(notdir $(CC))" != "mwccppc" ]; then \ ++USE_DEPENDENCY_FILE := $(shell if [ `uname` != "Linux" ] && [ "$(notdir $(CC))" != "mwccppc" ]; then \ + echo YES ; else echo NO ; \ + fi; ) + +@@ -43,7 +47,8 @@ + $(CC) $(CFLAGS) $(RC_CFLAGS) -o $(SYMROOT)/$@ $(OBJS) $(LIBSTUFF) + + vers.c: +- vers_string -c $(VERS_STRING_FLAGS) $(PRODUCT) > $(OFILE_DIR)/$@ ++ chmod +x vers_string ++ ./vers_string -c $(VERS_STRING_FLAGS) $(PRODUCT) > $(OFILE_DIR)/$@ + + ifeq "NO" "$(USE_DEPENDENCY_FILE)" + .c.o: +--- ld/fake-mach.c Sun Sep 7 14:13:57 2003 ++++ ld/fake-mach.c Sun Sep 7 14:13:50 2003 +@@ -0,0 +1,163 @@ ++/** fake-mach.c - A half baked implementation of mach kernel functions using the POSIX UNIX API. ++* ++* This was used to port Apple's Darwin linker (ld) to Linux. This allows Mac OS X applications to ++* be cross complied on Linux. */ ++ ++#include ++#include ++#include ++#include ++#include ++ ++#include ++ ++#include ++ ++// Mach include files for typedefs, return values, etc ++//~ #include ++#include ++#include ++#include ++#include ++#include ++ ++/** The port for the current task. Ignored in this implementation. */ ++mach_port_t mach_task_self_ = 0; ++ ++/** The bootstrap port. Ignored in this implementation. */ ++mach_port_t bootstrap_port = 0; ++ ++#include ++ ++/** Maps the file descriptor into memory. Free the memory using vm_deallocate. Ignores findspace and offset. */ ++kern_return_t map_fd( int fd, vm_offset_t offset, vm_offset_t *va, boolean_t findspace, vm_size_t size) ++{ ++ void* space = NULL; ++ int bytes = 0; ++ ++ assert( fd > 0 ); ++ assert( offset == 0 ); ++ //~ assert( *va == 0 ); ++ assert( findspace == TRUE ); ++ ++ // Allocate memory ++ space = malloc( size ); ++ assert( space != NULL ); ++ ++ // Read file into space ++ while(bytes < size) bytes += read( fd, ((char*)space) + bytes, size - bytes); ++ assert( bytes == size ); ++ ++ /* ++ space = mmap( (void*) offset, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0 ); ++ // No permission: try to make it read only ++ if ( space == (void*) -1 && errno == EACCES ) ++ { ++ space = mmap( (void*) offset, size, PROT_READ, MAP_SHARED, fd, 0 ); ++ } ++ assert( space != NULL && space != (void*) -1 ); ++ */ ++ ++ // Copy back the pointer ++ *va = (vm_offset_t) space; ++ ++ // Return success ++ return KERN_SUCCESS; ++} ++ ++/** Returns a string appropriate to the error argument given. */ ++char* mach_error_string( int error_value ) ++{ ++ char errorString[] = "Some fake mach error string."; ++ ++ return errorString; ++} ++ ++/** Returns the mach port for the current host. We fake it by returning zero. */ ++mach_port_t mach_host_self( void ) ++{ ++ return 0; ++} ++ ++/** Returns the mach port for the current task. We fake it by returning zero. */ ++//~ mach_port_t mach_task_self( void ) ++//~ { ++ //~ return 0; ++//~ } ++ ++/**The function vm_allocate allocates a region of virtual memory, placing it in the specified task's address space. Anywhere must be true, as the memory will be allocated anywhere. */ ++extern kern_return_t vm_allocate( mach_port_t target_task, vm_address_t *address, vm_size_t size, boolean_t anywhere ) ++{ ++ assert( anywhere == TRUE ); ++ ++ // Anonymous memory map ++ *address = (vm_address_t) mmap( NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE|MAP_ANON, 0, 0 ); ++ //~ *address = (vm_address_t) malloc( size ); ++ assert( address != (vm_address_t) NULL ); ++ ++ return KERN_SUCCESS; ++} ++ ++/**vm_deallocate relinquishes access to a region of a task's address space, causing further access to that memory to fail. This memory must have been allocated with vm_allocate. size is ignored. */ ++kern_return_t vm_deallocate( mach_port_t target_task, vm_address_t address, vm_size_t size ) ++{ ++ int ret = 0; ++ ++ assert( address != (vm_address_t) NULL ); ++ ++ // Free the memory ++ ret = munmap( (void*) address, size ); ++ assert( ret == 0 ); ++ ++ //~ free( (void*) address ); ++ ++ return KERN_SUCCESS; ++} ++ ++/** The function mach_port_allocate_name creates a new right in the specified task, with a specified name for the new right. In this implementation it does nothing. */ ++kern_return_t mach_port_allocate_name (mach_port_t task, mach_port_right_t right, mach_port_t name) ++{ ++ return KERN_SUCCESS; ++} ++ ++/** The function mach_port_deallocate releases a user reference for a right in task's IPC name space. In this implementation it does nothing. */ ++kern_return_t mach_port_deallocate (mach_port_t task, mach_port_t name) ++{ ++ return KERN_SUCCESS; ++} ++ ++/** host_info returns information about the host. It is not implemented in this implementation. */ ++kern_return_t host_info( host_t host, host_flavor_t flavor, host_info_t host_info_out, mach_msg_type_number_t *host_info_outCnt ) ++{ ++ assert( 0 ); ++ return KERN_FAILURE; ++} ++ ++/** vm_msync unimplemented: It does nothing. */ ++kern_return_t vm_msync ( vm_map_t target_task, vm_address_t address, vm_size_t size, vm_sync_t sync_flags ) ++{ ++ //~ assert( address != (vm_address_t) NULL ); ++ //~ int ret = 0; ++ //~ ret = msync( (void*) address, size, int flags); ++ //~ assert( 0 ); ++ return KERN_SUCCESS; ++} ++ ++/** bootstrap_look_up unimplemented. */ ++kern_return_t bootstrap_look_up( mach_port_t bootstrap_port, name_t service_name, mach_port_t *service_port ) ++{ ++ assert( 0 ); ++ return KERN_FAILURE; ++} ++ ++/** mach_msg unimplemented. Send and/or receive a message. If the message operation ++ * is interrupted, and the user did not request an indication ++ * of that fact, then restart the appropriate parts of the ++ * operation silently (trap version does not restart). ++ */ ++mach_msg_return_t mach_msg( mach_msg_header_t *msg, mach_msg_option_t option, mach_msg_size_t send_size, ++ mach_msg_size_t rcv_size, mach_port_name_t rcv_name, mach_msg_timeout_t timeout, mach_port_name_t notify) ++{ ++ //~ assert( 0 ); ++ return KERN_SUCCESS; ++} +--- ar/archive.c 30 Apr 2002 07:37:17 -0000 1.1.1.1 ++++ ar/archive.c 8 Sep 2003 00:44:40 -0000 +@@ -69,6 +69,7 @@ + + #include + #include ++#include + + #include + #include +@@ -262,27 +263,37 @@ + */ + lname = strlen(name); + if (options & AR_TR) { ++ char buf[16]; ++ int i; ++ for(i=0; i<15; i++) buf[i] = ' '; ++ buf[15] = '\0'; + if (lname > OLDARMAXNAME) { + (void)fflush(stdout); + warnx("warning: %s truncated to %.*s", + name, OLDARMAXNAME, name); + (void)fflush(stderr); + } +- (void)sprintf(hb, HDR3, name, (long int)sb->st_mtimespec.tv_sec, ++ strncpy(buf, name, 15); ++ (void)sprintf(hb, HDR3, buf, (long int)sb->st_mtime, + (unsigned int)(u_short)sb->st_uid, + (unsigned int)(u_short)sb->st_gid, + sb->st_mode, sb->st_size, ARFMAG); + lname = 0; + } else if (lname > sizeof(hdr->ar_name) || strchr(name, ' ')) + (void)sprintf(hb, HDR1, AR_EFMT1, (lname + 3) & ~3, +- (long int)sb->st_mtimespec.tv_sec, ++ (long int)sb->st_mtime, + (unsigned int)(u_short)sb->st_uid, + (unsigned int)(u_short)sb->st_gid, + sb->st_mode, sb->st_size + ((lname + 3) & ~3), + ARFMAG); + else { ++ char buf[17]; ++ int i; ++ for(i=0; i<16; i++) buf[i] = ' '; ++ buf[16] = '\0'; ++ strncpy(buf, name, 16); + lname = 0; +- (void)sprintf(hb, HDR2, name, (long int)sb->st_mtimespec.tv_sec, ++ (void)sprintf(hb, HDR2, buf, (long int)sb->st_mtime, + (unsigned int)(u_short)sb->st_uid, + (unsigned int)(u_short)sb->st_gid, + sb->st_mode, sb->st_size, ARFMAG);