Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp14708911rwd; Sun, 25 Jun 2023 02:57:44 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6kCUdd+mXUyvfIRYfvIuNeEtxw5rYZJTvHzPu/jkzvmAX6h29cJQ3iUWa/SXZfvZn6Z/rJ X-Received: by 2002:a05:6870:42c6:b0:1b0:293e:f8f3 with SMTP id z6-20020a05687042c600b001b0293ef8f3mr1895816oah.53.1687687064395; Sun, 25 Jun 2023 02:57:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687687064; cv=none; d=google.com; s=arc-20160816; b=C5U+p2ZTaPGF9nrxp8xjfWWi/0vO7HZhwb2wYG0cGFh0MjaiixxSz8FuroATHeGceE ASGI7iiirmV/kXK+pR12rJryxMRqQI7U1vwWklPEgmI2Etcygh1xwqQ3BpaopasgJVFb piiZP3vc+t8U8lejcT99Wo5gTji7iUkFnpX6k6YcnybK1iG9TX1EyX4t5+woiA7QktUd HRqPUO9ulk1WcU8pB8x7sATlUfw2LQtt0LuzxOm8i7EPmgFjqKpcJdhzGo+Qbubt0Sg9 13lp4wYn0/UJmZv3qTWTh9aQnzDZTPNmn0RRQ8e9bnmQxByB36vGwM5h6sJ0pjrXFGap EdzA== 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=; fh=dOptu1ihZdKkZ8ajFex7p+VOwkwvZgrA6cQy2X6s+EM=; b=G0L3OVfVG9DH3Ui9NgXt9sG6kSGTm2TNvHm3oecqgl1fGxgacHDZq8x433bkLH5fKf 4dsfObOlOKHHDWkzEHMfkeD7YBn7NpeR2Xo73TraL+6Z3rqI8GRYUGI6vKmk6i/G0fNS B1mteEsOEydp9BlEhd0+ttDtIGxc99SWfhLbI4wP2YnEMCXiqq8l6rHu0f6TBfHtMIct MZonhN4JfBGQpEZs6BO3i5lITnwo1wq0mf0r3y7ezGcKut7m9pf55AL9aZOE5Impt6Xj 1juasa85ipxnljJQJPdLk3k8RQhmAwW4SNM8Wuc4NZ21Pzd8VM2Iwcg3qCNZWjB1xXZJ GxsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xen0n.name header.s=mail header.b=qtdTPfBe; 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 q188-20020a632ac5000000b0053f6910ccc8si2940515pgq.747.2023.06.25.02.57.33; Sun, 25 Jun 2023 02:57:44 -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=qtdTPfBe; 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 S231236AbjFYJ5A (ORCPT + 99 others); Sun, 25 Jun 2023 05:57:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230203AbjFYJ46 (ORCPT ); Sun, 25 Jun 2023 05:56:58 -0400 Received: from mailbox.box.xen0n.name (mail.xen0n.name [115.28.160.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 950C9189; Sun, 25 Jun 2023 02:56:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xen0n.name; s=mail; t=1687687016; bh=UGMkiVgsD7TmU72TjAy44icKsVdzIhU52JRB8B10DPk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qtdTPfBenqcOclDJxFgwaklagBTEt6IfXBrI3jZtiM8hvv2cXxN8l+W71y2/tzae8 A/Vzc2Fs/8C/4iXefzfUsLc2TBFNey8K3jZt0EH09+Q2vjA6SyHBv1eLticTEjHg6e Nn7tt+FN7On/I/nXjA7T4/1s0jlGxa/BRuQxdg+I= 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 BC5CD6015B; Sun, 25 Jun 2023 17:56:55 +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 v3 1/8] LoongArch: Calculate various sizes in the linker script Date: Sun, 25 Jun 2023 17:56:37 +0800 Message-Id: <20230625095644.3156349-2-kernel@xen0n.name> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230625095644.3156349-1-kernel@xen0n.name> References: <20230625095644.3156349-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 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