From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/12218 Path: news.gmane.org!.POSTED!not-for-mail From: Nicholas Wilson Newsgroups: gmane.linux.lib.musl.general Subject: [PATCH] split __libc_start_main.c into two files (Wasm) Date: Thu, 7 Dec 2017 14:51:31 +0000 Message-ID: Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1512658310 8127 195.159.176.226 (7 Dec 2017 14:51:50 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 7 Dec 2017 14:51:50 +0000 (UTC) To: "musl@lists.openwall.com" Original-X-From: musl-return-12234-gllmg-musl=m.gmane.org@lists.openwall.com Thu Dec 07 15:51:46 2017 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1eMxWb-0001vm-9K for gllmg-musl@m.gmane.org; Thu, 07 Dec 2017 15:51:45 +0100 Original-Received: (qmail 32667 invoked by uid 550); 7 Dec 2017 14:51:49 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 32633 invoked from network); 7 Dec 2017 14:51:49 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=realvnc.onmicrosoft.com; s=selector1-realvnc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=Zo2ZqBDoUBmTeXxV3EUJNS0iPIHj487SK6cKR/SbjGo=; b=M+dto72iyAoPVQUNvTOFkzcKU/UQ0UQ3+TOeTsU5xLnvSKk7NKn0X6qXspKvVQ362s3AQTnSPyWAHY3yifZpP9X7Pmnb3wrsAWSlwS0Aw1GWwtI1dYJxJuuG5D74NggDYPStUcOtj0Udo0tXgTVtXC1ySBTTh2lzQfH6Uv7GIrE= Thread-Topic: [PATCH] split __libc_start_main.c into two files (Wasm) Thread-Index: AQHTb2pBP8VsOCdulkepcQ6wgWaD9g== Accept-Language: en-GB, en-US Content-Language: en-GB X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [2a02:390:a001:192:d6be:d9ff:fe9c:1892] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;VI1PR0502MB3886;6:y8d2QMqxLj1OIaVgJ2ZrBbZjMtulV3o+mXaZJNLC23b03iWL4Eub91MEmIts2NhH4eFbL5y62pWSoa6K9bwltvi9j5QB7N2pjooLYP53jIoIJbNZ1z9VSOxmsrJ7DxJ0WS1uII3OLb8vAr2ZGi4vfBE3al7kvbWJUUbbA/WZsoMajJgQvsNFmYsfTPF1F8EHM8cJzgXMZroX5CmB+owBb10IpvYDqIcoF+DvR3rTKcdQ2v92MVrwHYgo5a3NRjb5E6fKn5XqY/SeeQp4Ul7IIWiNjJ2SVpqaW3PSNredOB59QWdmr4QrIjy83Ipne8Wh91ZRnikGbnz13PsAzznQDX+4OKRi7jsl0fMat13pwLA=;5:UzsI/S0dow4VZE5wjh+gUcUW96Fydl0TWX6kd0SBnBkz/cuzMTigEcVFhLpu0UHm39BToU0iUdf7kclZivc4SpzzY4/OtiPdH3c6N3GKujGEhuB19oo8PAurMDRtqlLjalGltXaIVmhSHOd0/hqWPgJTS2Dp1BemcgmUoxYetPo=;24:P4uTfZyO3T/T1GIFrogLGSOsloLOJh/SvD8N4aVq1W0Iuj7nhzcZ9nKOplz3ZUMDKN0SzjtcKKS5RqE2S/3zE4ZtTg7W6A7zX9pD8IKxA1w=;7:GWWt09kC16z4Kgn7DnWPsYcmk5I0UDs8cvLLxsUovJyPrr9mdxrZ5mQ+69lbqlC2GDnlDApMcILljgrIYK+ugZxlGsNP fbqVh709hAxBavo4RUPonfn5s5hBaMYuyhr7kIQTtezvqkQzCqCt9S3A26kKZS6Rkm5YeqFSEmB7KrKjRdNWdMvpQ4JxwmV2cE x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-correlation-id: 0cd26dcc-c1d5-4aa9-59d3-08d53d82012e x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(5600026)(4604075)(4534020)(4602075)(4603075)(4627115)(201702281549075)(2017052603286);SRVR:VI1PR0502MB3886; x-ms-traffictypediagnostic: VI1PR0502MB3886: authentication-results: spf=none (sender IP is ) smtp.mailfrom=nicholas.wilson@realvnc.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(278428928389397); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040450)(2401047)(5005006)(8121501046)(3002001)(3231022)(93006095)(93001095)(10201501046)(6041248)(20161123555025)(20161123560025)(20161123564025)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(2016111802025)(20161123562025)(6043046)(6072148)(201708071742011);SRVR:VI1PR0502MB3886;BCL:0;PCL:0;RULEID:(100000803101)(100110400095);SRVR:VI1PR0502MB3886; x-forefront-prvs: 05143A8241 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(979002)(376002)(39830400002)(346002)(366004)(199004)(189003)(3280700002)(99286004)(53936002)(6436002)(68736007)(14454004)(8936002)(3660700001)(5640700003)(74316002)(6506006)(5660300001)(6916009)(8676002)(305945005)(81166006)(1730700003)(6116002)(7736002)(478600001)(101416001)(25786009)(55016002)(102836003)(2906002)(81156014)(2501003)(86362001)(575784001)(9686003)(2900100001)(97736004)(7696005)(106356001)(105586002)(316002)(2351001)(5250100002)(33656002)(969003)(989001)(999001)(1009001)(1019001);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR0502MB3886;H:VI1PR0502MB3885.eurprd05.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; received-spf: None (protection.outlook.com: realvnc.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM X-MS-Exchange-CrossTenant-Network-Message-Id: 0cd26dcc-c1d5-4aa9-59d3-08d53d82012e X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Dec 2017 14:51:31.6244 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 9ad766d3-c6a5-4458-8c58-244e7c118728 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0502MB3886 X-OriginatorOrg: realvnc.com Xref: news.gmane.org gmane.linux.lib.musl.general:12218 Archived-At: Hi, I've got some more patches to try and get in for Wasm support. Here's one that should be fairly straightforward? In Musl, most (non-static= ) functions are in a file of their own, which is good from a linkage point = of view. I'd like to have __libc_start_main.c split into two files, because for Wasm= I'd like to be able to call __libc_start_init (from within the CRT directo= ry) but without having to link in exit(), since many Wasm applications will= never call exit() and won't necessarily use main. There's no pollution of the codebase, it's purely splitting a file. Patch below. Nick =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D commit 3096e0e5e17ff5ee14288574503ad22d8e3d119c Author: Nicholas Wilson Date: Thu Dec 7 11:52:32 2017 +0000 [Wasm] split __libc_start_main.c into two files, for archs that want __= libc_start_init but might potentially not link in exit() diff --git a/src/env/__libc_start_init.c b/src/env/__libc_start_init.c new file mode 100644 index 00000000..ec05e1df --- /dev/null +++ b/src/env/__libc_start_init.c @@ -0,0 +1,64 @@ +#include +#include +#include +#include +#include "syscall.h" +#include "atomic.h" +#include "libc.h" + +void __init_tls(size_t *); + +static void dummy(void) {} +weak_alias(dummy, _init); + +__attribute__((__weak__, __visibility__("hidden"))) +extern void (*const __init_array_start)(void), (*const __init_array_end)(v= oid); + +static void dummy1(void *p) {} +weak_alias(dummy1, __init_ssp); + +#define AUX_CNT 38 + +void __init_libc(char **envp, char *pn) +{ + size_t i, *auxv, aux[AUX_CNT] =3D { 0 }; + __environ =3D envp; + for (i=3D0; envp[i]; i++); + libc.auxv =3D auxv =3D (void *)(envp+i+1); + for (i=3D0; auxv[i]; i+=3D2) if (auxv[i] -#include -#include -#include -#include "syscall.h" -#include "atomic.h" -#include "libc.h" +#include =20 -void __init_tls(size_t *); - -static void dummy(void) {} -weak_alias(dummy, _init); - -__attribute__((__weak__, __visibility__("hidden"))) -extern void (*const __init_array_start)(void), (*const __init_array_end)(v= oid); - -static void dummy1(void *p) {} -weak_alias(dummy1, __init_ssp); - -#define AUX_CNT 38 - -void __init_libc(char **envp, char *pn) -{ - size_t i, *auxv, aux[AUX_CNT] =3D { 0 }; - __environ =3D envp; - for (i=3D0; envp[i]; i++); - libc.auxv =3D auxv =3D (void *)(envp+i+1); - for (i=3D0; auxv[i]; i+=3D2) if (auxv[i]