From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 29723 invoked from network); 12 Jan 2021 03:29:53 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 12 Jan 2021 03:29:53 -0000 Received: (qmail 15787 invoked by uid 550); 12 Jan 2021 03:29:48 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 15769 invoked from network); 12 Jan 2021 03:29:47 -0000 Date: Mon, 11 Jan 2021 22:29:35 -0500 From: Rich Felker To: Sagar Tiwari Cc: musl@lists.openwall.com Message-ID: <20210112032935.GD23432@brightrain.aerifal.cx> References: <20210111181344.GB23432@brightrain.aerifal.cx> <20210111192420.GC23432@brightrain.aerifal.cx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [musl] printf segfaults on recent musl versions On Tue, Jan 12, 2021 at 06:33:10AM +0530, Sagar Tiwari wrote: > These changes fix the issue. > > Another alternative is to manually call '__init_libc' with two args > pointing to zeroed memory and > '__libc_start_init'. Don't know if it's safe? It's not. __init_libc is not a public function. You can call __libc_start_main (which is the ABI boundary) from your own entry point file if you like though but I don't see any reason to prefer that over just using [S]crt1.o. Rich > On 12/01/2021, Rich Felker wrote: > > On Tue, Jan 12, 2021 at 12:46:40AM +0530, Sagar Tiwari wrote: > >> I'm assembling a file with clang and linking it to custom compiled > >> musl with ld. This is the project I'm using: > >> > >> https://drive.google.com/file/d/1RiKZTf_nJUak14fz7kSXbh7egJuDthDk/view?usp=sharing > > > > In the future, please send attachments not Google Drive links. > > > >> musl 1.1.8 is the last version that works with this project. I used > >> clang 11.0.0 to compile both musl and this project. > > > > You can't call libc if you didn't enter the program through its entry > > point (or an ABI-compatible one). If you name the mn function main, > > link crt1.o (or the appropriate variant thereof), and drop the linker > > script (which may be omitting other necessary items), it should work > > as expected.