mailing list of musl libc
 help / color / mirror / code / Atom feed
* [PATCH] __libc_start_main: slightly simplify stage2 pointer setup
@ 2018-10-20 21:27 Alexander Monakov
  2018-10-22 17:45 ` Rich Felker
  0 siblings, 1 reply; 2+ messages in thread
From: Alexander Monakov @ 2018-10-20 21:27 UTC (permalink / raw)
  To: musl; +Cc: Alexander Monakov

Use "+r" in the asm instead of implementing a non-transparent copy by
applying "0" constraint to the source value. Introduce a typedef for
the function type to avoid spelling it out twice.
---

I didn't get credited in the asm bugfix, but I still want to leave my mark ;)

Thanks.
Alexander

 src/env/__libc_start_main.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/env/__libc_start_main.c b/src/env/__libc_start_main.c
index b4965d7f..7c95f822 100644
--- a/src/env/__libc_start_main.c
+++ b/src/env/__libc_start_main.c
@@ -66,7 +66,8 @@ static void libc_start_init(void)
 
 weak_alias(libc_start_init, __libc_start_init);
 
-static int libc_start_main_stage2(int (*)(int,char **,char **), int, char **);
+typedef int lsm2_fn(int (*)(int,char **,char **), int, char **);
+static lsm2_fn libc_start_main_stage2;
 
 int __libc_start_main(int (*main)(int,char **,char **), int argc, char **argv)
 {
@@ -79,8 +80,8 @@ int __libc_start_main(int (*main)(int,char **,char **), int argc, char **argv)
 
 	/* Barrier against hoisting application code or anything using ssp
 	 * or thread pointer prior to its initialization above. */
-	int (*stage2)(int (*)(int,char **,char **), int, char **);
-	__asm__ ( "" : "=r"(stage2) : "0"(libc_start_main_stage2) : "memory" );
+	lsm2_fn *stage2 = libc_start_main_stage2;
+	__asm__ ( "" : "+r"(stage2) : : "memory" );
 	return stage2(main, argc, argv);
 }
 
-- 
2.11.0



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-10-22 17:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-20 21:27 [PATCH] __libc_start_main: slightly simplify stage2 pointer setup Alexander Monakov
2018-10-22 17:45 ` Rich Felker

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).