Add patches for MacOS compilation.

Change-Id: I9176bacf7c393715b244706df9731b0e914eb228
diff --git a/0.153/libdw/Android.mk b/0.153/libdw/Android.mk
index d196931..38b6f88 100755
--- a/0.153/libdw/Android.mk
+++ b/0.153/libdw/Android.mk
@@ -14,7 +14,7 @@
 
 LOCAL_PATH := $(call my-dir)
 
-supported_platforms := linux-x86
+supported_platforms := linux-x86 darwin-x86
 cur_platform := $(filter $(HOST_OS)-$(HOST_ARCH),$(supported_platforms))
 
 ifdef cur_platform
diff --git a/0.153/libdw/dwarf_begin.c b/0.153/libdw/dwarf_begin.c
index 69935a4..8a41914 100644
--- a/0.153/libdw/dwarf_begin.c
+++ b/0.153/libdw/dwarf_begin.c
@@ -95,6 +95,7 @@
   elf = elf_begin (fd, elfcmd, NULL);
   if (elf == NULL)
     {
+#ifndef __APPLE__
       /* Test why the `elf_begin" call failed.  */
       struct stat64 st;
 
@@ -104,6 +105,9 @@
 	__libdw_seterrno (DWARF_E_INVALID_FILE);
       else
 	__libdw_seterrno (DWARF_E_IO_ERROR);
+#else
+      __libdw_seterrno (DWARF_E_IO_ERROR);
+#endif
     }
   else
     {
diff --git a/0.153/libdw/dwarf_error.c b/0.153/libdw/dwarf_error.c
index 0d95b8d..a298a19 100644
--- a/0.153/libdw/dwarf_error.c
+++ b/0.153/libdw/dwarf_error.c
@@ -59,7 +59,11 @@
 
 
 /* The error number.  */
+#ifdef __APPLE__
+static int global_error;
+#else
 static __thread int global_error;
+#endif
 
 
 int
diff --git a/0.153/libdwfl/Android.mk b/0.153/libdwfl/Android.mk
index 435e9c9..3101914 100755
--- a/0.153/libdwfl/Android.mk
+++ b/0.153/libdwfl/Android.mk
@@ -14,7 +14,7 @@
 
 LOCAL_PATH := $(call my-dir)
 
-supported_platforms := linux-x86
+supported_platforms := linux-x86 darwin-x86
 cur_platform := $(filter $(HOST_OS)-$(HOST_ARCH),$(supported_platforms))
 
 ifdef cur_platform
diff --git a/0.153/libdwfl/dwfl_error.c b/0.153/libdwfl/dwfl_error.c
index a73d667..966c990 100644
--- a/0.153/libdwfl/dwfl_error.c
+++ b/0.153/libdwfl/dwfl_error.c
@@ -62,7 +62,11 @@
 
 
 /* The error number.  */
+#ifdef __APPLE__
+static int global_error;
+#else
 static __thread int global_error;
+#endif
 
 
 int
diff --git a/0.153/libebl/Android.mk b/0.153/libebl/Android.mk
index a602d6d..e8c7db8 100755
--- a/0.153/libebl/Android.mk
+++ b/0.153/libebl/Android.mk
@@ -14,7 +14,7 @@
 
 LOCAL_PATH := $(call my-dir)
 
-supported_platforms := linux-x86
+supported_platforms := linux-x86 darwin-x86
 cur_platform := $(filter $(HOST_OS)-$(HOST_ARCH),$(supported_platforms))
 
 ifdef cur_platform
diff --git a/0.153/libebl/eblopenbackend.c b/0.153/libebl/eblopenbackend.c
index 60e7f84..542df62 100644
--- a/0.153/libebl/eblopenbackend.c
+++ b/0.153/libebl/eblopenbackend.c
@@ -196,8 +196,13 @@
 				 uint32_t descsz, const char *desc);
 static bool default_debugscn_p (const char *name);
 static bool default_copy_reloc_p (int reloc);
+#ifndef __APPLE__
 static bool default_none_reloc_p (int reloc);
 static bool default_relative_reloc_p (int reloc);
