Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4304264pxf; Tue, 30 Mar 2021 04:43:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxKBnoLZQ25QARSPywdR8gA7EuABZIo+881RX/CFIVbMUapi/O6nsF66K5Us0wCIhUkA98W X-Received: by 2002:aa7:c850:: with SMTP id g16mr32654580edt.324.1617104589201; Tue, 30 Mar 2021 04:43:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1617104589; cv=pass; d=google.com; s=arc-20160816; b=JOHwhsJj+zS6P/fVLnT3oatM1zhqQwe9CvjVWS41dCychIDGZsWe/W23po7pQtaZ6E iUdI1d+Tb8wjfxvJWsXef8yjtIw+WKU937QfNiXHJLOkBg4IucZ8dpNoFoJo0cNP2Elp 7IY/QCmCpg3kjOylzV8TCea8GE0fAimFtlbHPXEiQnBC1GyAiS/W3lyvHusKJD8CRR54 AaYiL67/MgXQ3UszbGIYv4FkDbyUamOb5XDyakY3u4Bc+dntZ3a4Keq5x7mQNEQvK9GP dMPVmwxEqGR5P8PJXy0wMSPL145bYdSiidmBh+IGSm9DJj2CNqm2X1wc564Ywv4mVxAl Szbw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=wlJvBPGf9zpq5/fJZk1Yy15sH4GX7Rhr0Pr6gu5i2I0=; b=JC6/A7rgP6CNEmzgA/jh83damvU8QAQ9ScBkAtumh7GvyaTS8ib3ZLDWRfAgcLN7qt IfuxdMu68vO2FABfVub+yfRw13jorlStUMSyO6CHn6huXsu7gN+FkISNA6VcUBxfIkdE O9r1mMT3KelsADOCkd/KRz4ufR8pTZBZ3/TP2onJnMLzyxA/7ZOaEYsQ/IU4+FMV4s8u EbM/j8X2yoR5St/TixVIKF7nP8K59n7oBlzE4hW/SVmM6M2gpdWU20vhNkDfh7gEQbpK UFG4hvjDjegUMwa9tNNhPf3DY8tNwMgQf8MJdLd6RbW6mwd8f/dfui1oMHqqi/LekVNV hLrg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nokia.onmicrosoft.com header.s=selector1-nokia-onmicrosoft-com header.b=SFfkVgJa; arc=pass (i=1 spf=pass spfdomain=nokia.com dmarc=pass fromdomain=nokia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nokia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ku22si14774807ejc.704.2021.03.30.04.42.46; Tue, 30 Mar 2021 04:43:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@nokia.onmicrosoft.com header.s=selector1-nokia-onmicrosoft-com header.b=SFfkVgJa; arc=pass (i=1 spf=pass spfdomain=nokia.com dmarc=pass fromdomain=nokia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nokia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231852AbhC3Lky (ORCPT + 99 others); Tue, 30 Mar 2021 07:40:54 -0400 Received: from mail-eopbgr20134.outbound.protection.outlook.com ([40.107.2.134]:55779 "EHLO EUR02-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231742AbhC3Lkt (ORCPT ); Tue, 30 Mar 2021 07:40:49 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UEwe8YMztRUROX4iS0nVCSu5v8TuKcuX6JO5FYUlmQcFxpd0YG0SB+SzZiV6XrtKcHsTL50wWmxYKLYhe2Rpc8Kt3veWTTUXDs4XF8fSavcxg1AVHh1WFk6Q/ghX+NDlH1c/KOC81degxq7R1VD4CYxCVxLGigO10skuhHsImdRveMDQRE6n5IJDInce2w4WRE6rFmUyB8kuDY3d69ZyIviulv8Yi5Jw1oBjrUlNwdmlXsUWS0HbLp9H/iCJd+LL3iikH1E96K7+r+Z/WbyUYAbu47OLpJYA+GrVjrNwjZvt6KUfhWFbsemKSV5QlwYYYPXfe/9U/q+37VkHqeszKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wlJvBPGf9zpq5/fJZk1Yy15sH4GX7Rhr0Pr6gu5i2I0=; b=YlQDD8XeJCA0+KrtUh/23Cdtg3XwACJKH6h9V5vJUzUidt92RuJ/+32pvtaUDW1fxuNM140XAfsli5t1FT4BJlR1v8YsG3sZmMkBy34nsSyrvE/psi7c0i28znupSC9j68FKUgB15W5SrA6XuyyWtK+WxX8y+fTd7EHggMZsMOawjRimPSUuRmUde8U5SgAy3JMrhjcGfIESvpGfY9kPBi2qmAuxarP8VzJTo5IAvlo/5aSpF0eeYhVN9/Ziozw5Xjy8NWI14sRaPk5YArh54mDnotT1j9FunvPUibd7YCKzHQCXnKS5tENwmJSAJ+l+ZedeqNtorKM28Iqd1zM+qg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 131.228.2.8) smtp.rcpttodomain=arm.com smtp.mailfrom=nokia.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=nokia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nokia.onmicrosoft.com; s=selector1-nokia-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wlJvBPGf9zpq5/fJZk1Yy15sH4GX7Rhr0Pr6gu5i2I0=; b=SFfkVgJarzrC/okVjrR+/iQNPLQMLRvRp29chh7d4twtqgaVQ6+dOUuqArdKJY4panRBrEif5/83YoaRln64TqlEg0otH21Ja0YrVlatCBGnf6PRZIkFfp7egnoqrgzL/Uuy1Knm3lp9/0zQddjKpbtazimJOI62njQQkvvkXnA= Received: from MR2P264CA0067.FRAP264.PROD.OUTLOOK.COM (2603:10a6:500:31::31) by AM5PR0701MB2721.eurprd07.prod.outlook.com (2603:10a6:203:76::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.14; Tue, 30 Mar 2021 11:40:46 +0000 Received: from VE1EUR03FT025.eop-EUR03.prod.protection.outlook.com (2603:10a6:500:31:cafe::5d) by MR2P264CA0067.outlook.office365.com (2603:10a6:500:31::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.25 via Frontend Transport; Tue, 30 Mar 2021 11:40:45 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 131.228.2.8) smtp.mailfrom=nokia.com; arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=pass action=none header.from=nokia.com; Received-SPF: Pass (protection.outlook.com: domain of nokia.com designates 131.228.2.8 as permitted sender) receiver=protection.outlook.com; client-ip=131.228.2.8; helo=fihe3nok0734.emea.nsn-net.net; Received: from fihe3nok0734.emea.nsn-net.net (131.228.2.8) by VE1EUR03FT025.mail.protection.outlook.com (10.152.18.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.29 via Frontend Transport; Tue, 30 Mar 2021 11:40:45 +0000 Received: from ulegcparamis.emea.nsn-net.net (ulegcparamis.emea.nsn-net.net [10.151.74.146]) by fihe3nok0734.emea.nsn-net.net (GMO) with ESMTP id 12UBeeuo023631; Tue, 30 Mar 2021 11:40:44 GMT From: Alexander A Sverdlin To: linux-arm-kernel@lists.infradead.org Cc: Alexander Sverdlin , Steven Rostedt , Ingo Molnar , Russell King , Florian Fainelli , linux-kernel@vger.kernel.org, Ard Biesheuvel , Qais Yousef Subject: [PATCH v8 3/3] ARM: ftrace: Add MODULE_PLTS support Date: Tue, 30 Mar 2021 13:40:35 +0200 Message-Id: <20210330114035.18575-4-alexander.sverdlin@nokia.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20210330114035.18575-1-alexander.sverdlin@nokia.com> References: <20210330114035.18575-1-alexander.sverdlin@nokia.com> X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-MS-PublicTrafficType: Email MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 0da15c10-98ee-4ce0-6c80-08d8f370a853 X-MS-TrafficTypeDiagnostic: AM5PR0701MB2721: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:751; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cR1RxNQQMVT1J5d0nYpxfMUuiN2F38w7BG3Ebu1HwPcIjoVipt/XCBPAb1CKEOVYW9GRx65EgiZXmv+RpfWsa9G7/FFMQ2zm13ngIIbbYFZ1VQiVpj73jaykvKAs1vkA34S4Io1nCwrZ38XZ9ypmF/Wdg4hzuWmfRK1pRlL8e+MfkSs65OlBLqg9XPaXaOb8CLmT9q9iM1eJOJt7TuLNcmXPXWKWzlFWutKUpWBVPOkr/iPLluvpfWVEri+wFoPk8h125DBfoyKrbDFqE//aCan9nrCfHXWaFxJH7CZDMlSE55kyb0cpZtfA4N/E4tqtml4IAr/98wkQB7IB2AZSNzE7+I014jPUfcBkyop9rI/9/rNYbBjxY9e+R40Q/cCcydOYD7dXe4oFY84AUr6K77wZLW+v8TW8PjGT6A7hRZ1dieYWZn5OOxkanngc2W8igE3ON6ZNdUnRL1sUb944Atz7h0KSIeXgE9kO/upP8U9duqo7A+VZEFAZ5dTCVgvHN4/lggixyJn5nHRJqWqL9AhEBq2oQ0E9w6dW/lLbTN7cYCSqs+KQSQVrTJS9xQjGe++T90P6kXL8h/8RAKe0n2zWnfFdUzarMxBPd/fQMZ4AzjpB+aNK5JxEDAv9+cniH+1kQ2d9DMXg1uhufZgOznKz54NLIAefcciP0srz+Wt6s0UB+ZfCm43Aezjl4YVl X-Forefront-Antispam-Report: CIP:131.228.2.8;CTRY:FI;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:fihe3nok0734.emea.nsn-net.net;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(4636009)(39860400002)(376002)(346002)(396003)(136003)(46966006)(36840700001)(70206006)(70586007)(8676002)(6916009)(36756003)(478600001)(47076005)(8936002)(81166007)(83380400001)(4326008)(26005)(2906002)(54906003)(5660300002)(36860700001)(2616005)(82740400003)(1076003)(316002)(186003)(336012)(86362001)(356005)(6666004)(82310400003)(36900700001);DIR:OUT;SFP:1102; X-OriginatorOrg: nokia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Mar 2021 11:40:45.7788 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0da15c10-98ee-4ce0-6c80-08d8f370a853 X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0;Ip=[131.228.2.8];Helo=[fihe3nok0734.emea.nsn-net.net] X-MS-Exchange-CrossTenant-AuthSource: VE1EUR03FT025.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0701MB2721 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexander Sverdlin Teach ftrace_make_call() and ftrace_make_nop() about PLTs. Teach PLT code about FTRACE and all its callbacks. Otherwise the following might happen: ------------[ cut here ]------------ WARNING: CPU: 14 PID: 2265 at .../arch/arm/kernel/insn.c:14 __arm_gen_branch+0x83/0x8c() ... Hardware name: LSI Axxia AXM55XX [] (unwind_backtrace) from [] (show_stack+0x11/0x14) [] (show_stack) from [] (dump_stack+0x81/0xa8) [] (dump_stack) from [] (warn_slowpath_common+0x69/0x90) [] (warn_slowpath_common) from [] (warn_slowpath_null+0x17/0x1c) [] (warn_slowpath_null) from [] (__arm_gen_branch+0x83/0x8c) [] (__arm_gen_branch) from [] (ftrace_make_nop+0xf/0x24) [] (ftrace_make_nop) from [] (ftrace_process_locs+0x27b/0x3e8) [] (ftrace_process_locs) from [] (load_module+0x11e9/0x1a44) [] (load_module) from [] (SyS_finit_module+0x59/0x84) [] (SyS_finit_module) from [] (ret_fast_syscall+0x1/0x18) ---[ end trace e1b64ced7a89adcc ]--- ------------[ cut here ]------------ WARNING: CPU: 14 PID: 2265 at .../kernel/trace/ftrace.c:1979 ftrace_bug+0x1b1/0x234() ... Hardware name: LSI Axxia AXM55XX [] (unwind_backtrace) from [] (show_stack+0x11/0x14) [] (show_stack) from [] (dump_stack+0x81/0xa8) [] (dump_stack) from [] (warn_slowpath_common+0x69/0x90) [] (warn_slowpath_common) from [] (warn_slowpath_null+0x17/0x1c) [] (warn_slowpath_null) from [] (ftrace_bug+0x1b1/0x234) [] (ftrace_bug) from [] (ftrace_process_locs+0x285/0x3e8) [] (ftrace_process_locs) from [] (load_module+0x11e9/0x1a44) [] (load_module) from [] (SyS_finit_module+0x59/0x84) [] (SyS_finit_module) from [] (ret_fast_syscall+0x1/0x18) ---[ end trace e1b64ced7a89adcd ]--- ftrace failed to modify [] 0xe9ef7006 actual: 02:f0:3b:fa ftrace record flags: 0 (0) expected tramp: c0314265 Signed-off-by: Alexander Sverdlin --- arch/arm/include/asm/ftrace.h | 3 +++ arch/arm/include/asm/module.h | 1 + arch/arm/kernel/ftrace.c | 46 +++++++++++++++++++++++++++++++++++-------- arch/arm/kernel/module-plts.c | 44 +++++++++++++++++++++++++++++++++++++---- 4 files changed, 82 insertions(+), 12 deletions(-) diff --git a/arch/arm/include/asm/ftrace.h b/arch/arm/include/asm/ftrace.h index 48ec1d0..a4dbac0 100644 --- a/arch/arm/include/asm/ftrace.h +++ b/arch/arm/include/asm/ftrace.h @@ -15,6 +15,9 @@ extern void __gnu_mcount_nc(void); #ifdef CONFIG_DYNAMIC_FTRACE struct dyn_arch_ftrace { +#ifdef CONFIG_ARM_MODULE_PLTS + struct module *mod; +#endif }; static inline unsigned long ftrace_call_adjust(unsigned long addr) diff --git a/arch/arm/include/asm/module.h b/arch/arm/include/asm/module.h index 09b9ad5..cfffae6 100644 --- a/arch/arm/include/asm/module.h +++ b/arch/arm/include/asm/module.h @@ -30,6 +30,7 @@ struct plt_entries { struct mod_plt_sec { struct elf32_shdr *plt; + struct plt_entries *plt_ent; int plt_count; }; diff --git a/arch/arm/kernel/ftrace.c b/arch/arm/kernel/ftrace.c index 61de817..3c83b5d 100644 --- a/arch/arm/kernel/ftrace.c +++ b/arch/arm/kernel/ftrace.c @@ -68,9 +68,10 @@ int ftrace_arch_code_modify_post_process(void) return 0; } -static unsigned long ftrace_call_replace(unsigned long pc, unsigned long addr) +static unsigned long ftrace_call_replace(unsigned long pc, unsigned long addr, + bool warn) { - return arm_gen_branch_link(pc, addr, true); + return arm_gen_branch_link(pc, addr, warn); } static int ftrace_modify_code(unsigned long pc, unsigned long old, @@ -104,14 +105,14 @@ int ftrace_update_ftrace_func(ftrace_func_t func) int ret; pc = (unsigned long)&ftrace_call; - new = ftrace_call_replace(pc, (unsigned long)func); + new = ftrace_call_replace(pc, (unsigned long)func, true); ret = ftrace_modify_code(pc, 0, new, false); #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS if (!ret) { pc = (unsigned long)&ftrace_regs_call; - new = ftrace_call_replace(pc, (unsigned long)func); + new = ftrace_call_replace(pc, (unsigned long)func, true); ret = ftrace_modify_code(pc, 0, new, false); } @@ -124,10 +125,22 @@ int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr) { unsigned long new, old; unsigned long ip = rec->ip; + unsigned long aaddr = adjust_address(rec, addr); + struct module *mod = NULL; + +#ifdef CONFIG_ARM_MODULE_PLTS + mod = rec->arch.mod; +#endif old = ftrace_nop_replace(rec); - new = ftrace_call_replace(ip, adjust_address(rec, addr)); + new = ftrace_call_replace(ip, aaddr, !mod); +#ifdef CONFIG_ARM_MODULE_PLTS + if (!new && mod) { + aaddr = get_module_plt(mod, ip, aaddr); + new = ftrace_call_replace(ip, aaddr, true); + } +#endif return ftrace_modify_code(rec->ip, old, new, true); } @@ -140,9 +153,9 @@ int ftrace_modify_call(struct dyn_ftrace *rec, unsigned long old_addr, unsigned long new, old; unsigned long ip = rec->ip; - old = ftrace_call_replace(ip, adjust_address(rec, old_addr)); + old = ftrace_call_replace(ip, adjust_address(rec, old_addr), true); - new = ftrace_call_replace(ip, adjust_address(rec, addr)); + new = ftrace_call_replace(ip, adjust_address(rec, addr), true); return ftrace_modify_code(rec->ip, old, new, true); } @@ -152,12 +165,29 @@ int ftrace_modify_call(struct dyn_ftrace *rec, unsigned long old_addr, int ftrace_make_nop(struct module *mod, struct dyn_ftrace *rec, unsigned long addr) { + unsigned long aaddr = adjust_address(rec, addr); unsigned long ip = rec->ip; unsigned long old; unsigned long new; int ret; - old = ftrace_call_replace(ip, adjust_address(rec, addr)); +#ifdef CONFIG_ARM_MODULE_PLTS + /* mod is only supplied during module loading */ + if (!mod) + mod = rec->arch.mod; + else + rec->arch.mod = mod; +#endif + + old = ftrace_call_replace(ip, aaddr, + !IS_ENABLED(CONFIG_ARM_MODULE_PLTS) || !mod); +#ifdef CONFIG_ARM_MODULE_PLTS + if (!old && mod) { + aaddr = get_module_plt(mod, ip, aaddr); + old = ftrace_call_replace(ip, aaddr, true); + } +#endif + new = ftrace_nop_replace(rec); ret = ftrace_modify_code(ip, old, new, true); diff --git a/arch/arm/kernel/module-plts.c b/arch/arm/kernel/module-plts.c index d330e9e..a0524ad 100644 --- a/arch/arm/kernel/module-plts.c +++ b/arch/arm/kernel/module-plts.c @@ -4,6 +4,7 @@ */ #include +#include #include #include #include @@ -20,19 +21,52 @@ (PLT_ENT_STRIDE - 8)) #endif +static const u32 fixed_plts[] = { +#ifdef CONFIG_FUNCTION_TRACER + FTRACE_ADDR, + MCOUNT_ADDR, +#endif +}; + static bool in_init(const struct module *mod, unsigned long loc) { return loc - (u32)mod->init_layout.base < mod->init_layout.size; } +static void prealloc_fixed(struct mod_plt_sec *pltsec, struct plt_entries *plt) +{ + int i; + + if (!ARRAY_SIZE(fixed_plts) || pltsec->plt_count) + return; + pltsec->plt_count = ARRAY_SIZE(fixed_plts); + + for (i = 0; i < ARRAY_SIZE(plt->ldr); ++i) + plt->ldr[i] = PLT_ENT_LDR; + + BUILD_BUG_ON(sizeof(fixed_plts) > sizeof(plt->lit)); + memcpy(plt->lit, fixed_plts, sizeof(fixed_plts)); +} + u32 get_module_plt(struct module *mod, unsigned long loc, Elf32_Addr val) { struct mod_plt_sec *pltsec = !in_init(mod, loc) ? &mod->arch.core : &mod->arch.init; + struct plt_entries *plt; + int idx; + + /* cache the address, ELF header is available only during module load */ + if (!pltsec->plt_ent) + pltsec->plt_ent = (struct plt_entries *)pltsec->plt->sh_addr; + plt = pltsec->plt_ent; - struct plt_entries *plt = (struct plt_entries *)pltsec->plt->sh_addr; - int idx = 0; + prealloc_fixed(pltsec, plt); + + for (idx = 0; idx < ARRAY_SIZE(fixed_plts); ++idx) + if (plt->lit[idx] == val) + return (u32)&plt->ldr[idx]; + idx = 0; /* * Look for an existing entry pointing to 'val'. Given that the * relocations are sorted, this will be the last entry we allocated. @@ -180,8 +214,8 @@ static unsigned int count_plts(const Elf32_Sym *syms, Elf32_Addr base, int module_frob_arch_sections(Elf_Ehdr *ehdr, Elf_Shdr *sechdrs, char *secstrings, struct module *mod) { - unsigned long core_plts = 0; - unsigned long init_plts = 0; + unsigned long core_plts = ARRAY_SIZE(fixed_plts); + unsigned long init_plts = ARRAY_SIZE(fixed_plts); Elf32_Shdr *s, *sechdrs_end = sechdrs + ehdr->e_shnum; Elf32_Sym *syms = NULL; @@ -236,6 +270,7 @@ int module_frob_arch_sections(Elf_Ehdr *ehdr, Elf_Shdr *sechdrs, mod->arch.core.plt->sh_size = round_up(core_plts * PLT_ENT_SIZE, sizeof(struct plt_entries)); mod->arch.core.plt_count = 0; + mod->arch.core.plt_ent = NULL; mod->arch.init.plt->sh_type = SHT_NOBITS; mod->arch.init.plt->sh_flags = SHF_EXECINSTR | SHF_ALLOC; @@ -243,6 +278,7 @@ int module_frob_arch_sections(Elf_Ehdr *ehdr, Elf_Shdr *sechdrs, mod->arch.init.plt->sh_size = round_up(init_plts * PLT_ENT_SIZE, sizeof(struct plt_entries)); mod->arch.init.plt_count = 0; + mod->arch.init.plt_ent = NULL; pr_debug("%s: plt=%x, init.plt=%x\n", __func__, mod->arch.core.plt->sh_size, mod->arch.init.plt->sh_size); -- 2.10.2