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=-0.8 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,HTML_MESSAGE,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H2 autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 9345 invoked from network); 13 Nov 2022 00:18:47 -0000 Received: from second.openwall.net (193.110.157.125) by inbox.vuxu.org with ESMTPUTF8; 13 Nov 2022 00:18:47 -0000 Received: (qmail 19924 invoked by uid 550); 13 Nov 2022 00:18:44 -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 13383 invoked from network); 13 Nov 2022 00:11:52 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=NP/2/PE1/Sbi6lIlfFfkUbsDViSRmTt7Nx2IuzirL7A=; b=n64BsvCqztXZZhbYjeh10LAHoRBtF0Dn2hUXi6EH4Z1SZX03pNM7XSNZGcDnJhye/o vSd9rD9Btcr9Gg1mTlLQg/+MZ4ADrIdDaAaOJKA+wQBqddMHBUTHCnMvxqK6fCc76Xyw J3AvvrLZe2eJSDpIDm8LPJd+CPTfNzl51zJIe2cM/POASc9Vm4mvF+sXcR+wxeSxsIRb sOAPYTTH4zMK9kivl+FucLV/HUwOnGfaBANCGlGcpXcHWLRWMyucsYEGELECvighZrno 8gRhY/pkOKLEYaddClHFQeYII1QuQpFEy9d10bqWbEAM1CzOshTFiFs4P5nn4YmwAoH/ iBuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=NP/2/PE1/Sbi6lIlfFfkUbsDViSRmTt7Nx2IuzirL7A=; b=usek8cYB7IHRLVE8gAflwFMBF8yHq+PfvEsinLwkXpQlSfql+i9el9F3TQCIUp2oyO MfH5xW01zpB/F7kAW0+NGND/Un+dsWa9PhRJm2u3o1b3OXOK0wf0xK9xFNRLYpLy9BeD EVGhbrgFHGJGb4FjU2Zkk8G8YNeb9VjXBMsOu2b97anSgBV8KSdW4TQo5zyont+zVD4M KRahhnuQZdDhKRUnGTDsRpSl6NXv6RAMMYxZmGmDcBFJ/jDZgNn9N+7cE1p9DBV6E/QE cpNo3r1Cv4yTg8fZx1na9x4/OvxsqMlz6WkiPKBEXM1HnV8IRBkGlvDbXSE4McKhJGlh SlzA== X-Gm-Message-State: ANoB5pnXVgqhRArJnbWUkhhyHKBZe6bTI0jbAg9Ltt0qCypNwvawxXqm iOwsiFTTlxxZReeuxeidzZS+T/YJgAAuIuQbGLvBxNyXF44= X-Google-Smtp-Source: AA0mqf63/6SHEb+ihm1vMeP1isrqihsiuEAj88w97NBrW9oRR8GMJB2cu3fDBhrOFdmPnvF3IOfgRTgEmxN6SNbqjR8= X-Received: by 2002:a05:6830:631b:b0:66c:6096:1878 with SMTP id cg27-20020a056830631b00b0066c60961878mr4082079otb.203.1668298300562; Sat, 12 Nov 2022 16:11:40 -0800 (PST) MIME-Version: 1.0 From: Rui Ueyama Date: Sun, 13 Nov 2022 08:11:29 +0800 Message-ID: To: musl@lists.openwall.com Content-Type: multipart/alternative; boundary="00000000000095a22b05ed4ef752" Subject: [musl] `musl-gcc -static` and lld/mold --00000000000095a22b05ed4ef752 Content-Type: text/plain; charset="UTF-8" Hi, I think I found a musl-gcc issue. It looks like musl-gcc always appends `-dynamic-linker /lib/ld-musl-x86_64.so.1` even if `-static` is given. That causes a created program to immediately crash on startup as you can see below: $ cat hello.c #include int main() { printf("Hello\n"); } $ musl-gcc -static -fuse-ld=lld hello.c -o hello $ ./hello Segmentation fault (core dumped) $ musl-gcc -static -fuse-ld=lld hello.c -o hello -Wl,-no-dynamic-linker $ ./hello Hello This also happens to my new linker, mold, as well. `-dynamic-linker` option is passed to the linker, and lld and mold do what it is told to do, so I don't think it is a linker's bug. Rather, it's a compiler front end's bug that passes the unnecessary command line option. Can you not to append `-dynamic-linker` if `-static`? Rui Ueyama --00000000000095a22b05ed4ef752 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi,

I think I found a musl-gcc issue. I= t looks like musl-gcc always appends `-dynamic-linker /lib/ld-musl-x86_64.s= o.1` even if `-static` is given. That causes a created program to immediate= ly crash on startup as you can see below:

$ cat hello.c<= /div>
#include <stdio.h>
int main() { printf("Hello\n&quo= t;); }

$ musl-gcc -static -fuse-ld=3Dlld hello= .c -o hello

$ ./hello
Segmentation fault (c= ore dumped)

$ musl-gcc -static -fuse-ld= =3Dlld hello.c -o hello -Wl,-no-dynamic-linker
$ ./hello
Hello

This also happens=C2=A0to my new= linker, mold, as well. `-dynamic-linker` option is passed to the linker, a= nd lld and mold do what it is told to do, so I don't think it is a link= er's bug. Rather, it's a compiler front end's bug that passes t= he unnecessary command line option. Can you not to append `-dynamic-linker`= if `-static`?

Rui Ueyama
--00000000000095a22b05ed4ef752--