Skip to content

Instantly share code, notes, and snippets.

@7shi
Created March 20, 2012 11:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 7shi/2134330 to your computer and use it in GitHub Desktop.
Save 7shi/2134330 to your computer and use it in GitHub Desktop.
NetBSDでodcctoolsをビルドするためのやっつけパッチ
diff -Nur odcctools.orig/as/struc-symbol.h odcctools/as/struc-symbol.h
--- odcctools.orig/as/struc-symbol.h 2012-06-07 21:55:07.000000000 +0900
+++ odcctools/as/struc-symbol.h 2012-06-13 00:13:40.000000000 +0900
@@ -33,7 +33,7 @@
struct symbol /* our version of an nlist node */
{
nlist_t sy_nlist; /* what we write in .o file (if permitted) */
-#ifdef ARCH64
+#if defined(ARCH64) || defined(__NetBSD__)
char *sy_name; /* symbol name */
#endif
long unsigned sy_name_offset; /* 1-origin position of sy_name in symbols */
@@ -52,7 +52,7 @@
typedef struct symbol symbolS;
-#ifndef ARCH64
+#if !defined(ARCH64) && !defined(__NetBSD__)
#define sy_name sy_nlist .n_un. n_name
/* Name field always points to a string. */
/* 0 means .stabd-like anonymous symbol. */
diff -Nur odcctools.orig/include/i386/_types.h odcctools/include/i386/_types.h
--- odcctools.orig/include/i386/_types.h 2012-06-07 21:54:50.000000000 +0900
+++ odcctools/include/i386/_types.h 2012-06-13 00:13:40.000000000 +0900
@@ -37,8 +37,10 @@
typedef unsigned short __uint16_t;
typedef int __int32_t;
typedef unsigned int __uint32_t;
+#ifndef __NetBSD__
typedef long long __int64_t;
typedef unsigned long long __uint64_t;
+#endif
typedef long __darwin_intptr_t;
typedef unsigned int __darwin_natural_t;
@@ -68,10 +70,14 @@
* stream conversions. The content must not be referenced by user programs.
*/
#ifndef _POSIX_C_SOURCE
+#ifdef __NetBSD__
+#include <machine/ansi.h>
+#else
typedef union {
char __mbstate8[128];
long long _mbstateL; /* for alignment */
} __mbstate_t;
+#endif
typedef __mbstate_t __darwin_mbstate_t; /* mbstate_t */
#else
typedef union {
diff -Nur odcctools.orig/include/i386/types.h odcctools/include/i386/types.h
--- odcctools.orig/include/i386/types.h 2012-06-07 21:54:50.000000000 +0900
+++ odcctools/include/i386/types.h 2012-06-13 00:13:40.000000000 +0900
@@ -84,9 +84,18 @@
typedef unsigned int u_int32_t;
#ifndef _INT64_T
#define _INT64_T
+#ifdef __NetBSD__
+typedef __int64_t int64_t;
+#else
typedef long long int64_t;
#endif
+#endif
+#ifdef __NetBSD__
+typedef __uint64_t u_int64_t;
+typedef volatile unsigned char __cpu_simple_lock_t;
+#else
typedef unsigned long long u_int64_t;
+#endif
#if __LP64__
typedef int64_t register_t;
diff -Nur odcctools.orig/include/mach-o/nlist.h odcctools/include/mach-o/nlist.h
--- odcctools.orig/include/mach-o/nlist.h 2012-06-07 21:54:53.000000000 +0900
+++ odcctools/include/mach-o/nlist.h 2012-06-13 00:13:40.000000000 +0900
@@ -75,7 +75,7 @@
*/
struct nlist {
union {
-#ifndef __LP64__
+#if !defined(__LP64__) || defined(__NetBSD__)
char *n_name; /* for use when in-core */
#endif
int32_t n_strx; /* index into the string table */
diff -Nur odcctools.orig/include/mach-o/ranlib.h odcctools/include/mach-o/ranlib.h
--- odcctools.orig/include/mach-o/ranlib.h 2012-06-07 21:54:54.000000000 +0900
+++ odcctools/include/mach-o/ranlib.h 2012-06-13 00:13:40.000000000 +0900
@@ -58,7 +58,7 @@
struct ranlib {
union {
uint32_t ran_strx; /* string table index of */
-#ifndef __LP64__
+#if !defined(__LP64__) || defined(__NetBSD__)
char *ran_name; /* symbol defined by */
#endif
} ran_un;
diff -Nur odcctools.orig/include/sys/appleapiopts.h odcctools/include/sys/appleapiopts.h
--- odcctools.orig/include/sys/appleapiopts.h 1970-01-01 09:00:00.000000000 +0900
+++ odcctools/include/sys/appleapiopts.h 2012-06-13 00:13:40.000000000 +0900
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
+ *
+ * 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 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. The rights granted to you under the License
+ * may not be used to create, or enable the creation or redistribution of,
+ * unlawful or unlicensed copies of an Apple operating system, or to
+ * circumvent, violate, or enable the circumvention or violation of, any
+ * terms of an Apple operating system software license agreement.
+ *
+ * Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ 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, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
+ */
+
+#ifndef __SYS_APPLEAPIOPTS_H__
+#define __SYS_APPLEAPIOPTS_H__
+
+
+#ifndef __APPLE_API_STANDARD
+#define __APPLE_API_STANDARD
+#endif /* __APPLE_API_STANDARD */
+
+#ifndef __APPLE_API_STABLE
+#define __APPLE_API_STABLE
+#endif /* __APPLE_API_STABLE */
+
+#ifndef __APPLE_API_STRICT_CONFORMANCE
+
+#ifndef __APPLE_API_EVOLVING
+#define __APPLE_API_EVOLVING
+#endif /* __APPLE_API_EVOLVING */
+
+#ifndef __APPLE_API_UNSTABLE
+#define __APPLE_API_UNSTABLE
+#endif /* __APPLE_API_UNSTABLE */
+
+#ifndef __APPLE_API_PRIVATE
+#define __APPLE_API_PRIVATE
+#endif /* __APPLE_API_PRIVATE */
+
+#ifndef __APPLE_API_OBSOLETE
+#define __APPLE_API_OBSOLETE
+#endif /* __APPLE_API_OBSOLETE */
+
+#endif /* __APPLE_API_STRICT_CONFORMANCE */
+
+#endif /* __SYS_APPLEAPIOPTS_H__ */
+
diff -Nur odcctools.orig/ld/pass1.c odcctools/ld/pass1.c
--- odcctools.orig/ld/pass1.c 2012-06-07 21:55:05.000000000 +0900
+++ odcctools/ld/pass1.c 2012-06-13 00:13:40.000000000 +0900
@@ -514,7 +514,7 @@
pass1_object(file_name, file_addr, file_size, base_name, FALSE,
FALSE, bundle_loader, force_weak);
}
-#if defined(VM_SYNC_DEACTIVATE) && !defined(_POSIX_C_SOURCE)
+#if defined(VM_SYNC_DEACTIVATE) && !defined(_POSIX_C_SOURCE) && !defined(__NetBSD__)
vm_msync(mach_task_self(), (vm_address_t)file_addr,
(vm_size_t)file_size, VM_SYNC_DEACTIVATE);
#endif /* VM_SYNC_DEACTIVATE */
diff -Nur odcctools.orig/ld/pass2.c odcctools/ld/pass2.c
--- odcctools.orig/ld/pass2.c 2012-06-07 21:55:05.000000000 +0900
+++ odcctools/ld/pass2.c 2012-06-13 00:13:40.000000000 +0900
@@ -269,7 +269,7 @@
}
}
output_local_symbols();
-#if defined(VM_SYNC_DEACTIVATE) && !defined(_POSIX_C_SOURCE)
+#if defined(VM_SYNC_DEACTIVATE) && !defined(_POSIX_C_SOURCE) && !defined(__NetBSD__)
vm_msync(mach_task_self(), (vm_address_t)cur_obj->obj_addr,
(vm_size_t)cur_obj->obj_size, VM_SYNC_DEACTIVATE);
#endif /* VM_SYNC_DEACTIVATE */
@@ -874,7 +874,7 @@
print(" writing (write_offset = %lu write_size = %lu)\n",
write_offset, write_size);
#endif /* DEBUG */
- lseek(fd, write_offset, L_SET);
+ lseek(fd, write_offset, SEEK_SET);
if(write(fd, output_addr + write_offset, write_size) !=
(int)write_size)
system_fatal("can't write to output file");
@@ -936,7 +936,7 @@
print(" writing (write_offset = %lu write_size = %lu)\n",
write_offset, write_size);
#endif /* DEBUG */
- lseek(fd, write_offset, L_SET);
+ lseek(fd, write_offset, SEEK_SET);
if(write(fd, output_addr + write_offset, write_size) !=
(int)write_size)
system_fatal("can't write to output file");
diff -Nur odcctools.orig/libstuff/arch.c odcctools/libstuff/arch.c
--- odcctools.orig/libstuff/arch.c 2012-06-07 21:55:22.000000000 +0900
+++ odcctools/libstuff/arch.c 2012-06-13 00:13:40.000000000 +0900
@@ -21,6 +21,10 @@
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef RLD
+#ifdef __NetBSD__
+typedef volatile unsigned char __cpu_simple_lock_t;
+#include <pthread_types.h>
+#endif
#include "stdio.h"
#endif /* !defined(RLD) */
#include "stdlib.h"
diff -Nur odcctools.orig/libstuff/dylib_roots.c odcctools/libstuff/dylib_roots.c
--- odcctools.orig/libstuff/dylib_roots.c 2012-06-07 21:55:22.000000000 +0900
+++ odcctools/libstuff/dylib_roots.c 2012-06-13 00:13:40.000000000 +0900
@@ -32,6 +32,9 @@
#include <fts.h>
#endif
#include <sys/errno.h>
+#ifdef __NetBSD__
+#include <errno.h>
+#endif
#include "stuff/bool.h"
#include "stuff/SymLoc.h"
#include "stuff/ofile.h"
diff -Nur odcctools.orig/libstuff/errors.c odcctools/libstuff/errors.c
--- odcctools.orig/libstuff/errors.c 2012-06-07 21:55:22.000000000 +0900
+++ odcctools/libstuff/errors.c 2012-06-13 00:13:40.000000000 +0900
@@ -21,6 +21,10 @@
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef RLD
+#ifdef __NetBSD__
+typedef volatile unsigned char __cpu_simple_lock_t;
+#include <pthread_types.h>
+#endif
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
diff -Nur odcctools.orig/libstuff/ofile.c odcctools/libstuff/ofile.c
--- odcctools.orig/libstuff/ofile.c 2012-06-07 21:55:22.000000000 +0900
+++ odcctools/libstuff/ofile.c 2012-06-13 00:13:41.000000000 +0900
@@ -105,7 +105,7 @@
unsigned long module_index);
#ifndef OTOOL
-#ifdef ALIGNMENT_CHECKS
+#ifdef ALIGNMENT_CHECKS_ARCHIVE_64_BIT
static
void
temporary_archive_member_warning(
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment