From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by sourceware.org (Postfix) with ESMTPS id 49C7B3858D34 for ; Sat, 30 Mar 2024 01:43:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 49C7B3858D34 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 49C7B3858D34 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::62e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711763028; cv=none; b=EPp7tzMSZxQhsEwMEb2LVawrPohIYGhQwbrfXWgKflhHymmk06LZ2xOSHVZKB8kb65iTF+NFzzcm5vkkduar9TraBEXJArteC7vMOaD1SXQXn9JwEk/PbXjJFRcWOy1YyMFacjSxcazyqcHySeEytRPSEQNqwOypvD2vBD75lR0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711763028; c=relaxed/simple; bh=LIedc1zOsCOqrt+3ERuFigLOhMxCG790jfIptmrwjhI=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=XN1DL6tid9Jizc2FbpDPhP06fcTLPlYhwzQvMC5wP/0XnLvvqeHEnbC99EeVITTNy58ioiB0I2NpJSy4y4AB2nGKsQ5QG9KcktQlEW0FZpZ1SkK7aMEAu5p3DX+DzJ9SaxhMyRKNyZZ+Da+K3KRe4iMiqzOEhIstbBCub5ebiM4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1dfff641d10so19198885ad.2 for ; Fri, 29 Mar 2024 18:43:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711763025; x=1712367825; darn=sourceware.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=n521dKMh+SzhW71EhMHTyBcAKsh40y7ZdqxEqTMVqbE=; b=UvR6ta1CrQOvchjhbngaL5S/bhSTfNLhhWqwQ7NLX7XHzB+BJ758FZhZPOFZyYh7pH 68a34Sm2GcevaF4bLA/7Dh3fnwcuK1Q6Ih5NhSEDRhRS6yCW+Z0VLqJj1vED4ZZXmZfS eyYQaeszBuq1vEq7jJ7KWsGG5Y33CNzAErmntkMTQG9+Vx7sKLVbhPILZF1QyKNa/V5F R93R3A8Qel8AdXn7A98bB8nAFI9nwsJ/ltVpxHzI+rqla/CQHGSFvWUtfPpkBtO7YF8J 6BPoQe6aABjQ7IfIX/OGoyBWisaGcvstaFbpVIzLDZtfaVbvktpfatdafDVeYEi0k/dQ amkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711763025; x=1712367825; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=n521dKMh+SzhW71EhMHTyBcAKsh40y7ZdqxEqTMVqbE=; b=U9fbjKbqPYSkbC0NufH0x3hn+5sMQEeZJlFPxkNaDSX979UwztWIErahRGuhlBg8OG 9pBbTyHQsZ3vJUJH8X5yyMKf5ts5pdV7Gctun4vIGeGORtOo2YAy7DxLsyHZo+vG8EOp l0Pv+dhH7QjQ1oBqeU5kIWsU4AcdCZuuSAx68JZXyvnfZgltgzOAhJcUt/uPKWyJmTwq MSrUvPAfBfr+1tqey7VwtlzP6tUwE1k0LDKksWJCyiY40AeuKOaM+tj5ibi/hbHAOT2l fhvumyXMNFV6mj4M6D0iyccl8shAlS5r4aFfgtv7tEoBVQCCGi0bei9sV2ZWQfLtWGgL dJTQ== X-Gm-Message-State: AOJu0YwQaVc9QVsD0LXhXs53kaCF2SMISpCTTMZr6hAzMVXXNg0/Gu6e m5ZtLgKMySW42/YrxiDO5u8r3bv2yr9f7kMjAf4sAURn2f+vsUmGRyqnJ4JS X-Google-Smtp-Source: AGHT+IGJ+mrvFpgsTowVgxM50DbL8FoYrWEeDvdtkZ1+42WOS3NJ3iAkAiFdYdt3twglVRVdIGbZOA== X-Received: by 2002:a17:902:e5ce:b0:1e0:cd8a:58c with SMTP id u14-20020a170902e5ce00b001e0cd8a058cmr4694883plf.1.1711763025181; Fri, 29 Mar 2024 18:43:45 -0700 (PDT) Received: from squeak.grove.modra.org ([2406:3400:51d:8cc0:3fea:a7d:d6e0:c900]) by smtp.gmail.com with ESMTPSA id 4-20020a170902e9c400b001dbcfb4766csm4084859plk.226.2024.03.29.18.43.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 18:43:44 -0700 (PDT) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id CCA8611400C5; Sat, 30 Mar 2024 12:13:41 +1030 (ACDT) Date: Sat, 30 Mar 2024 12:13:41 +1030 From: Alan Modra To: Tom Kacvinsky Cc: Binutils Subject: Re: resolving weak symbols. Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-3025.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Thu, Mar 28, 2024 at 06:58:36PM -0400, Tom Kacvinsky wrote: > HI, > > Support I have a static archive libfoo.a that has a weak sym, call it quux. > > And the link line I have is > > gcc -o foo -L. -lfoo -Wl,--as-needed -lbar -lbaz > > Where libbar.so and libbaz.so also have the weak symbol quux. > > Then the executable foo has a dynamic dependency on both libbar.so _and_ > libbaz.so. > > Is this expected behavior? Is there a way of forcing exactly one of > libfoo.so and libbaz.so to be used? Works fine for me on x86_64-linux. You'll notice that I'm not using gcc to link. Perhaps something in the way your gcc is invoking the linker is getting in the way. It pays to check what gcc is doing by adding -v to the gcc command line. It is also worthwhile checking what you think is going on, by creating a little testcase like the following. cat > quux.s < quuxref.s <