Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934743AbdCVPCU (ORCPT ); Wed, 22 Mar 2017 11:02:20 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:34420 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760621AbdCVPBO (ORCPT ); Wed, 22 Mar 2017 11:01:14 -0400 Subject: Re: [PATCH v2 02/10] x86: assembly, FUNC_START for fn, DATA_START for data To: Josh Poimboeuf , Ingo Molnar References: <9ea5e137-61f9-dccc-bb9d-ac3ff86e5867@suse.cz> <20170320123222.15453-1-jslaby@suse.cz> <20170320123222.15453-2-jslaby@suse.cz> <20170321140840.GA23311@amd> <20170322072557.GA13904@gmail.com> <20170322074616.GA10809@gmail.com> <20170322141123.opss3u4gpupqgl2q@treble> Cc: Pavel Machek , mingo@redhat.com, tglx@linutronix.de, hpa@zytor.com, x86@kernel.org, linux-kernel@vger.kernel.org, Boris Ostrovsky , Juergen Gross , xen-devel@lists.xenproject.org, "Rafael J. Wysocki" , Len Brown , linux-pm@vger.kernel.org From: Jiri Slaby Message-ID: <049e6c03-8d7d-e869-96bd-0a98e6471227@suse.cz> Date: Wed, 22 Mar 2017 16:01:08 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <20170322141123.opss3u4gpupqgl2q@treble> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2351 Lines: 78 On 03/22/2017, 03:11 PM, Josh Poimboeuf wrote: > Or, here's a much easier way to do it, without involving objtool: > > --- a/include/linux/linkage.h > +++ b/include/linux/linkage.h > @@ -138,9 +138,17 @@ > name: > #endif > > +#ifndef CHECK_DUP_SYM_END > +#define CHECK_DUP_SYM_END(name) \ > + .pushsection .discard.sym_func_end ASM_NL \ > + SYM_END_##name: .byte 0 ASM_NL \ > + .popsection > +#endif > + > /* SYM_END -- use only if you have to */ > #ifndef SYM_END > #define SYM_END(name, sym_type) \ > + CHECK_DUP_SYM_END(name) ASM_NL \ > .type name sym_type ASM_NL \ > .size name, .-name > #endif I tried this approach and it didn't work for me inside .macros. Oh, well, the name cannot be first, so now, we can have a check for both correct pairing _and_ duplicate ends in one: #define SYM_CHECK_START(name) \ .pushsection .rodata.bubak ASM_NL \ .long has_no_SYM_END_##name - . ASM_NL \ .popsection #define SYM_CHECK_END(name) \ has_no_SYM_END_##name: /* SYM_START -- use only if you have to */ #ifndef SYM_START #define SYM_START(name, align, visibility, entry) \ SYM_CHECK_START(name) ASM_NL \ visibility(name) ASM_NL \ align ASM_NL \ name: ASM_NL \ entry #endif /* SYM_END -- use only if you have to */ #ifndef SYM_END #define SYM_END(name, sym_type, exit) \ exit ASM_NL \ SYM_CHECK_END(name) ASM_NL \ .type name sym_type ASM_NL \ .size name, .-name #endif So for the ftrace mistake I did: AS arch/x86/kernel/mcount_64.o /home/latest/linux/arch/x86/kernel/mcount_64.S: Assembler messages: /home/latest/linux/arch/x86/kernel/mcount_64.S:192: Error: symbol `has_no_SYM_END_ftrace_caller' is already defined or if I remove SYM_END_FUNC completely: LD vmlinux.o MODPOST vmlinux.o arch/x86/built-in.o:(.rodata.bubak+0x130): undefined reference to `has_no_SYM_END_ftrace_stub' Sad is that this occurs only during linking, so I cannot put it in the .discard section -- ideas? thanks, -- js suse labs