Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp12493102rwd; Fri, 23 Jun 2023 06:58:12 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6oFvWJZ0w0EWyDr83FdLcEhe7gQJKxCzU5IEQRZBWYu1EmGvqSLHX19wrCUVN37cK3UHF8 X-Received: by 2002:a17:902:e54a:b0:1b6:7c9a:3a26 with SMTP id n10-20020a170902e54a00b001b67c9a3a26mr12569242plf.36.1687528692637; Fri, 23 Jun 2023 06:58:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687528692; cv=none; d=google.com; s=arc-20160816; b=v5eB2PNRIQlQkOHhDJQP4YhZ7yUAMzEia7v0b/n1FCuJSKKaHcKlkP/wsiEWsMoegG 2i6i9UQzVtSP4Yo+2XKU3ZpNXCzwz+1YGlrFyWEDSSlTTM7JRreoIiTMd4lWle9iEsVm bp50UXABfL0wpeJRz65+wUT5SdtIS/6pMadwIwijxQvMdkiOjWnIxYACebp7m6jB2vWp GM67oFH5blyjC8e1pF3x42wqF6AIs5W+JsxfWXtW2sm8SsHHlh4+BNlwo6g9GGGKTr0e pNqoZSnmvGl+BCowQTbUUV74Ev4WWigxRWaIerG0p3zWNcwNfZuYNUfbUli3YX7dt1SL mj9w== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=kFRo+kiT4MgRmDPPUMHK0nZcKxHLJF8GkcwJipyr5Cw=; b=ZuqzzQlNztVFJ20GyaEsNDDB05dzuLGxrnwo0K4vQDy9BkWdSyxlJznpACqV9KmL22 2kOEW80dWzrekSsod/7gsJ/+y+pL1+6o80Z+hBUBRGTxDnf5II2gMKM69jpxPG+MnUyr Or6KP5A0m4hTf5zkyQlP8O6aUpOKh9VurpfxdqcJukKWEo8hW7PW6EjQi9hgiBxLeTd6 jJkoayb76lYKYZzCBhLQFhmwmt3sdBS+HdIgJBUYV6oPZSm6m1caL1yVwrdOhiPMHuJG z/7IHb90mrPIqEvNoTQQCfF6WIWpMgVl9/LpaxZ2ofsCaVVIkXUJ1YuQDssPNvqkDZ/7 xeKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xen0n.name header.s=mail header.b=PcH2WS3O; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l5-20020a170903120500b001a6f0e81ec7si10319272plh.237.2023.06.23.06.57.59; Fri, 23 Jun 2023 06:58:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@xen0n.name header.s=mail header.b=PcH2WS3O; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231742AbjFWNoS (ORCPT + 99 others); Fri, 23 Jun 2023 09:44:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231702AbjFWNoN (ORCPT ); Fri, 23 Jun 2023 09:44:13 -0400 Received: from mailbox.box.xen0n.name (mail.xen0n.name [115.28.160.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 977FC1FE1; Fri, 23 Jun 2023 06:44:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xen0n.name; s=mail; t=1687527847; bh=UGMkiVgsD7TmU72TjAy44icKsVdzIhU52JRB8B10DPk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PcH2WS3OQnYbVLadIOb2aA7NaJzM1CB241KBf3vck8CD5g2ivzEZrZd+gVBR0wT7I zqh009KFH0f3bNRIVh7t6ZFIpCl9QH5oeRwygko6A9aTpZyC3+kIeK/h1c2Z4fONGP lj7Boe7rZ35pwtETS/alsxsKCSKIPwFo065hZP34= Received: from ld50.lan (unknown [101.88.25.181]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mailbox.box.xen0n.name (Postfix) with ESMTPSA id E2D386015C; Fri, 23 Jun 2023 21:44:06 +0800 (CST) From: WANG Xuerui To: Huacai Chen Cc: WANG Rui , Xi Ruoyao , loongarch@lists.linux.dev, linux-kbuild@vger.kernel.org, llvm@lists.linux.dev, linux-kernel@vger.kernel.org, WANG Xuerui Subject: [PATCH 1/9] LoongArch: Calculate various sizes in the linker script Date: Fri, 23 Jun 2023 21:43:43 +0800 Message-Id: <20230623134351.1898379-2-kernel@xen0n.name> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230623134351.1898379-1-kernel@xen0n.name> References: <20230623134351.1898379-1-kernel@xen0n.name> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: WANG Rui Taking the address delta between symbols in different sections is not supported by the LLVM IAS. Instead, do this in the linker script, so the same data can be properly referenced in assembly. Signed-off-by: WANG Rui Signed-off-by: WANG Xuerui --- arch/loongarch/kernel/efi-header.S | 6 +++--- arch/loongarch/kernel/head.S | 8 ++++---- arch/loongarch/kernel/vmlinux.lds.S | 7 +++++++ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/arch/loongarch/kernel/efi-header.S b/arch/loongarch/kernel/efi-header.S index 8c1d229a2afa..5f23b85d78ca 100644 --- a/arch/loongarch/kernel/efi-header.S +++ b/arch/loongarch/kernel/efi-header.S @@ -24,7 +24,7 @@ .byte 0x02 /* MajorLinkerVersion */ .byte 0x14 /* MinorLinkerVersion */ .long __inittext_end - .Lefi_header_end /* SizeOfCode */ - .long _end - __initdata_begin /* SizeOfInitializedData */ + .long _kernel_vsize /* SizeOfInitializedData */ .long 0 /* SizeOfUninitializedData */ .long __efistub_efi_pe_entry - _head /* AddressOfEntryPoint */ .long .Lefi_header_end - _head /* BaseOfCode */ @@ -79,9 +79,9 @@ IMAGE_SCN_MEM_EXECUTE /* Characteristics */ .ascii ".data\0\0\0" - .long _end - __initdata_begin /* VirtualSize */ + .long _kernel_vsize /* VirtualSize */ .long __initdata_begin - _head /* VirtualAddress */ - .long _edata - __initdata_begin /* SizeOfRawData */ + .long _kernel_rsize /* SizeOfRawData */ .long __initdata_begin - _head /* PointerToRawData */ .long 0 /* PointerToRelocations */ diff --git a/arch/loongarch/kernel/head.S b/arch/loongarch/kernel/head.S index 0d8180153ec0..53b883db0786 100644 --- a/arch/loongarch/kernel/head.S +++ b/arch/loongarch/kernel/head.S @@ -23,7 +23,7 @@ _head: .word MZ_MAGIC /* "MZ", MS-DOS header */ .org 0x8 .dword kernel_entry /* Kernel entry point */ - .dword _end - _text /* Kernel image effective size */ + .dword _kernel_asize /* Kernel image effective size */ .quad PHYS_LINK_KADDR /* Kernel image load offset from start of RAM */ .org 0x38 /* 0x20 ~ 0x37 reserved */ .long LINUX_PE_MAGIC @@ -32,9 +32,9 @@ _head: pe_header: __EFI_PE_HEADER -SYM_DATA(kernel_asize, .long _end - _text); -SYM_DATA(kernel_fsize, .long _edata - _text); -SYM_DATA(kernel_offset, .long kernel_offset - _text); +SYM_DATA(kernel_asize, .long _kernel_asize); +SYM_DATA(kernel_fsize, .long _kernel_fsize); +SYM_DATA(kernel_offset, .long _kernel_offset); #endif diff --git a/arch/loongarch/kernel/vmlinux.lds.S b/arch/loongarch/kernel/vmlinux.lds.S index 0c7b041be9d8..79f238df029e 100644 --- a/arch/loongarch/kernel/vmlinux.lds.S +++ b/arch/loongarch/kernel/vmlinux.lds.S @@ -136,6 +136,13 @@ SECTIONS DWARF_DEBUG ELF_DETAILS + /* header symbols */ + _kernel_asize = _end - _text; + _kernel_fsize = _edata - _text; + _kernel_offset = kernel_offset - _text; + _kernel_vsize = _end - __initdata_begin; + _kernel_rsize = _edata - __initdata_begin; + .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) -- 2.40.0