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=-4.0 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham 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 2EAF61F4B5 for ; Tue, 12 Nov 2019 09:47:22 +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:from:to:cc:subject:references:date:in-reply-to :message-id:mime-version:content-type:content-transfer-encoding; q=dns; s=default; b=Pkf84vTUa/234BBMGcv68FrPj+ByPB4nWHjQm0E35ST zsk3Q6rSg24w4G3UisBiwsRUmGfT9N20LkPEmffUAP01JlvjMmnHt71oSbQMpcHF O2QLdevftIb6w5y86fFB5iEPDwjf68C39nl6Yk3sBi7LCFg3BAac/HIl3UPs+SRs = 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:from:to:cc:subject:references:date:in-reply-to :message-id:mime-version:content-type:content-transfer-encoding; s=default; bh=9hoS+uTp1YrBOa9C93TllVSb+1A=; b=QYRr34KNdWS7bRZU3 17iB/EyaGBKw45CY5rTwuf7R2tkh4G2HlJkNowIXQWm0ovBHu++Zt8n5HmkbRoxC Sn9HlxMsSA8IqVzBZgzJBsyQ734HM6u8OjRBGsoxstEG7u4zfcx9cM9U5vh45gVM PGEyzQO47jfefuJBvJ/1OXMY5k= Received: (qmail 65171 invoked by alias); 12 Nov 2019 09:47:19 -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 65157 invoked by uid 89); 12 Nov 2019 09:47:19 -0000 Authentication-Results: sourceware.org; auth=none X-HELO: us-smtp-delivery-1.mimecast.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573552036; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eDJGKqPr4UdvOeF8a/XiYLRWgsVzaKaHfR19gn2APJ0=; b=CtH2h7276xenSpna2sIECYNLA85P0jBQ7SWV1xvh7PgCMasNAZ4E1HCHtBR5GYShlNtM9P 5K60Ayy0oE18YnKRcTZbdIJ0One+X7P5iMeWR3mYSPIio5tHKRazh9MTOQJGt79BhU/M/N tJ97JWvVakNQHZQx6ebpCVzbJy3yVjY= From: Florian Weimer To: Alistair Francis Cc: GNU C Library Subject: Re: Generate VDSO_HASH References: Date: Tue, 12 Nov 2019 10:47:12 +0100 In-Reply-To: (Alistair Francis's message of "Mon, 11 Nov 2019 15:57:03 -0800") Message-ID: <87v9rpqvdr.fsf@oldenburg2.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable * 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, 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=091 /* 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 =3D (const unsigned char *) name_arg; unsigned long int hash =3D *name; if (hash !=3D 0 && name[1] !=3D '\0') { hash =3D (hash << 4) + name[1]; if (name[2] !=3D '\0') =09{ =09 hash =3D (hash << 4) + name[2]; =09 if (name[3] !=3D '\0') =09 { =09 hash =3D (hash << 4) + name[3]; =09 if (name[4] !=3D '\0') =09=09{ =09=09 hash =3D (hash << 4) + name[4]; =09=09 name +=3D 5; =09=09 while (*name !=3D '\0') =09=09 { =09=09 unsigned long int hi; =09=09 hash =3D (hash << 4) + *name++; =09=09 hi =3D hash & 0xf0000000; =09=09 /* The algorithm specified in the ELF ABI is as =09=09=09 follows: =09=09=09 if (hi !=3D 0) =09=09=09 hash ^=3D hi >> 24; =09=09=09 hash &=3D ~hi; =09=09=09 But the following is equivalent and a lot =09=09=09 faster, especially on modern processors. */ =09=09 hash ^=3D hi >> 24; =09=09 } =09=09 /* Second part of the modified formula. This =09=09 operation can be lifted outside the loop. */ =09=09 hash &=3D 0x0fffffff; =09=09} =09 } =09} } return hash; } #endif /* dl-hash.h */