Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1200657pxb; Tue, 17 Aug 2021 06:18:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxdiyB+FStr6x6HPOm6OsW8x15PjAtpgpwT3gd5d0xDE9BlQOtj63uUwE6gQk7oCAouXFSv X-Received: by 2002:a17:906:3542:: with SMTP id s2mr4015562eja.379.1629206309625; Tue, 17 Aug 2021 06:18:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629206309; cv=none; d=google.com; s=arc-20160816; b=a+GzC46Fyazccw36Ax/JwwayukL1u8mPDmX94iACWH/Emi2nsHhhbzRa3j3hBHlqDq ToE0IIMUf/OYKPqbBoPAlCTifzY4xOkb85w++qHJuPEmoGjciHpuqswPhs084I7E3Msj zdxctPmoFIIY3i+eIm2XQ7c7LwVaQwOxhFXiJ/a9+KVIgHBXlcH69dzVmXA9mScoNeVG G/Kc4dZ6Mljwj9RNAe3lEwnMe0uqHQes5Itw0nblj/Ytg+X5rhVH7i/6PfWoV9Up6uXA qPgxhgqaXUzznFw5aQM1N3u02OOcOyK90O+I0K8fkP/DJ59d/KXqfm/MBz7MowW6r5+X 7EFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=oQqo8hoVlThMMKnyM3FPqRihSiJEUC2ucaiuvvbW2TA=; b=wXy8vJqj8NAvzfZMLxkUmC+nrktDWltRHzgLVtWY7sYUmUbyBGWjfA4alunnA6jg+F CwHf91hHbshlb5FHsh1R32eUAnUkDb9CnSeihIrnieA+77z/i5vSx4RUi+duR+4c24t2 FQrOPZD4vNMy9pChCN5rhZXJnRDj0opt4XwOKL886UvoOr8TqxAoANciJeXEg6y9Up7O NbWh8ODrBL9AXNl62IAHaVTEj4JQy1kl7tISA9W14ZaUN5ZzFLkiFniFTJnrm1mXZoEm ijnRlHi544dVG9QDKUuGhjyTbivoUePgN0CwNnSyyEpYw+hWevlnpYWqgyzAW2S5uvcR mvjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DKiX0Utf; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id de10si2358916edb.214.2021.08.17.06.18.02; Tue, 17 Aug 2021 06:18:29 -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=@redhat.com header.s=mimecast20190719 header.b=DKiX0Utf; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237475AbhHQNDq (ORCPT + 99 others); Tue, 17 Aug 2021 09:03:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:29787 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229721AbhHQNDm (ORCPT ); Tue, 17 Aug 2021 09:03:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629205388; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=oQqo8hoVlThMMKnyM3FPqRihSiJEUC2ucaiuvvbW2TA=; b=DKiX0UtfvSE9CLEB2umsy3lhsLqfmK1K5hDhfFLc6k7dutJcQwGfNLTcjFBWWduRjbTfn1 pQ0fp1N9RXM2z+FWH5x+kpJY+RnP++Yi/z7fHPUv0GdVvlQGozg378poNy/jG+me5ji/TT mhmnMWfDxTWOY0V3s8AlHTfmXlsbPlQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-449-sR4Wrbx7Nd6psWd4z1W6HQ-1; Tue, 17 Aug 2021 09:03:06 -0400 X-MC-Unique: sR4Wrbx7Nd6psWd4z1W6HQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5013EC73A0; Tue, 17 Aug 2021 13:03:05 +0000 (UTC) Received: from janakin.usersys.redhat.com (unknown [10.40.208.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id 514A95C1D5; Tue, 17 Aug 2021 13:03:03 +0000 (UTC) From: Jan Stancek To: mpe@ellerman.id.au, benh@kernel.crashing.org, paulus@samba.org, christophe.leroy@csgroup.eu, linuxppc-dev@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org, jstancek@redhat.com Subject: [PATCH/RFC] powerpc/module_64: allow .init_array constructors to run Date: Tue, 17 Aug 2021 15:02:54 +0200 Message-Id: <920acea9aa18e4f2956581a8e158bdaa376fdf63.1629203945.git.jstancek@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org gcov and kasan rely on compiler generated constructor code. For modules, gcc-8 with gcov enabled generates .init_array section, but on ppc64le it doesn't get executed. find_module_sections() never finds .init_array section, because module_frob_arch_sections() renames it to _init_array. Avoid renaming .init_array section, so do_mod_ctors() can use it. Cc: Michael Ellerman Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: Christophe Leroy Signed-off-by: Jan Stancek --- I wasn't able to trace the comment: "We don't handle .init for the moment: rename to _init" to original patch (it pre-dates .git). I'm not sure if it still applies today, so I limited patch to .init_array. This fixes gcov for modules for me on ppc64le 5.14.0-rc6. Renaming issue is also mentioned in kasan patches here: https://patchwork.ozlabs.org/project/linuxppc-dev/cover/20210319144058.772525-1-dja@axtens arch/powerpc/kernel/module_64.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/kernel/module_64.c b/arch/powerpc/kernel/module_64.c index 6baa676e7cb6..c604b13ea6bf 100644 --- a/arch/powerpc/kernel/module_64.c +++ b/arch/powerpc/kernel/module_64.c @@ -299,8 +299,16 @@ int module_frob_arch_sections(Elf64_Ehdr *hdr, sechdrs[i].sh_size); /* We don't handle .init for the moment: rename to _init */ - while ((p = strstr(secstrings + sechdrs[i].sh_name, ".init"))) + while ((p = strstr(secstrings + sechdrs[i].sh_name, ".init"))) { +#ifdef CONFIG_CONSTRUCTORS + /* find_module_sections() needs .init_array intact */ + if (strstr(secstrings + sechdrs[i].sh_name, + ".init_array")) { + break; + } +#endif p[0] = '_'; + } if (sechdrs[i].sh_type == SHT_SYMTAB) dedotify((void *)hdr + sechdrs[i].sh_offset, -- 2.27.0