From patchwork Sun Aug 20 22:30:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Sebor X-Patchwork-Id: 22250 Received: (qmail 76814 invoked by alias); 20 Aug 2017 22:30:36 -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 76780 invoked by uid 89); 20 Aug 2017 22:30:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.9 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, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:1348 X-HELO: mail-qk0-f195.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:message-id:date:user-agent :mime-version:content-transfer-encoding; bh=kOH+NfH6MW8e9AMsSPgBpuFz5elY+O3sUROFvHiEUsw=; b=sqhWIPLxUqnhms9U2l2z3Z0RF4MkE/TW8qx4wM91AqJg11lsYeZLJixau9OffmTGnJ ey0/pfh6uKDeTm3hCpwcs3SCWLpYFCOuKQm8768k1jLVphceWRbQdqIr2hsBdE+/JZrF qW5X8PLfDvwVoYNkqhTyI7SzyTgE32LK7Hbr6HPvx8NKzQELc6x8p19OjFYPWwDjtuvo j3y0px32xX/8Y+Gy9DLhShADos9j7oPXMCf9wZdGsNt+KtFbZMB0K+ZzJd4BopzTRtbj KaHydCzp4kjpCzjnnJV9JbDNwZ+UDFSfgBbeh6Ec7rUrV2We1kSpEoFAGbwyt5CSWMfm zRuQ== X-Gm-Message-State: AHYfb5j5X4SClVxJsGhYp6QH662k6+nRmFRqNgzywsZ4oJJdV6iXckUB 6XBmCvfV1dsfeVzp X-Received: by 10.55.162.79 with SMTP id l76mr5673162qke.165.1503268229973; Sun, 20 Aug 2017 15:30:29 -0700 (PDT) From: Martin Sebor Subject: [PATCH] have ifunc resolver's return type match target To: GNU C Library Message-ID: Date: Sun, 20 Aug 2017 16:30:28 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 The following GCC patch has been submitted for review. It helps detect mismatches between the type of an ifunc or alias declaration and the type of the resolver or alias. https://gcc.gnu.org/ml/gcc-patches/2017-08/msg01103.html To let Glibc take advantage of this type checking and avoid warnings when using the patched GCC when the change above is committed, the patch below adjusts the Glibc __ifunc_resolver macro to declare the ifunc resolver so that its return type matches that of the target. (I was going to wait to submit it until after the GCC patch has been accepted but per Joseph's suggestion I'm posting it here ahead of time.) The patch has been tested on its own with the system GCC 6.3 and with the patched GCC on x86_64-linux with no regressions. Martin __typeof (type_name) *res = expr; \ diff --git a/include/libc-symbols.h b/include/libc-symbols.h index fe3ab81..5413e56 100644 --- a/include/libc-symbols.h +++ b/include/libc-symbols.h @@ -790,7 +790,8 @@ for linking") /* Helper / base macros for indirect function symbols. */ #define __ifunc_resolver(type_name, name, expr, arg, init, classifier) \ - classifier inhibit_stack_protector void *name##_ifunc (arg) \ + classifier inhibit_stack_protector \ + __typeof (type_name) *name##_ifunc (arg) \ { \ init (); \