From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi1-x229.google.com (mail-oi1-x229.google.com [IPv6:2607:f8b0:4864:20::229]) by sourceware.org (Postfix) with ESMTPS id 6D4D6385802A for ; Sat, 16 Jan 2021 13:18:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 6D4D6385802A Received: by mail-oi1-x229.google.com with SMTP id f132so12615954oib.12 for ; Sat, 16 Jan 2021 05:18:58 -0800 (PST) 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=aX7/kpV6jBmR9wJmt2Jzis4BlSrRIec3N7/Wq/78Sq8=; b=cyzNEutzDYgCEXIcNUQaPL7OlNEsYvAwc6ktf9mx/SZGn5l2V2mD2kap+RnQgp/dE7 tsmRMcx93Y2Y74Gwk1FNb1vYLilDfZFsQ+o2xUqY4eC757W+pmtZlHnSH8UCmtXsRWnw 4rAn0xhi7aC3ua94du0ruL9FoUjbIQ3xbUcOavsWTUgP2sMn1glPaW6/drLu4R5ZoEJs TBQ6tKjQ2Pvhb5GGlv7JlDXCMXEEOXdqdLyQPd9Vapmft39CvLrYACfMTacak7DdIhbp c26hnYRe6pNAMS2mikXHu+TfY2eLZwSfJpirkhUkELsdEIBQBXlQHvyG7bJyMdDkYTc0 TeIA== X-Gm-Message-State: AOAM531MT8678QwKhQTw0l79vFrFS2VCp0EZVMMCxJ2zdJHHeX7fSIwh 3Xgo5gqZfBQgJQXq47ncDWj5Y6KLwxxWRxZk6oo= X-Google-Smtp-Source: ABdhPJyFRyKg8ZDbrsnu1gXh8/44XkE77SQjewhNxxsNE8M9jyqZ1UUhjwQ/Go6COf66rs1w5kCU1v7QinQxvtn8BCw= X-Received: by 2002:aca:f456:: with SMTP id s83mr8420467oih.58.1610803137836; Sat, 16 Jan 2021 05:18:57 -0800 (PST) MIME-Version: 1.0 References: <27498bbc768372541e4379794656ac2778d33035.1610471272.git.szabolcs.nagy@arm.com> <20210113095053.GA2379@arm.com> <20210114111757.GA11466@arm.com> <20210115112524.GE11466@arm.com> <20210115142737.GF11466@arm.com> In-Reply-To: From: "H.J. Lu" Date: Sat, 16 Jan 2021 05:18:21 -0800 Message-ID: Subject: Re: [PATCH v3 2/5] Make libc symbols hidden in static PIE To: Szabolcs Nagy Cc: GNU C Library Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3030.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, KAM_SHORT, 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: Sat, 16 Jan 2021 13:18:59 -0000 On Fri, Jan 15, 2021 at 4:41 PM H.J. Lu wrote: > > On Fri, Jan 15, 2021 at 2:42 PM H.J. Lu wrote: > > > > On Fri, Jan 15, 2021 at 7:28 AM H.J. Lu wrote: > > > > > > On Fri, Jan 15, 2021 at 6:27 AM Szabolcs Nagy wrote: > > > > > > > > The 01/15/2021 05:43, H.J. Lu wrote: > > > > > On Fri, Jan 15, 2021 at 3:25 AM Szabolcs Nagy wrote: > > > > > > options: > > > > > > > > > > > > (1) fix extern hidden pie calls on i686 (by making > > > > > > them the same as default vis pie calls so ifuncs > > > > > > work). > > > > > > > > > > > > (2) annotate ifuncs (avoid hidden for them, ifuncs > > > > > > cannot appear in early start code anyway because > > > > > > of IRELATIVE): this can be difficult to maintain. > > > > > > > > > > > > (3) annotate early object accesses to be hidden so > > > > > > RELATIVE relocs are avoided. (most targets want > > > > > > all objects to be hidden, but this solves bug > > > > > > 27072 without causing problems on i686) > > > > > > > > > > > > (4) make pie always use copy relocations on i686. > > > > > > (and then no hidden annotation is needed, object > > > > > > access is always local in pie). > > > > ... > > > > > > > --- a/elf/dl-reloc-static-pie.c > > > > > > > +++ b/elf/dl-reloc-static-pie.c > > > > > > > @@ -17,6 +17,7 @@ > > > > > > > . */ > > > > > > > > > > > > > > #if ENABLE_STATIC_PIE > > > > > > > +#pragma GCC visibility push(hidden) > > > > > > > > > > > > yes, this is option (3). you will also need it in _dl_aux_init > > > > > > and __libc_init_secure and __tunables_init. > > > > > > > > > > I will try it. > > > > > > > > the naive way does not seem to work: > > > > > > > > _dl_support.c has _dl_aux_init as well as _dl_non_dynamic_init, > > > > the former needs hidden the latter does not and calls rawmemchr > > > > which is ifunc on i686. > > > > > > > > i think the easiest fix is to move those two functions into > > > > separate files. (ideally we would have a small set of files > > > > that are involved in the start code before self relocation) > > > > > > > > now i realized that there is another option: > > > > > > > > (5) remove all ifuncs from i686 libc. > > > > > > > > i assume there are not many users who care about i686 performance. > > > > > > I don't know if this will work on i686. Since i386 doesn't have IP relative > > > addressing, we can't remove all RELATIVE relocations. We need to > > > call _dl_aux_init again after relocating PIE. I don't know what other symbols > > > are affected. My current patches are on users/hjl/pr27072/master branch: > > > > > > https://gitlab.com/x86-glibc/glibc/-/commits/users/hjl/pr27072/master > > > > > > > The problem is > > > > #ifdef NEED_DL_SYSINFO > > /* Needed for improved syscall handling on at least x86/Linux. */ > > uintptr_t _dl_sysinfo = DL_SYSINFO_DEFAULT; > > #endif > > > > We can initialize it in _dl_aux_init instead. > > > > I am testing this set of patches on top of yours on i686 and x86-64. > > > > They worked and they passed build-many-glibcs.py. > I combined my patches, including 4 testcases, with yours in the right order here: https://gitlab.com/x86-glibc/glibc/-/commits/users/hjl/pr27072/master -- H.J.