From patchwork Sun Feb 11 06:29:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Chestnykh X-Patchwork-Id: 1897414 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=BdDidvu+; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=uclibc-ng.org (client-ip=2a00:1828:2000:679::23; helo=helium.openadk.org; envelope-from=devel-bounces@uclibc-ng.org; receiver=patchwork.ozlabs.org) Received: from helium.openadk.org (helium.openadk.org [IPv6:2a00:1828:2000:679::23]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TXd4V4mLKz23dJ for ; Sun, 11 Feb 2024 17:30:18 +1100 (AEDT) Received: from helium.openadk.org (localhost [IPv6:::1]) by helium.openadk.org (Postfix) with ESMTP id A1B623521113; Sun, 11 Feb 2024 07:30:09 +0100 (CET) Authentication-Results: helium.openadk.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=BdDidvu+; dkim-atps=neutral Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com [209.85.208.172]) by helium.openadk.org (Postfix) with ESMTPS id 3AA6535205A0 for ; Sun, 11 Feb 2024 07:29:48 +0100 (CET) Received: by mail-lj1-f172.google.com with SMTP id 38308e7fff4ca-2d0cc05abd3so9772591fa.0 for ; Sat, 10 Feb 2024 22:29:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707632987; x=1708237787; darn=uclibc-ng.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=QJZ8r1XqWThzRkF/2DRghmX/j7iNrSZFfXxvfMTOzJ0=; b=BdDidvu+irwBrh3mBjPpejI9Hl5mUOubpEzAAK8yKvi1WJmFecd7OBZOSpfnzFyJC0 xORujSNQBcTN+vyBG34jMgN5WUZ7OLe/+4shEuAUHGpa6o5q6pwbd/LTG51nn4ebbzwy RRCutpEIwaz0sOZF/aweXu8MSOPqxce0I2RPQAuH/25/GDDSFHhq7JKZ5nNP+5SMCNLz oz922LLJ5Nlp/Z/0obPUD313KfSrHQq+xjVcnGg73m/2e7ao1LJr9sC/3TFZfSp1hwlp YRaoj39Kzi781vIZKc+Y+Y/67OAWpXSY7p501b5M+DKzWNolZ3n9ja9WZU8T31KxvBE6 TEbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707632987; x=1708237787; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=QJZ8r1XqWThzRkF/2DRghmX/j7iNrSZFfXxvfMTOzJ0=; b=SAsjLN7Mqf7K4TB0DjW5AUuxlOKxowid5480bubFf6qQkfRz1x+eFntmBKnSoB4v9V XL2tr8Vlu7IXGVV4YtaBtM1BG+TAIBBPhnwSeMrumzPeUcd07mpieGze5qLzibKGG6a+ kpBRiTEkVQxeKDY1+GlbjRsqI4CQKeZgGR6XjiZPIT0bMjQ1lr9yb1jJOA4Ju4/ev5aN xAxQ4NwRjeDrWNOP8KWjKzC6H3c1PSH6Be2W/32FXb+hHfjvUf5b8AG2HVzGlbEQbloc wEziS67V7LUMOurr05QLWalkfMLrb5Glcho4FMi0Rd1sxuulrkI5ZFzqcKOpcHHv/tPy ks4w== X-Gm-Message-State: AOJu0Yxj1FO79lTNBVrld9lkkRM2/36WyteWD8kdFBDsjDwKY8g3KHRZ 6VwLEgpXdsvm1SVXKFp1OPMNCUwQDgT3zeuuxBmiSEmRDn35iNZZLaJgYAvF/9M= X-Google-Smtp-Source: AGHT+IEulI9zb9HTcNANa81ff3DACagFcst8JhH3A2+lb4CgL7MDwJ41bT3I9lwGH5TOIlvz/vbBOA== X-Received: by 2002:a05:6512:3d10:b0:511:84ae:9f36 with SMTP id d16-20020a0565123d1000b0051184ae9f36mr1577043lfv.5.1707632986441; Sat, 10 Feb 2024 22:29:46 -0800 (PST) Received: from localhost.localdomain ([2a00:1370:817a:d2b8:efcf:5129:674b:51b6]) by smtp.gmail.com with ESMTPSA id j17-20020ac253b1000000b00511696f0d95sm426007lfh.203.2024.02.10.22.29.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 22:29:46 -0800 (PST) From: Dmitry Chestnykh To: devel@uclibc-ng.org Date: Sun, 11 Feb 2024 09:29:54 +0300 Message-ID: <20240211062954.6200-1-dm.chestnykh@gmail.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Message-ID-Hash: HT4UL2JIZMCR7HKN6FJBKS5ZDRRFYDLY X-Message-ID-Hash: HT4UL2JIZMCR7HKN6FJBKS5ZDRRFYDLY X-MailFrom: dm.chestnykh@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Dmitry Chestnykh X-Mailman-Version: 3.3.3 Precedence: list Subject: [uclibc-ng-devel] [PATCH] Add extra `-shared` to link.so command. List-Id: uClibc-ng Development Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: While compiling OpenADK I discovered that there may be a case where UCLIBC_EXTRA_LDFLAGS contains `-fpie -pie`. Linker ignores `-shared` if `-pie` flag is passed after and produces an executable binary instead of shared object. This leads to linking failure because `ld-uClibc.so.1` becomes executable instead of shared object. `ld-uClibc.so.1` is used as one of the inputs when linking of libc.so.1 and linking proccess fails. To prevent this issue we need to pass extra `-shared` flag in `link.so` target command after all other flags to overwrite `-pie` effect. Signed-off-by: Dmitry Chestnykh --- Makerules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makerules b/Makerules index 1a7443c39..fe8a7916e 100644 --- a/Makerules +++ b/Makerules @@ -334,7 +334,7 @@ define link.so -Wl,-soname=$(notdir $@).$(2) \ $(CFLAG_-nostdlib) $(CFLAG_-nostartfiles) \ -o $(dir $@)$(1) $(START_FILE-$(notdir $@)) \ - -Wl,--whole-archive $(firstword $^) -Wl,--no-whole-archive \ + -Wl,--whole-archive $(firstword $^) -Wl,--no-whole-archive -shared \ $(LIBS-$(notdir $@)) $(LIBGCC) $(END_FILE-$(notdir $@)) $(Q)$(LN) -sf $(1) $@.$(2) $(Q)$(LN) -sf $(1) $@