+#else
+#define default_none_reloc_p            default_copy_reloc_p
+#define default_relative_reloc_p        default_copy_reloc_p
+#endif
 static bool default_check_special_symbol (Elf *elf, GElf_Ehdr *ehdr,
 					  const GElf_Sym *sym,
 					  const char *name,
@@ -687,8 +692,10 @@
 {
   return false;
 }
+#ifndef __APPLE__
 strong_alias (default_copy_reloc_p, default_none_reloc_p)
 strong_alias (default_copy_reloc_p, default_relative_reloc_p)
+#endif
 
 static bool
 default_check_special_symbol (Elf *elf __attribute__ ((unused)),
diff --git a/0.153/libelf/Android.mk b/0.153/libelf/Android.mk
index f9fcbcc..3e6188f 100755
--- a/0.153/libelf/Android.mk
+++ b/0.153/libelf/Android.mk
@@ -14,7 +14,7 @@
 
 LOCAL_PATH := $(call my-dir)
 
-supported_platforms := linux-x86
+supported_platforms := linux-x86 darwin-x86
 cur_platform := $(filter $(HOST_OS)-$(HOST_ARCH),$(supported_platforms))
 
 ifdef cur_platform
diff --git a/0.153/libelf/elf.h b/0.153/libelf/elf.h
index a9558a3..1d43deb 100644
--- a/0.153/libelf/elf.h
+++ b/0.153/libelf/elf.h
@@ -21,7 +21,9 @@
 #ifndef _ELF_H
 #define	_ELF_H 1
 
+#ifndef __APPLE__
 #include <features.h>
+#endif
 
 __BEGIN_DECLS
 
diff --git a/0.153/libelf/elf32_fsize.c b/0.153/libelf/elf32_fsize.c
index 3189045..d23e3a4 100644
--- a/0.153/libelf/elf32_fsize.c
+++ b/0.153/libelf/elf32_fsize.c
@@ -88,5 +88,7 @@
 	  * __libelf_type_sizes[0][ELFW(ELFCLASS,LIBELFBITS) - 1][type]);
 #endif
 }
+#ifndef __APPLE__
 #define local_strong_alias(n1, n2) strong_alias (n1, n2)
 local_strong_alias (elfw2(LIBELFBITS, fsize), __elfw2(LIBELFBITS, msize))
+#endif
diff --git a/0.153/libelf/elf_error.c b/0.153/libelf/elf_error.c
index 7f7504e..6394c02 100644
--- a/0.153/libelf/elf_error.c
+++ b/0.153/libelf/elf_error.c
@@ -62,7 +62,11 @@
 
 
 /* The error number.  */
+#ifdef __APPLE__
+static int global_error;
+#else
 static __thread int global_error;
+#endif
 
 
 int
diff --git a/0.153/libelf/elf_getshdrnum.c b/0.153/libelf/elf_getshdrnum.c
index ed1149b..5ca7fdd 100644
--- a/0.153/libelf/elf_getshdrnum.c
+++ b/0.153/libelf/elf_getshdrnum.c
@@ -107,5 +107,7 @@
 
   return result;
 }
+#ifndef __APPLE__
 /* Alias for the deprecated name.  */
 strong_alias (elf_getshdrnum, elf_getshnum)
+#endif
diff --git a/0.153/libelf/elf_getshdrstrndx.c b/0.153/libelf/elf_getshdrstrndx.c
index 5e89b34..a1aba5f 100644
--- a/0.153/libelf/elf_getshdrstrndx.c
+++ b/0.153/libelf/elf_getshdrstrndx.c
@@ -202,4 +202,6 @@
 }
 INTDEF(elf_getshdrstrndx)
 /* Alias for the deprecated name.  */
+#ifndef __APPLE__
 strong_alias (elf_getshdrstrndx, elf_getshstrndx)
+#endif
diff --git a/0.153/libelf/gelf_xlate.c b/0.153/libelf/gelf_xlate.c
index a4134c3..7cf3b3c 100644
--- a/0.153/libelf/gelf_xlate.c
+++ b/0.153/libelf/gelf_xlate.c
@@ -232,4 +232,6 @@
 /* For now we only handle the case where the memory representation is the
    same as the file representation.  Should this change we have to define
    separate functions.  For now reuse them.  */
+#ifndef __APPLE__
 strong_alias (__elf_xfctstom, __elf_xfctstof)
+#endif