From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-xd41.google.com (mail-io1-xd41.google.com [IPv6:2607:f8b0:4864:20::d41]) by sourceware.org (Postfix) with ESMTPS id 1E3BD3850415 for ; Fri, 18 Sep 2020 14:19:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 1E3BD3850415 Received: by mail-io1-xd41.google.com with SMTP id d190so6989584iof.3 for ; Fri, 18 Sep 2020 07:19:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=vDoIyJF0oM4t2WFTLWQFyRnDRDD5UWoI9r9YjIbuhlw=; b=SNNDVM9IxzA81JgOqu8fay9rqpNikKC+ctIUQdDDtHhwPbDmUS6FvCVeI96si+i/K0 s9zQkgTVLZqOT2VFuo340Yrv6Bo4/7P6AR6c5xklAt7cqfPGHN9WUpC4Bok59gV1Pe0C gktUtmGpbmPa1CS7hnu8vRG+e3fiPDw2fXrSv9XwTP2FmrSVsxtuHEqGuQc0m7NxtyWP 8/Rv32NP/AHuiyXMjVxSIthwq6Cwg1zhLa51C2yrbZ2vDNgS9cVLlHssffPJHsEifJCo GRD48YPtvi7/4cUMxZmp9znmirKbntx+jCN5/rL72tWEbcx6llEI3uYWJcOWK+f5+wnf WWSg== X-Gm-Message-State: AOAM530+SeElyXXrHe+CAgt8lJt5LboBuLxAJv2i85AmTH4tEPhWIwzX OsRJta7mx7BFS+WCKfEzQZDKn+EFaKFEWh/pSQU= X-Google-Smtp-Source: ABdhPJyMW3Uf+hJxYqadTVnAeyTOuglpp7q+yZTIdKU5iBIHY970hoBGyBne1j33hiOGSo7Y58/80QPi7J7LanfM7uI= X-Received: by 2002:a5e:881a:: with SMTP id l26mr26761660ioj.51.1600438768592; Fri, 18 Sep 2020 07:19:28 -0700 (PDT) MIME-Version: 1.0 References: <20200912134441.2407884-1-hjl.tools@gmail.com> <20200912134441.2407884-2-hjl.tools@gmail.com> <874knva4r6.fsf@oldenburg2.str.redhat.com> <87a6xn6v8u.fsf@oldenburg2.str.redhat.com> In-Reply-To: <87a6xn6v8u.fsf@oldenburg2.str.redhat.com> From: "H.J. Lu" Date: Fri, 18 Sep 2020 07:18:52 -0700 Message-ID: Subject: Re: [PATCH 1/3] x86: Initialize CPU info via IFUNC relocation [BZ 26203] To: Florian Weimer Cc: "H.J. Lu via Libc-alpha" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3.2 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.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2020 14:19:30 -0000 On Fri, Sep 18, 2020 at 6:59 AM Florian Weimer wrote: > > * H. J. Lu: > > > On Fri, Sep 18, 2020 at 1:06 AM Florian Weimer wrote: > >> > >> * H. J. Lu via Libc-alpha: > >> > >> > X86 CPU features in ld.so are initialized by init_cpu_features, which is > >> > invoked by DL_PLATFORM_INIT from _dl_sysdep_start. But when ld.so is > >> > loaded by static executable, DL_PLATFORM_INIT is never called. > >> > >> I don't think that's accurate. It's called from elf/dl-support.c in the > >> static case. But I agree that it's too late in this case. > > > > I was referring to the ld.so case. elf/dl-support.c isn't used for ld.so. > > I missed that. > > You cannot use ld.so in a static executable because it is > uninitialized/dormant. > > If you need functionality after static dlopen, it has to reside in > libc.so.6, not the dynamic loader. Here is the problem. static dlopen uses libc.so.6 which brings in ld.so with _rtld_global and _rtld_global_ro via DT_NEEDED. My patch is trying to deal with it to initialize CPU info in _rtld_global_ro in this case. -- H.J.