From patchwork Tue Aug 25 20:41:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roland McGrath X-Patchwork-Id: 510615 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id E989A14010F for ; Wed, 26 Aug 2015 06:41:12 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b=vRoHKr4A; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:content-type :content-transfer-encoding:from:to:subject:message-id:date; q= dns; s=default; b=prh9MeKAatKl0PuD+ZN6YLxhsC9EyLUmwIJHo+2fv8MHIS Nb0t1QDQYt3/qi4WiogkcQPWLo9C7n4tR+MePXWnykEUq6mBkDiSUJuSEf1NsKjP sQ3+Xvdbg+KSR06x0oFK/odv6CqMAx9XmTlO3Lw5YstKY4VL/3dXgUTsExEZc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:content-type :content-transfer-encoding:from:to:subject:message-id:date; s= default; bh=iUtaf7iMaGWdraiuhYSejoXzbLM=; b=vRoHKr4AFsAn+wpV1m7Z 3CgPXeuo3u11cmXkYNuR+NXISwuPzDzdtKGj4S63zjI7iEvtcj3z9HTLI4Sxt3zJ oSBSuobxnutnue/Ootx900z7Y2bEqz5UOE7OKDG6l75pAiPQDqU+9bwrC9JxVTvI I5iAjK9gN3KtvBKZs2RD/l4= Received: (qmail 27248 invoked by alias); 25 Aug 2015 20:41:06 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 27231 invoked by uid 89); 25 Aug 2015 20:41:05 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_NONE autolearn=no version=3.3.2 X-HELO: topped-with-meat.com MIME-Version: 1.0 From: Roland McGrath To: "GNU C. Library" Subject: [COMMITTED PATCH] NaCl: Call __nacl_main in preference to main. Message-Id: <20150825204100.703242C39FB@topped-with-meat.com> Date: Tue, 25 Aug 2015 13:41:00 -0700 (PDT) X-CMAE-Score: 0 X-CMAE-Analysis: v=2.1 cv=SvUDtp+0 c=1 sm=1 tr=0 a=WkljmVdYkabdwxfqvArNOQ==:117 a=14OXPxybAAAA:8 a=hOe2yjtxAAAA:8 a=kj9zAlcOel0A:10 a=VQslKzW27LWaaJZCib4A:9 a=CjuIK1q_8ugA:10 The norm for NaCl C libraries is to call __nacl_main if it's defined, rather than main. This allows for libraries that wrap an application's original main function. I've also cherry-picked this onto the 2.22 branch. Thanks, Roland 2015-08-25 Roland McGrath * sysdeps/nacl/start.c (_start): Call __nacl_main instead of main if the weak reference is not null. diff --git a/sysdeps/nacl/start.c b/sysdeps/nacl/start.c index a4b6dd3..8e8bc1a 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),