Index: ports/pnacl-binutils-src/nacl.patch |
diff --git a/ports/pnacl-binutils-src/nacl.patch b/ports/pnacl-binutils-src/nacl.patch |
new file mode 100644 |
index 0000000000000000000000000000000000000000..58de783e85bd8a8d9109a541917e880bf7885970 |
--- /dev/null |
+++ b/ports/pnacl-binutils-src/nacl.patch |
@@ -0,0 +1,383 @@ |
+diff --git a/bfd/configure b/bfd/configure |
+--- a/bfd/configure |
++++ b/bfd/configure |
+@@ -11809,9 +11809,7 @@ if test "${enable_plugins+set}" = set; then : |
+ enableval=$enable_plugins; case "${enableval}" in |
+ no) plugins=no ;; |
+ *) plugins=yes |
+- if test "$maybe_plugins" != "yes" ; then |
+- as_fn_error "Building with plugin support requires a host that supports dlopen." "$LINENO" 5 |
+- fi ;; |
++ ;; |
+ esac |
+ else |
+ plugins=$maybe_plugins |
+diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c |
+--- a/bfd/elfxx-mips.c |
++++ b/bfd/elfxx-mips.c |
+@@ -2161,6 +2161,7 @@ got_page_reloc_p (unsigned int r_type) |
+ return r_type == R_MIPS_GOT_PAGE || r_type == R_MICROMIPS_GOT_PAGE; |
+ } |
+ |
++#if !defined(__native_client__) |
+ static inline bfd_boolean |
+ got_ofst_reloc_p (unsigned int r_type) |
+ { |
+@@ -2172,6 +2173,7 @@ got_hi16_reloc_p (unsigned int r_type) |
+ { |
+ return r_type == R_MIPS_GOT_HI16 || r_type == R_MICROMIPS_GOT_HI16; |
+ } |
++#endif |
+ |
+ static inline bfd_boolean |
+ got_lo16_reloc_p (unsigned int r_type) |
+diff --git a/bfd/opncls.c b/bfd/opncls.c |
+--- a/bfd/opncls.c |
++++ b/bfd/opncls.c |
+@@ -673,6 +673,9 @@ bfd_openw (const char *filename, const char *target) |
+ static inline void |
+ _maybe_make_executable (bfd * abfd) |
+ { |
++#if defined(__native_client__) |
++ (void) abfd; |
++#else |
+ /* If the file was open for writing and is now executable, |
+ make it so. */ |
+ if (abfd->direction == write_direction |
+@@ -694,6 +697,7 @@ _maybe_make_executable (bfd * abfd) |
+ & (buf.st_mode | ((S_IXUSR | S_IXGRP | S_IXOTH) &~ mask)))); |
+ } |
+ } |
++#endif |
+ } |
+ |
+ /* |
+diff --git a/bfd/plugin.c b/bfd/plugin.c |
+--- a/bfd/plugin.c |
++++ b/bfd/plugin.c |
+@@ -28,6 +28,8 @@ |
+ #include <dlfcn.h> |
+ #elif defined (HAVE_WINDOWS_H) |
+ #include <windows.h> |
++#elif defined (__native_client__) |
++// Handled inline. |
+ #else |
+ #error Unknown how to handle dynamic-load-libraries. |
+ #endif |
+@@ -204,13 +206,19 @@ try_claim (bfd *abfd) |
+ static int |
+ try_load_plugin (const char *pname, bfd *abfd) |
+ { |
++#if !defined(__native_client__) |
+ void *plugin_handle; |
++#endif |
+ int tv_size = 4; |
+ struct ld_plugin_tv tv[tv_size]; |
+ int i; |
+ ld_plugin_onload onload; |
+ enum ld_plugin_status status; |
+ |
++#if defined(__native_client__) |
++ (void) pname; |
++ onload = 0; |
++#else |
+ plugin_handle = dlopen (pname, RTLD_NOW); |
+ if (!plugin_handle) |
+ { |
+@@ -221,6 +229,7 @@ try_load_plugin (const char *pname, bfd *abfd) |
+ onload = dlsym (plugin_handle, "onload"); |
+ if (!onload) |
+ goto err; |
++#endif |
+ |
+ i = 0; |
+ tv[i].tv_tag = LDPT_MESSAGE; |
+@@ -252,7 +261,9 @@ try_load_plugin (const char *pname, bfd *abfd) |
+ return 1; |
+ |
+ err: |
++#if !defined(__native_client__) |
+ plugin_handle = NULL; |
++#endif |
+ return 0; |
+ } |
+ |
+diff --git a/binutils/configure b/binutils/configure |
+--- a/binutils/configure |
++++ b/binutils/configure |
+@@ -11373,9 +11373,7 @@ if test "${enable_plugins+set}" = set; then : |
+ enableval=$enable_plugins; case "${enableval}" in |
+ no) plugins=no ;; |
+ *) plugins=yes |
+- if test "$maybe_plugins" != "yes" ; then |
+- as_fn_error "Building with plugin support requires a host that supports dlopen." "$LINENO" 5 |
+- fi ;; |
++ ;; |
+ esac |
+ else |
+ plugins=$maybe_plugins |
+diff --git a/gas/configure b/gas/configure |
+--- a/gas/configure |
++++ b/gas/configure |
+@@ -11353,9 +11353,7 @@ if test "${enable_plugins+set}" = set; then : |
+ enableval=$enable_plugins; case "${enableval}" in |
+ no) plugins=no ;; |
+ *) plugins=yes |
+- if test "$maybe_plugins" != "yes" ; then |
+- as_fn_error "Building with plugin support requires a host that supports dlopen." "$LINENO" 5 |
+- fi ;; |
++ ;; |
+ esac |
+ else |
+ plugins=$maybe_plugins |
+diff --git a/gold/Makefile.in b/gold/Makefile.in |
+--- a/gold/Makefile.in |
++++ b/gold/Makefile.in |
+@@ -563,7 +563,7 @@ incremental_dump_SOURCES = incremental-dump.cc |
+ incremental_dump_DEPENDENCIES = $(TARGETOBJS) libgold.a $(LIBIBERTY) \ |
+ $(LIBINTL_DEP) |
+ |
+-incremental_dump_LDADD = $(TARGETOBJS) libgold.a $(LIBIBERTY) $(LIBINTL) \ |
++incremental_dump_LDADD = $(TARGETOBJS) libgold.a $(LIBIBERTY) $(GOLD_LDADD) $(LIBINTL) \ |
+ $(THREADSLIB) $(LIBDL) |
+ |
+ dwp_SOURCES = dwp.cc |
+diff --git a/gold/descriptors.cc b/gold/descriptors.cc |
+--- a/gold/descriptors.cc |
++++ b/gold/descriptors.cc |
+@@ -48,7 +48,7 @@ static inline void |
+ set_close_on_exec(int fd ATTRIBUTE_UNUSED) |
+ { |
+ // @LOCALMOD-SB-BEGIN |
+-#if defined(__native_client__) |
++#if 0 && defined(__native_client__) |
+ gold::gold_fatal(_("NaCl gold: unexpected use of fcntl for %d"), fd); |
+ #else |
+ // Mingw does not define F_SETFD. |
+diff --git a/gold/fileread.cc b/gold/fileread.cc |
+--- a/gold/fileread.cc |
++++ b/gold/fileread.cc |
+@@ -180,7 +180,7 @@ File_read::~File_read() |
+ if (this->is_descriptor_opened_) |
+ { |
+ // @LOCALMOD-SB-BEGIN |
+-#if defined(__native_client__) |
++#if 0 && defined(__native_client__) |
+ nacl_file::NaClReleaseFileDescriptor(this->descriptor_); |
+ #else |
+ release_descriptor(this->descriptor_, true); |
+@@ -205,7 +205,7 @@ File_read::open(const Task* task, const std::string& name) |
+ this->name_ = name; |
+ |
+ // @LOCALMOD-SB-BEGIN |
+-#if defined(__native_client__) |
++#if 0 && defined(__native_client__) |
+ this->descriptor_ = nacl_file::NaClOpenFileDescriptor(this->name_.c_str()); |
+ #else |
+ this->descriptor_ = open_descriptor(-1, this->name_.c_str(), |
+@@ -257,7 +257,7 @@ File_read::reopen_descriptor() |
+ { |
+ |
+ // @LOCALMOD-SB-BEGIN |
+-#if defined(__native_client__) |
++#if 0 && defined(__native_client__) |
+ this->descriptor_ = nacl_file::NaClOpenFileDescriptor(this->name_.c_str()); |
+ #else |
+ this->descriptor_ = open_descriptor(this->descriptor_, |
+@@ -300,7 +300,7 @@ File_read::release() |
+ if (this->is_descriptor_opened_) |
+ { |
+ // @LOCALMOD-SB-BEGIN |
+-#if defined(__native_client__) |
++#if 0 && defined(__native_client__) |
+ nacl_file::NaClReleaseFileDescriptor(this->descriptor_); |
+ #else |
+ release_descriptor(this->descriptor_, false); |
+diff --git a/gold/main.cc b/gold/main.cc |
+--- a/gold/main.cc |
++++ b/gold/main.cc |
+@@ -137,7 +137,7 @@ write_debug_script(std::string, const char*, const char*) |
+ // For the in-browser sandboxed build, main() is defined in |
+ // nacl_file.cc and calls an IRT interface for handling the browser's |
+ // request. gold_main() is called by that request handler. |
+-#if defined(__native_client__) |
++#if 0 && defined(__native_client__) |
+ int |
+ gold_main(int argc, char** argv) |
+ #else |
+@@ -162,7 +162,7 @@ main(int argc, char** argv) |
+ // @LOCALMOD-SB: skip this in sandboxed mode since the commandline we |
+ // build will likely not have @filename (and we can avoid hijacking |
+ // the file open operation there). |
+-#if !defined(__native_client__) |
++#if 1 || !defined(__native_client__) |
+ expandargv(&argc, &argv); |
+ #endif |
+ |
+@@ -341,7 +341,7 @@ main(int argc, char** argv) |
+ // @LOCALMOD-SB-BEGIN |
+ // This function is called from an IPC request handler. We do not |
+ // want it to exit. |
+-#if defined(__native_client__) |
++#if 0 && defined(__native_client__) |
+ return errors.error_count() > 0; |
+ #else |
+ // If the user used --noinhibit-exec, we force the exit status to be |
+diff --git a/gold/output.cc b/gold/output.cc |
+--- a/gold/output.cc |
++++ b/gold/output.cc |
+@@ -5017,7 +5017,7 @@ Output_file::open(off_t file_size) |
+ // We let the name "-" mean "stdout" |
+ |
+ // @LOCALMOD-SB-BEGIN |
+-#if defined(__native_client__) |
++#if 0 && defined(__native_client__) |
+ int o = nacl_file::NaClOpenFileDescriptor(this->name_); |
+ if (o < 0) |
+ gold_fatal(_("%s: open: %s"), this->name_, strerror(errno)); |
+@@ -5037,6 +5037,7 @@ Output_file::open(off_t file_size) |
+ ::unlink(this->name_); |
+ else if (!parameters->options().relocatable()) |
+ { |
++#if !defined(__native_client__) |
+ // If we don't unlink the existing file, add execute |
+ // permission where read permissions already exist |
+ // and where the umask permits. |
+@@ -5044,6 +5045,7 @@ Output_file::open(off_t file_size) |
+ ::umask(mask); |
+ s.st_mode |= (s.st_mode & 0444) >> 2; |
+ ::chmod(this->name_, s.st_mode & ~mask); |
++#endif |
+ } |
+ } |
+ |
+diff --git a/gold/plugin.cc b/gold/plugin.cc |
+--- a/gold/plugin.cc |
++++ b/gold/plugin.cc |
+@@ -33,6 +33,8 @@ |
+ #include <dlfcn.h> |
+ #elif defined (HAVE_WINDOWS_H) |
+ #include <windows.h> |
++#elif defined (__native_client__) |
++/* Handled inline. */ |
+ #else |
+ #error Unknown how to handle dynamic-load-libraries. |
+ #endif |
+@@ -74,6 +76,10 @@ dlerror(void) |
+ #include "descriptors.h" |
+ #include "elfcpp.h" |
+ |
++#if defined(__native_client__) |
++extern "C" ld_plugin_status LLVMgold_onload(ld_plugin_tv *tv); |
++#endif |
++ |
+ namespace gold |
+ { |
+ |
+@@ -178,6 +184,9 @@ void |
+ Plugin::load() |
+ { |
+ #ifdef ENABLE_PLUGINS |
++#if defined(__native_client__) |
++ ld_plugin_onload onload = ::LLVMgold_onload; |
++#else |
+ // Load the plugin library. |
+ // FIXME: Look for the library in standard locations. |
+ this->handle_ = dlopen(this->filename_.c_str(), RTLD_NOW); |
+@@ -199,6 +208,7 @@ Plugin::load() |
+ ld_plugin_onload onload; |
+ gold_assert(sizeof(onload) == sizeof(ptr)); |
+ memcpy(&onload, &ptr, sizeof(ptr)); |
++#endif |
+ |
+ // Get the linker's version number. |
+ const char* ver = get_version_string(); |
+diff --git a/gprof/configure b/gprof/configure |
+--- a/gprof/configure |
++++ b/gprof/configure |
+@@ -11283,9 +11283,7 @@ if test "${enable_plugins+set}" = set; then : |
+ enableval=$enable_plugins; case "${enableval}" in |
+ no) plugins=no ;; |
+ *) plugins=yes |
+- if test "$maybe_plugins" != "yes" ; then |
+- as_fn_error "Building with plugin support requires a host that supports dlopen." "$LINENO" 5 |
+- fi ;; |
++ ;; |
+ esac |
+ else |
+ plugins=$maybe_plugins |
+diff --git a/ld/configure b/ld/configure |
+--- a/ld/configure |
++++ b/ld/configure |
+@@ -15109,14 +15109,14 @@ fi |
+ done |
+ |
+ |
++enable_plugins=no |
++ |
+ # Check whether --enable-plugins was given. |
+ if test "${enable_plugins+set}" = set; then : |
+ enableval=$enable_plugins; case "${enableval}" in |
+ no) plugins=no ;; |
+ *) plugins=yes |
+- if test "$maybe_plugins" != "yes" ; then |
+- as_fn_error "Building with plugin support requires a host that supports dlopen." "$LINENO" 5 |
+- fi ;; |
++ ;; |
+ esac |
+ else |
+ plugins=$maybe_plugins |
+diff --git a/libiberty/strsignal.c b/libiberty/strsignal.c |
+--- a/libiberty/strsignal.c |
++++ b/libiberty/strsignal.c |
+@@ -550,6 +550,7 @@ followed by a newline. |
+ |
+ #ifndef HAVE_PSIGNAL |
+ |
++#if !defined(__native_client__) |
+ void |
+ psignal (int signo, char *message) |
+ { |
+@@ -566,6 +567,7 @@ psignal (int signo, char *message) |
+ fprintf (stderr, "%s: %s\n", message, sys_siglist[signo]); |
+ } |
+ } |
++#endif |
+ |
+ #endif /* ! HAVE_PSIGNAL */ |
+ |
+diff --git a/libiberty/vfork.c b/libiberty/vfork.c |
+--- a/libiberty/vfork.c |
++++ b/libiberty/vfork.c |
+@@ -11,6 +11,7 @@ Emulates @code{vfork} by calling @code{fork} and returning its value. |
+ |
+ */ |
+ |
++#if !defined(__native_client__) |
+ #include "ansidecl.h" |
+ |
+ extern int fork (void); |
+@@ -20,3 +21,4 @@ vfork (void) |
+ { |
+ return (fork ()); |
+ } |
++#endif |
+diff --git a/opcodes/mips-dis.c b/opcodes/mips-dis.c |
+--- a/opcodes/mips-dis.c |
++++ b/opcodes/mips-dis.c |
+@@ -157,6 +157,7 @@ static const char * const mips_cp0_names_r5900[32] = |
+ "c0_taglo", "c0_taghi", "c0_errorepc", "$31" |
+ }; |
+ |
++#if !defined(__native_client__) |
+ static const struct mips_cp0sel_name mips_cp0sel_names_mipsr5900[] = |
+ { |
+ { 24, 2, "c0_iab" }, |
+@@ -168,6 +169,7 @@ static const struct mips_cp0sel_name mips_cp0sel_names_mipsr5900[] = |
+ { 25, 1, "c0_perfcnt,1" }, |
+ { 25, 2, "c0_perfcnt,2" } |
+ }; |
++#endif |
+ |
+ static const char * const mips_cp0_names_mips3264[32] = |
+ { |