Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp14101056rwd; Sat, 24 Jun 2023 12:04:13 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7/InWhyC0Xlxce9/awXrpCp5GPD6kEw/wFlItwpfc3EJW4JFGMofzJuuPCGaTJDjFSgZ1i X-Received: by 2002:a05:6359:596:b0:130:f7b2:86ec with SMTP id ee22-20020a056359059600b00130f7b286ecmr13995184rwb.9.1687633453247; Sat, 24 Jun 2023 12:04:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687633453; cv=none; d=google.com; s=arc-20160816; b=yB3nOIGx+J/nmRP/GVnqqavadEf8h7NI+/TvVUBFguY1zlzN5UwkBJbms07anduuXC 6JBofGlsVazbvbz/8FFsnCTpfz2vSWWb4D9hQKJWSmX0BezFWwXs7edti96PjKS78s8V 6zrb/QZ26/+GJTcLoQNJuhyXtHflDogNWbPFqQl02P5aABfrD6iLJrh2dSQHla53LsnR 4VF83XANpXHETMc6S9mb4KSLvbAVpfesvrW3pSoKUTDeZ5R8mfJe4qMTl5kKCtRDH9x0 TuGRyz9o8IdiD9qIaTtjlJ+r5mHkvRFoHKwHMDUNDJboM+v6WKz6eNsyXmwnA3beXGWm WN3A== 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=nNj4tWij2jVaKwbomzo8lkrhVtG8JDk7ZilpHPoHQR4o6HC36rId70YzcWzyUAN8ou INRBBP83cxUA/Ee9YJK2flEntC+9Te/5ga4zilYqkcWFubXUGo2DO6rqINeCGbz515aV SlunnLkG/gWVMVCiYlUaYTXS0PmMG/BSRKCUgRiPo7AkMVaHwoRxhmFkXXthq1Hmt9Dl e3RPKjWMKwoVMwEBrnDH05vHJUrxWncsTXZx56B8o5u+0D6xEhl2gem2waoPde8JQaAk KjBTIOftNAg/QYqPecKRH7r6FwgL04VH14E9ngu4guiW7j9c9/A5QJJ5k+Ny6r67NEWZ DgTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xen0n.name header.s=mail header.b=rqoM2NoH; 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 fa12-20020a056a002d0c00b006687f4b1b56si1846028pfb.68.2023.06.24.12.03.42; Sat, 24 Jun 2023 12:04:13 -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=rqoM2NoH; 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 S233213AbjFXSlV (ORCPT + 99 others); Sat, 24 Jun 2023 14:41:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231997AbjFXSlP (ORCPT ); Sat, 24 Jun 2023 14:41:15 -0400 Received: from mailbox.box.xen0n.name (mail.xen0n.name [115.28.160.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E764510C2; Sat, 24 Jun 2023 11:41:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xen0n.name; s=mail; t=1687632073; bh=UGMkiVgsD7TmU72TjAy44icKsVdzIhU52JRB8B10DPk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rqoM2NoH9rlQ7eTfbgCTMVda9R/RGyl4KllU5Ib5Sg8IZgEbAmMkkbXkP8MOUR/UM fV2xsavONr28n+2bBrmQh5/CpbS9o4KMaJi5gO/byulQ0WUa1CjBhIVpr62wYUeO8j 3lSaIFhXBOtnMEt+GIjZ0S5163G0Jt2X07PvoUZY= 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 E57366015B; Sun, 25 Jun 2023 02:41:12 +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 v2 1/9] LoongArch: Calculate various sizes in the linker script Date: Sun, 25 Jun 2023 02:40:47 +0800 Message-Id: <20230624184055.3000636-2-kernel@xen0n.name> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230624184055.3000636-1-kernel@xen0n.name> References: <20230624184055.3000636-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