From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by sourceware.org (Postfix) with ESMTPS id 70DDD38582BE for ; Wed, 24 Aug 2022 00:16:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 70DDD38582BE Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-x635.google.com with SMTP id io24so953459plb.1 for ; Tue, 23 Aug 2022 17:16:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc; bh=7bYaBlvGSS8M8k00FxzlFkx3tQMqyjNohY2lsZ4garY=; b=ei6TtQ8tGXIDUJ4hlb5Qy4Fb/jWUTU36VWATOjrU7eJrsbnUmFi+aMsKcbg50k2y8T 1PAAEa3JhXTUAmkt1Ygr/DKe7o/baXoajoV6t7yr7LHAEL6cUcDiIgGifEhhaPdlkEYW DjhRJ+/bTCJC35EXHkZJm6LIxKOihRgvsbkUY1AyI7+1jIaGFj4mKftOspLERvPAQBA9 UKBPY3D3JQBtaflZ5QequAYd3RgU2r9aMpAY7Kd70xCOhC08EdrLDuxM5cC0At/utwXo 3BzYnelxpy8JX7Ol7taMTQCTCfruylAbGkWDa/61INAqLpEBzKtQ2asdJ/1oSNP9YbHQ cPkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc; bh=7bYaBlvGSS8M8k00FxzlFkx3tQMqyjNohY2lsZ4garY=; b=OL+QIwpMJc2e1vP/EcWoMWK7Y8rPbhNvSBT0qZuktHt2fhKtZ9j1tZAfB6WT/u+KDa Jdq9Gjl/BK7wCVQnGBvFCcJzm8RRwfyrqJeb0/CYL25T1+MO/qcKcvbldQzp10FjMlGu aX67X/DKDHrvJTxA6ePbYxSZFznmyzLTEXqvt6zeEH5PyDf+UFpzavygQRG9GLTVPoeL RDZYoLknOIOSkb5rWsTzQRFg0BOuYiGgs6FX9X9iO3kmTks0Opk5SIlP+IK0Igy4vyzA VOZ0+GxRwg58y56+QvlVCYKQrdEh1dqBnRPfUOLNTOr8tQYMPR92KOQNBk+eFJBbnlqt LN5g== X-Gm-Message-State: ACgBeo09+23mduhICktK1z85aZB2SsMnlvEJ4gOJiZxSIMjxzA3eL3bX 0AOzmQWl/aYYZOx2rWlzq5Oj/OAUAuE= X-Google-Smtp-Source: AA6agR5msQUAOLeBC2PclOtMoDRof9YkIBeCCZCVPPNByNvM8pkXTMrRIfN9RsIEW4jRNJw7HaCysQ== X-Received: by 2002:a17:902:a982:b0:170:d646:5851 with SMTP id bh2-20020a170902a98200b00170d6465851mr27283801plb.134.1661300195456; Tue, 23 Aug 2022 17:16:35 -0700 (PDT) Received: from squeak.grove.modra.org ([2406:3400:51d:8cc0:bb55:31be:89dd:d0dc]) by smtp.gmail.com with ESMTPSA id z17-20020aa79591000000b0052aaff953aesm11490446pfj.115.2022.08.23.17.16.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Aug 2022 17:16:35 -0700 (PDT) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id 7133511409D3; Wed, 24 Aug 2022 09:46:32 +0930 (ACST) Date: Wed, 24 Aug 2022 09:46:32 +0930 From: Alan Modra To: "H.J. Lu" Cc: binutils@sourceware.org Subject: Re: [PATCH] x86: Ignore protected visibility in shared libraries on Solaris Message-ID: References: <20220823173432.36035-1-hjl.tools@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220823173432.36035-1-hjl.tools@gmail.com> X-Spam-Status: No, score=-3034.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,KAM_STOCKGEN,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE,URIBL_BLACK 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 Tue, Aug 23, 2022 at 10:34:32AM -0700, H.J. Lu via Binutils wrote: > On x86, the PLT entry in executable may be used as function address for > functions in shared libraries. If functions are protected, the function > address used in executable can be different from the function address > used in shared library. This will lead to incorrect run-time behavior > if function pointer equality is needed. By default, x86 linker issues > an error in this case. > > On Solaris, linker issued an error for > > struct tm *tb = (kind == CPP_time_kind::FIXED ? gmtime : localtime) (&tt); > > where gmtime is a protected function in libc.so. Use gmtime's PLT entry > in executable as function address is safe since function pointer equality > isn't needed. I'm curious as to how pointer_equality_needed came to be set for gmtime. > Ignore protected visibility in shared libraries on Solaris > to disable linker error. If function pointer equality is needed, linker > will silently generate executable with incorrect run-time behavior on > Solaris. > > PR ld/29512 > * elf32-i386.c (elf_i386_scan_relocs): Ignore protected > visibility in shared libraries on Solaris. > * elf64-x86-64.c (elf_x86_64_scan_relocs): Likewise. > --- > bfd/elf32-i386.c | 3 ++- > bfd/elf64-x86-64.c | 3 ++- > 2 files changed, 4 insertions(+), 2 deletions(-) > > diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c > index 52b1db44546..9717e2c5ed6 100644 > --- a/bfd/elf32-i386.c > +++ b/bfd/elf32-i386.c > @@ -1808,7 +1808,8 @@ elf_i386_scan_relocs (bfd *abfd, > || (sec->flags & (SEC_CODE | SEC_READONLY)) != 0) > h->plt.refcount = 1; > > - if (h->pointer_equality_needed > + if (htab->elf.target_os != is_solaris > + && h->pointer_equality_needed > && h->type == STT_FUNC > && eh->def_protected > && !SYMBOL_DEFINED_NON_SHARED_P (h) > diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c > index 62a9a22317a..f3b54400013 100644 > --- a/bfd/elf64-x86-64.c > +++ b/bfd/elf64-x86-64.c > @@ -2251,7 +2251,8 @@ elf_x86_64_scan_relocs (bfd *abfd, struct bfd_link_info *info, > || (sec->flags & (SEC_CODE | SEC_READONLY)) != 0) > h->plt.refcount = 1; > > - if (h->pointer_equality_needed > + if (htab->elf.target_os != is_solaris > + && h->pointer_equality_needed > && h->type == STT_FUNC > && eh->def_protected > && !SYMBOL_DEFINED_NON_SHARED_P (h) > -- > 2.37.2 -- Alan Modra Australia Development Lab, IBM