From patchwork Mon Feb 5 12:28:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 869253 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-89962-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="jDQn36QU"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zZn1c1WRxz9s1h for ; Mon, 5 Feb 2018 23:28:19 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:mime-version :content-type; q=dns; s=default; b=uXu5GCRnQ4sYv6OGkj9yI6ObtGaWg klShtiGttOmK7CvItlei3xhl299+Fm9BJBnUHqWdIiAgjdoLoMSmGaYFsnfK/E0M TTZo8w2DgmjAgbxhK7z9hvkiPGpHZ7Y2qhknhtVLREpy/E3lz/lelLo8KwWUFpCS YSIV7EMdEpf2c4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:mime-version :content-type; s=default; bh=uf4Ty1b4zmEScpW1wGAXL/mOsjI=; b=jDQ n36QUZtPbm/ESlvc8OAzflbLRkLaI1spfbWnK9elueAkteRJv5xf+xs1p6f1SG5F 0kf9sxD9NP54HzW20iEVazyXs1KojMgwybbH53UrBgRe1nECI9SfJCllTAD9VNvK JJVeeqczj/iyiBy1NYPsgj657FzjCS7gOI7iXEwA= Received: (qmail 6225 invoked by alias); 5 Feb 2018 12:28:14 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 6213 invoked by uid 89); 5 Feb 2018 12:28:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.8 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=shortly X-HELO: mail-pg0-f45.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition:user-agent; bh=26h2xc8DfScSZcjowP04ii3OP4qqORUqMBDYBhqs/oM=; b=ssDYgkKsN4CoOxjw4EhqR2R7v2PB7GJmGfwHjqqzaJP9BMA4peLjOt4eGY2B736zD+ WvjYY2BsgqYrhSAmzRClPSd5ozx+NYMynk6KuH2VghnPD5aNHfNlh9WmJJRRNW+RDfiv jhDlD79QMz7LEGcMHdqnH6zShhuN9fu0lT5ufOH/cxhVPzL7v0UTchoXh6O9L5dGZ9Ph hC1u/687MYrRgAEY8CYWkU04kREKR/roKVBQ8B/R7J+EO9aNkeG0t3MswFh/10R6HzYg 2o84M0fA/vvE56blb+hCdzXpBef80QbnGS4VzPK2oze9880e1+c7kuB97AFrTUV0zVXl v/Qg== X-Gm-Message-State: APf1xPA88InT9Umr4WTGPDw/fdlYKf4x1bHw0Zv0XOuZ5J8VqfXAs850 uwwJLBzvfY4GyPjsJXbZu6ykhQ== X-Google-Smtp-Source: AH8x2262zrFAc4i7PC14JreuPjl0wj7ZaICCtj/BVcp1nF5o1Y99yaAYODFUJgQNIxVAazcb5sAVdg== X-Received: by 10.98.249.9 with SMTP id o9mr1546252pfh.213.1517833689288; Mon, 05 Feb 2018 04:28:09 -0800 (PST) Date: Mon, 5 Feb 2018 04:28:07 -0800 From: "H.J. Lu" To: GNU C Library Subject: [PATCH] i386: Use __glibc_likely/__glibc_likely in dl-machine.h Message-ID: <20180205122807.GA12157@gmail.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.1 (2017-09-22) The differences in elf/dl-reloc.os are --- before 2018-02-05 03:53:31.970492246 -0800 +++ after 2018-02-05 03:53:49.719902340 -0800 @@ -1202,9 +1202,9 @@ _dl_relocate_object: movl -60(%ebp), %eax testl %eax, %eax je .L249 - movl 8(%eax), %eax - movl 8(%ebx), %esi - cmpl %esi, %eax + movl 8(%eax), %esi + movl 8(%ebx), %eax + cmpl %eax, %esi ja .L284 jb .L707 .L285: @@ -2255,7 +2255,7 @@ _dl_relocate_object: cmpl $6, %edi movl $4, %edx je .L132 - cmpl %ecx, %eax + cmpl %eax, %ecx je .L350 cmpl $7, %edi je .L419 @@ -2735,7 +2735,7 @@ _dl_relocate_object: je .L120 .L121: movl -96(%ebp), %edx - movl $640, 8(%esp) + movl $639, 8(%esp) leal __PRETTY_FUNCTION__.9431@GOTOFF(%edx), %eax movl %eax, 12(%esp) leal .LC9@GOTOFF(%edx), %eax @@ -3454,10 +3454,10 @@ _dl_relocate_object: movl -152(%ebp), %eax movl %eax, 4(%esp) call _dl_dprintf - movl -60(%ebp), %eax - movl 8(%ebx), %esi + movl 8(%ebx), %eax + movl -60(%ebp), %ebx movl -112(%ebp), %edx - movl 8(%eax), %eax + movl 8(%ebx), %esi jmp .L285 .L713: movl %esi, (%esp) I will check it in shortly. H.J. --- * sysdeps/i386/dl-machine.h (elf_machine_rel): Replace __builtin_expect with __glibc_likely and __glibc_likely. (elf_machine_rela): Likewise. (elf_machine_lazy_rel): Likewise. --- sysdeps/i386/dl-machine.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/sysdeps/i386/dl-machine.h b/sysdeps/i386/dl-machine.h index 5171499e33..eb8a6619e9 100644 --- a/sysdeps/i386/dl-machine.h +++ b/sysdeps/i386/dl-machine.h @@ -323,10 +323,9 @@ elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc, Elf32_Addr value = sym_map == NULL ? 0 : sym_map->l_addr + sym->st_value; if (sym != NULL - && __builtin_expect (ELFW(ST_TYPE) (sym->st_info) == STT_GNU_IFUNC, - 0) - && __builtin_expect (sym->st_shndx != SHN_UNDEF, 1) - && __builtin_expect (!skip_ifunc, 1)) + && __glibc_unlikely (ELFW(ST_TYPE) (sym->st_info) == STT_GNU_IFUNC) + && __glibc_likely (sym->st_shndx != SHN_UNDEF) + && __glibc_likely (!skip_ifunc)) { # ifndef RTLD_BOOTSTRAP if (sym_map != map @@ -456,8 +455,8 @@ elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc, /* This can happen in trace mode if an object could not be found. */ break; - if (__builtin_expect (sym->st_size > refsym->st_size, 0) - || (__builtin_expect (sym->st_size < refsym->st_size, 0) + if (__glibc_unlikely (sym->st_size > refsym->st_size) + || (__glibc_unlikely(sym->st_size < refsym->st_size) && GLRO(dl_verbose))) { const char *strtab; @@ -504,9 +503,9 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc, Elf32_Addr value = sym == NULL ? 0 : sym_map->l_addr + sym->st_value; if (sym != NULL - && __builtin_expect (sym->st_shndx != SHN_UNDEF, 1) - && __builtin_expect (ELFW(ST_TYPE) (sym->st_info) == STT_GNU_IFUNC, 0) - && __builtin_expect (!skip_ifunc, 1)) + && __glibc_likely (sym->st_shndx != SHN_UNDEF) + && __glibc_unlikely (ELFW(ST_TYPE) (sym->st_info) == STT_GNU_IFUNC) + && __glibc_likely (!skip_ifunc)) value = ((Elf32_Addr (*) (void)) value) (); switch (ELF32_R_TYPE (reloc->r_info)) @@ -601,8 +600,8 @@ elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc, /* This can happen in trace mode if an object could not be found. */ break; - if (__builtin_expect (sym->st_size > refsym->st_size, 0) - || (__builtin_expect (sym->st_size < refsym->st_size, 0) + if (__glibc_unlikely (sym->st_size > refsym->st_size) + || (__glibc_unlikely (sym->st_size < refsym->st_size) && GLRO(dl_verbose))) { const char *strtab; @@ -663,7 +662,8 @@ elf_machine_lazy_rel (struct link_map *map, /* Check for unexpected PLT reloc type. */ if (__glibc_likely (r_type == R_386_JMP_SLOT)) { - if (__builtin_expect (map->l_mach.plt, 0) == 0) + /* Prelinked has been deprecated. */ + if (__glibc_likely (map->l_mach.plt == 0)) *reloc_addr += l_addr; else *reloc_addr = (map->l_mach.plt