From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-il1-x144.google.com (mail-il1-x144.google.com [IPv6:2607:f8b0:4864:20::144]) by sourceware.org (Postfix) with ESMTPS id 43FB4386F03B for ; Fri, 18 Sep 2020 14:30:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 43FB4386F03B Received: by mail-il1-x144.google.com with SMTP id a19so6397879ilq.10 for ; Fri, 18 Sep 2020 07:30:53 -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=bEbMUdcTKGgj1tTjzVSwVPie0KGXJzNyMPVIBFoeVqI=; b=bf076l0CYbgk4bniCVv00U6pNIOMGEO/Go0s22tMk29FnA2DnXksScoVC4qkP1oGn+ sDZiqn88oYfjVKJOhIwf1ko4203L1n/4gxLOVUxloYPCla3+tm82x9EHMDBsVE5gMNj6 XUds0Lnpuy7Xg/Q3yKF+45KYfhkbeyLhDwXwdIaH2ieZ1DYb8FJ4b9C/l1+lWWKUMgsz XFZDG3rz9l99c4TL6vgdVqVpS+X0Ekt/IyP8W9uO70RmAL8LH+x3ZINv6XCskCjqIbuS NxhsXjwY4GcXPerPyxLby3nncwNlOehcJbfgGGTiy3MjOzwRVOe4kC5+5pCm4IJNt5D3 kkBQ== X-Gm-Message-State: AOAM532JtbD0KeUVAe9yldYVaaQ/abtT4F2FNdQsYcHPAppEEYtwH87Q aqiCNRrLsST8saM6oYWdWDo45Nlyy8rRuXeF7Gs= X-Google-Smtp-Source: ABdhPJxplNy/2YJUi8Hjce7+XPuH3t5DJEs4n51RrX/8Jnf+6g1LlnxYnRUOyDVIYNQqYeLUzo11s4FxBIEB4WriKx0= X-Received: by 2002:a92:c9c4:: with SMTP id k4mr6684627ilq.292.1600439452720; Fri, 18 Sep 2020 07:30:52 -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> <87y2l75fls.fsf@oldenburg2.str.redhat.com> In-Reply-To: <87y2l75fls.fsf@oldenburg2.str.redhat.com> From: "H.J. Lu" Date: Fri, 18 Sep 2020 07:30:16 -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=-2.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, URIBL_BLACK autolearn=no 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:30:54 -0000 On Fri, Sep 18, 2020 at 7:23 AM Florian Weimer wrote: > > * H. J. Lu: > > > 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. > > Putting this data into _rtld_global_ro is not correct if it is required > after static dlopen. The current static dlopen approach simply does not > support that. You can only assume that libc.so has been initialized > after static dlopen. > Unless it is removed, _rtld_global_ro is the right place. _rtld_global_ro is initialized by dynamic relocation. My patch does it. -- H.J.