From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-2.9 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_GMAIL_RCVD, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=no autolearn_force=no version=3.4.2 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 dcvr.yhbt.net (Postfix) with ESMTPS id A22281F4B5 for ; Tue, 12 Nov 2019 17:40:00 +0000 (UTC) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-type; q=dns; s=default; b=oWLs pH22csButtmK51th93WuNgNeMT5BiqHAnzkI6/QmSD+fA93Xs3ZTzXBuPfhEmnc2 oRI6+1eESBFBpMlauhGro8r+il18CxE9bz7+H5s3cBiDuabOW2y+eEkIQnvKa4u8 gt0h3pVi//dio3elT5APh+SkYssEEiTqWrQQOKE= 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:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-type; s=default; bh=3zvGqtG1XL wOzsppA9EWGT3L1bY=; b=Q9RPSNDVtImbHG1ZOveaLsyN7rocoZLDyM+T2CTGf0 97GKI2JCZWs9ih4qRNKpcQug9HlGVkvRzq1w9htHOOvQL8od8ftp9BZ6BAsHxIa3 0SnY3k9MWpQqY1F3v10XEmM8MnJqnynqKUnHEJdj1Wx3atEv8tW3CHcn9FllHx2C A= Received: (qmail 57262 invoked by alias); 12 Nov 2019 17:39:58 -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 Received: (qmail 57250 invoked by uid 89); 12 Nov 2019 17:39:58 -0000 Authentication-Results: sourceware.org; auth=none X-HELO: mail-lf1-f41.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=8zsiK5xDeRKAh4zawfwy9757Rxca7Vq1KH2miUQpHz8=; b=j7EpTDuEawiwDgzhg6lRcmDLfBElTB0mp26xRJVnkm9aKDdFpTChQ4wUToRjKeBD7a 5+We619oCTfgcsNXBEfnsn/Jv6Scz8LZVEKDWemSs3M6nx+4PqztXIpBOgX4eKAqtC1n Sjqrj1X5kO0VxIcQhluSLvSkzhte0OFsuF5guxRAJDGvTY8ImbledUqtpUBa/x3kVPNv F32ugigWau0jAjd6UzmAAISyoW1bxRmdk0pMMCYrochIUjNN3+n3/wwYSIfSkKO5y+4u Zfs26Sfnask8Uv/x1m6C9JAbAOZzUiBl3QAbG+/uD8i75t5F3WugjpY2V4VZvn6EwRIy 08lg== MIME-Version: 1.0 References: <87v9rpqvdr.fsf@oldenburg2.str.redhat.com> In-Reply-To: <87v9rpqvdr.fsf@oldenburg2.str.redhat.com> From: Alistair Francis Date: Tue, 12 Nov 2019 09:34:05 -0800 Message-ID: Subject: Re: Generate VDSO_HASH To: Florian Weimer Cc: GNU C Library Content-Type: text/plain; charset="UTF-8" On Tue, Nov 12, 2019 at 1:47 AM Florian Weimer wrote: > > * Alistair Francis: > > > How is VDSO_HASH generated? I would like to generate one for the 5.4 > > kernel. > > It's the ELF hash. Not to be confused with the GNU hash, which is used > for symbol name lookup these days. See and > the program below. > > LINUX_5.4: ELF: 61765876 (0x3ae78f4), GNU: 650524491 (0x26c6374b) > > The ELF hash is still used for symbol versions, only the symbol names > switched to the GNU hash. Thanks! Alistair > > Thanks, > Florian > > /* Compute hash value for given string according to ELF standard. > Copyright (C) 1995-2019 Free Software Foundation, Inc. > This file is part of the GNU C Library. > > The GNU C Library is free software; you can redistribute it and/or > modify it under the terms of the GNU Lesser General Public > License as published by the Free Software Foundation; either > version 2.1 of the License, or (at your option) any later version. > > The GNU C Library is distributed in the hope that it will be useful, > but WITHOUT ANY WARRANTY; without even the implied warranty of > MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > Lesser General Public License for more details. > > You should have received a copy of the GNU Lesser General Public > License along with the GNU C Library; if not, see > . */ > > #ifndef _DL_HASH_H > #define _DL_HASH_H 1 > > > /* This is the hashing function specified by the ELF ABI. In the > first five operations no overflow is possible so we optimized it a > bit. */ > static unsigned int > __attribute__ ((unused)) > _dl_elf_hash (const char *name_arg) > { > const unsigned char *name = (const unsigned char *) name_arg; > unsigned long int hash = *name; > if (hash != 0 && name[1] != '\0') > { > hash = (hash << 4) + name[1]; > if (name[2] != '\0') > { > hash = (hash << 4) + name[2]; > if (name[3] != '\0') > { > hash = (hash << 4) + name[3]; > if (name[4] != '\0') > { > hash = (hash << 4) + name[4]; > name += 5; > while (*name != '\0') > { > unsigned long int hi; > hash = (hash << 4) + *name++; > hi = hash & 0xf0000000; > > /* The algorithm specified in the ELF ABI is as > follows: > > if (hi != 0) > hash ^= hi >> 24; > > hash &= ~hi; > > But the following is equivalent and a lot > faster, especially on modern processors. */ > > hash ^= hi >> 24; > } > > /* Second part of the modified formula. This > operation can be lifted outside the loop. */ > hash &= 0x0fffffff; > } > } > } > } > return hash; > } > > #endif /* dl-hash.h */ >