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.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,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 1163 invoked from network); 11 Jan 2021 19:16:54 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 11 Jan 2021 19:16:54 -0000 Received: (qmail 16296 invoked by uid 550); 11 Jan 2021 19:16:52 -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 16275 invoked from network); 11 Jan 2021 19:16:52 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=1txKzIg8W6V4G9b6GLG8R+dYXDE/H8DeiN3imyIjBHg=; b=K/Tw/72omVeuWIndon5WMX1hw6aSNJlmnRruR6WsfcOxiKnYRyTsSKq1zRI5GmoExA wyfzhrIlgmtdwyDl1HZzF0AKTtvF2WMvDP1P+DZ7b/rKrScuRShEscC50G2Mv1pHHgyU rdkc/BLrLK+NQkJewye02NbMjawrqY18z77gm5yn2Z2ZYiITrdbJ89uFZAnWOagQ1vGx ZrGDLKHW4pFnu00+q+ymRjMlS18d2VKqeWdELOIianVyURSxfFC04Q0WlNqTFZzzSZQA OeN4FM05A4eeoSVvQfhf9xGkgwaS2sI2Ey/5lfY6rlLPv3ESAvPFM+MKp8Xa8Ztor7ZH jmHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=1txKzIg8W6V4G9b6GLG8R+dYXDE/H8DeiN3imyIjBHg=; b=KZ6Z6W9ivslTaKoX1Y1kxto4ioR1h6Tyfhp3XgW91RwSIlt7dQL9T2h74CH3z706Nl qGwNeMCwkY/vtQ1zYak5qWsNxXxE98R9C4s6xFIwdTO1t92fRk2pmYrB99V//Kew2qw/ B7jPLTyY1vgWRS7gSYdhanTWKArlSs8h0MzS8Aqfndgvj0WOlkFQGDOqAutOw0Hpy2Z9 2nDk7Oxt7kHcvh01ELRwyhafYp6rVWuyhtOyMtS1dHZrjwgXU8HIkUxUVVhtEP96iP7a VBKGANY6Y2bs26MZo/yKf1rYTEZEG6b5gH4jxomENHJv9u3wC4qGnS8yYh83OQ8z8XJl k5gg== X-Gm-Message-State: AOAM532QfnvZM8RCiKG92ROZ3ypoOdKDgyV1N0ex84c3PrCU9XcXjO+1 mAp8TnsPm4oGs79Z2Jgbb9gxSEhvVhZzybXJR0BiDxBXDg== X-Google-Smtp-Source: ABdhPJzTomeKryWn6ufMO5BwsOReJSRHrNaKrYlGxa8kfeI4gtLl8LPr75LSejIsD8hQJJGtfvLZZfwu5yiwLYxKJ/Q= X-Received: by 2002:a05:6000:1d1:: with SMTP id t17mr632589wrx.164.1610392600713; Mon, 11 Jan 2021 11:16:40 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <20210111181344.GB23432@brightrain.aerifal.cx> References: <20210111181344.GB23432@brightrain.aerifal.cx> From: Sagar Tiwari Date: Tue, 12 Jan 2021 00:46:40 +0530 Message-ID: To: Rich Felker Cc: musl@lists.openwall.com Content-Type: text/plain; charset="UTF-8" Subject: Re: [musl] printf segfaults on recent musl versions 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 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. On 11/01/2021, Rich Felker wrote: > On Mon, Jan 11, 2021 at 10:31:21PM +0530, Sagar Tiwari wrote: >> Hi, >> >> Apologies if this isn't a support forum for musl. I couldn't find any >> such portal online. >> >> I'm trying to compile a program with musl libc. Dynamically linked >> version of this program works fine, but the statically linked version >> segfaults whenever `printf` is invoked. This is how a debugging >> session looks like: >> >>
>> $ gdb out/sm
>> GNU gdb (GDB) 9.2
>> Copyright (C) 2020 Free Software Foundation, Inc.
>> License GPLv3+: GNU GPL version 3 or later
>> 
>> This is free software: you are free to change and redistribute it.
>> There is NO WARRANTY, to the extent permitted by law.
>> Type "show copying" and "show warranty" for details.
>> This GDB was configured as "x86_64-unknown-linux-gnu".
>> Type "show configuration" for configuration details.
>> For bug reporting instructions, please see:
>> .
>> Find the GDB manual and other documentation resources online at:
>>     .
>>
>> For help, type "help".
>> Type "apropos word" to search for commands related to "word"...
>> Reading symbols from out/sm...
>> (gdb) b printf
>> Breakpoint 1 at 0x100ac: file src/stdio/printf.c, line 5.
>> (gdb) r
>> Starting program: /home/fctorial/src/pgs/c/out/sm
>>
>> Breakpoint 1, printf (fmt=0x1004f  "hello world from printf\n")
>> at src/stdio/printf.c:5
>> 5       {
>> (gdb) n
>>
>> Program received signal SIGSEGV, Segmentation fault.
>> 0x000000000001010a in printf (fmt=0x1004f  "hello world from
>> printf\n") at src/stdio/printf.c:5
>> 5       {
>> (gdb) quit
>> A debugging session is active.
>>
>>         Inferior 1 [process 25984] will be killed.
>>
>> Quit anyway? (y or n) EOF [assumed Y]
>>
>> 
>> >> This issue appears when linking with recent musl versions (within an >> year). 1.0.0 doesn't have this issue. I can call other functions like >> 'rand', 'strlen' without any issue. `printf` and `puts` are >> segfaulting. > > Can you elaborate on how you compiled/linked (using musl-gcc wrapper? > mcm-built or distro-provided toolchain or one you built yourself? > etc.) > > Judging from the very low address in gdb output, my guess is that you > have a broken toolchain that's trying to link static pie without using > the right link options or start files. > > Rich >