about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRoland McGrath <roland@hack.frob.com>2015-08-25 13:37:07 -0700
committerRoland McGrath <roland@hack.frob.com>2015-08-25 13:40:00 -0700
commit64c25345714d792b283c8c8469d58f898d1ef109 (patch)
tree254dafcfdc3278d9aa48ff3f499670e6f7003f2a
parent9031106ea063f0476bdabf3f5ec22758cdcf987b (diff)
downloadglibc-fedora/2.22/master.tar.gz
glibc-fedora/2.22/master.tar.xz
glibc-fedora/2.22/master.zip
NaCl: Call __nacl_main in preference to main. fedora/2.22/master
(cherry picked from commit f97194930886838796546646e26a49bb5899075b)
-rw-r--r--ChangeLog5
-rw-r--r--sysdeps/nacl/start.c6
2 files changed, 10 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index c2bdf59b51..8230149d4a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-08-25  Roland McGrath  <roland@hack.frob.com>
+
+	* sysdeps/nacl/start.c (_start): Call __nacl_main instead of main
+	if the weak reference is not null.
+
 2015-08-19  Andrew Senkevich  <andrew.senkevich@intel.com>
 
 	[BZ #18796]
diff --git a/sysdeps/nacl/start.c b/sysdeps/nacl/start.c
index a4b6dd33d4..8e8bc1a05e 100644
--- a/sysdeps/nacl/start.c
+++ b/sysdeps/nacl/start.c
@@ -44,6 +44,10 @@
 /* The application defines this, of course.  */
 extern int main (int argc, char **argv, char **envp);
 
+/* But maybe it defines this too, in which case it takes precedence.  */
+extern int __nacl_main (int argc, char **argv, char **envp)
+  __attribute__ ((weak));
+
 /* These are defined in libc.  */
 extern int __libc_csu_init (int argc, char **argv, char **envp);
 extern void __libc_csu_fini (void);
@@ -59,7 +63,7 @@ _start (uint32_t info[])
 {
   /* The generic code actually assumes that envp follows argv.  */
 
-  __libc_start_main (&main,
+  __libc_start_main (&__nacl_main ?: &main,
 		     nacl_startup_argc (info),
 		     nacl_startup_argv (info),
 		     nacl_startup_auxv (info),