From patchwork Wed Nov 6 09:19:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrii Anisov X-Patchwork-Id: 11229745 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B81761575 for ; Wed, 6 Nov 2019 09:21:17 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 87DAB2173E for ; Wed, 6 Nov 2019 09:21:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="U+Wwm06/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 87DAB2173E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iSHTf-0006vy-3d; Wed, 06 Nov 2019 09:19:47 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iSHTc-0006vA-UI for xen-devel@lists.xenproject.org; Wed, 06 Nov 2019 09:19:44 +0000 X-Inumbo-ID: 87b6f2ee-0076-11ea-984a-bc764e2007e4 Received: from mail-lf1-x141.google.com (unknown [2a00:1450:4864:20::141]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 87b6f2ee-0076-11ea-984a-bc764e2007e4; Wed, 06 Nov 2019 09:19:27 +0000 (UTC) Received: by mail-lf1-x141.google.com with SMTP id f5so17478592lfp.1 for ; Wed, 06 Nov 2019 01:19:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=A2D8arGicganAwObtfIOuesVLUdvzsL7dF/vnzlO4jo=; b=U+Wwm06/M0kTDmAXPRnYzmco5VzHF8v+P2P1jDYQ+v/BS7mr1j5J7XNGVJ9Ngnx2et 5+uXvquTRsbRZz7Zq4y792EfrCZc0kOeugaqB0fomSZ8SptD+2Fgj95mVpPQMvQWcJPE IFyHZDJZ6xkRUE73ilqFlC0bom/uuE1C2+Ua7NoAwugd7vSi8nhDgvMWBO2tULTLqpj3 /rllViUaRoo9RxT/mYqU8bh/cAGwuLOqX5S3uBAtJrY/OI1ZUrAaYCC0ErhSXwnG1WUM 4FaqhezwK7VtGfQ/JlQf3Hqamju465WFfoddjXmsL8XcFICzC4E4jzL3AZdWON2xbK47 SB/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=A2D8arGicganAwObtfIOuesVLUdvzsL7dF/vnzlO4jo=; b=B41pLqi1BnsClCO9NZRZL2MIc9bHLo2AEAvkIzwa7ZXKoy4xOuvKYzU/gPv0dtj4/b K+tRvociqMtQjC+t2Kd0DWRZKGucX9pB9LaZAWSW/N/Ubq5PsV2m9pBGq5LDA7+ziDzu 0cG+lBKCrh7AhA0fadjAx2YNKT6fYcDJ7dhGK/olC6bw8G5ZXd1rLXXJLvH4c3ZVLxOZ iq3zajQfsdrEKzTNG8sosdeE7f4kuM/8wOUq2BEphhdcpeSK1XoueUF3FDp+yKp6lHbQ n/6inVKGOmabsMddg3jDz9cA4G/BA6fjrDePNywJi/xEulBbMG0xO3/ERaB1P9JuOxKl 0QwA== X-Gm-Message-State: APjAAAXVpRTZWZy/EEGAF5SSWsTKVqzsByLBG2zjpsgSg61nUUbBvSWq wh28XlxcPyf5YJQvfi5AKvqQVX9CrJA= X-Google-Smtp-Source: APXvYqzdIh37IxjMeTnuoOZdQf65qHt64ugtMHGizdXo7XT8896WnWGzL/ex3vQCGjQcBtkDff9NfA== X-Received: by 2002:ac2:48b5:: with SMTP id u21mr24147723lfg.75.1573031966032; Wed, 06 Nov 2019 01:19:26 -0800 (PST) Received: from aanisov-work.kyiv.epam.com (ll-74.141.223.85.sovam.net.ua. [85.223.141.74]) by smtp.gmail.com with ESMTPSA id g23sm3945937lja.104.2019.11.06.01.19.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 06 Nov 2019 01:19:25 -0800 (PST) From: Andrii Anisov To: xen-devel@lists.xenproject.org Date: Wed, 6 Nov 2019 11:19:11 +0200 Message-Id: <1573031953-12894-6-git-send-email-andrii.anisov@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1573031953-12894-1-git-send-email-andrii.anisov@gmail.com> References: <1573031953-12894-1-git-send-email-andrii.anisov@gmail.com> Subject: [Xen-devel] [RFC 5/7] WIP:arm64:armds: Build XEN with ARM Compiler 6.6 X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Andrii Anisov , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Jan Beulich , Julien Grall , Volodymyr Babchuk MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Andrii Anisov Here several ARM Compiler 6.6 issues are solved or provided a work-around: - Scatter file is pretty primitive, it has no feature to define symbols - ARM linker defined symbols are not counted as referred if only mentioned in a steering file for rename or resolve, so a header file is used to redefine GNU linker script symbols into armlink defined symbols. - _srodata type clashes by type with __start_bug_frames so can not be both redefined as Load$$_rodata_bug_frames_0$$Base. Use resolve feature of armlink steering file. - C style shift operators are missed among supported scatter file expressions, so some needed values are hardcoded in scatter file. - Rename correspondent ARM Linker defined symbols to those needed by `symbols` tool using steering file feature. - ARM Compiler 6.6 tools are not able to rename sections, so we still need GNU toolchain's objcopy for this. Signed-off-by: Andrii Anisov --- xen/Rules.mk | 6 + xen/arch/arm/Makefile | 24 ++++ xen/arch/arm/xen.scat.S | 266 ++++++++++++++++++++++++++++++++++++++++++++ xen/arch/arm/xen.steer | 5 + xen/include/asm-arm/armds.h | 91 +++++++++++++++ 5 files changed, 392 insertions(+) create mode 100644 xen/arch/arm/xen.scat.S create mode 100644 xen/arch/arm/xen.steer create mode 100644 xen/include/asm-arm/armds.h diff --git a/xen/Rules.mk b/xen/Rules.mk index 41a1c26..67bedce 100644 --- a/xen/Rules.mk +++ b/xen/Rules.mk @@ -60,6 +60,12 @@ CFLAGS += -nostdinc -fno-builtin -fno-common CFLAGS += -Werror -Wredundant-decls -Wno-pointer-arith $(call cc-option-add,CFLAGS,CC,-Wvla) CFLAGS += -pipe -D__XEN__ -include $(BASEDIR)/include/xen/config.h + +ifeq ($(armds),y) +CFLAGS += -nostdlibinc -nostdlib -Wno-unused-command-line-argument +CFLAGS += -include $(BASEDIR)/include/asm/armds.h +endif + CFLAGS-$(CONFIG_DEBUG_INFO) += -g CFLAGS += '-D__OBJECT_FILE__="$@"' diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile index 70f532e..a5a3479 100644 --- a/xen/arch/arm/Makefile +++ b/xen/arch/arm/Makefile @@ -83,11 +83,16 @@ else all_symbols = endif +ifeq ($(armds),y) +$(TARGET): $(TARGET)-syms + fromelf --bin $< --output $@ +else $(TARGET): $(TARGET)-syms $(OBJCOPY) -O binary -S $< $@ ifeq ($(CONFIG_ARM_64),y) ln -sf $(notdir $@) ../../$(notdir $@).efi endif +endif ifeq ($(CONFIG_LTO),y) # Gather all LTO objects together @@ -102,6 +107,19 @@ prelink.o: $(ALL_OBJS) $(LD) $(LDFLAGS) -r -o $@ $^ endif +ifeq ($(armds),y) +$(TARGET)-syms: prelink.o xen.scat + armlink --scatter="xen.scat" --edit="xen.steer" --no_scanlib $(LDFLAGS) prelink.o $(BASEDIR)/common/symbols-dummy.o -o $(@D)/.$(@F).0 + $(NM) -pa --format=sysv $(@D)/.$(@F).0 \ + | $(BASEDIR)/tools/symbols $(all_symbols) --sysv --sort >$(@D)/.$(@F).0.S + $(MAKE) -f $(BASEDIR)/Rules.mk $(@D)/.$(@F).0.o + armlink --scatter="xen.scat" --edit="xen.steer" --no_scanlib $(LDFLAGS) prelink.o $(@D)/.$(@F).0.o -o $(@D)/.$(@F).1 + $(NM) -pa --format=sysv $(@D)/.$(@F).1 \ + | $(BASEDIR)/tools/symbols $(all_symbols) --sysv --sort >$(@D)/.$(@F).1.S + $(MAKE) -f $(BASEDIR)/Rules.mk $(@D)/.$(@F).1.o + armlink --scatter="xen.scat" --edit="xen.steer" --no_scanlib --symdefs="$(@D)/$(@F).map" $(LDFLAGS) prelink.o $(build_id_linker) $(@D)/.$(@F).1.o -o $@ + rm -f $(@D)/.$(@F).[0-9]* +else $(TARGET)-syms: prelink.o xen.lds $(LD) $(LDFLAGS) -T xen.lds -N prelink.o \ $(BASEDIR)/common/symbols-dummy.o -o $(@D)/.$(@F).0 @@ -119,14 +137,20 @@ $(TARGET)-syms: prelink.o xen.lds | $(BASEDIR)/tools/symbols --xensyms --sysv --sort \ >$(@D)/$(@F).map rm -f $(@D)/.$(@F).[0-9]* +endif asm-offsets.s: $(TARGET_SUBARCH)/asm-offsets.c $(CC) $(filter-out -flto,$(CFLAGS)) -S -o $@ $< +ifeq ($(armds),y) +xen.scat: xen.scat.S + $(CC) -P -E --target=aarch64-arm-none-eabi -o $@ $< +else xen.lds: xen.lds.S $(CC) -P -E -Ui386 $(AFLAGS) -o $@ $< sed -e 's/xen\.lds\.o:/xen\.lds:/g' <.xen.lds.d >.xen.lds.d.new mv -f .xen.lds.d.new .xen.lds.d +endif dtb.o: $(CONFIG_DTB_FILE) diff --git a/xen/arch/arm/xen.scat.S b/xen/arch/arm/xen.scat.S new file mode 100644 index 0000000..3bb405f --- /dev/null +++ b/xen/arch/arm/xen.scat.S @@ -0,0 +1,266 @@ +#if 0 +/* + * armlink does not understand shifts in scat file expressions + * so hardcode needed values + */ +#include +#include +#include +#undef ENTRY +#undef ALIGN +#else + #define PAGE_SIZE 4096 + #define POINTER_ALIGN 8 + #define SMP_CACHE_BYTES 128 + #define STACK_SIZE 32768 + #define XEN_VIRT_START 0x00200000 +#endif + +LOAD XEN_VIRT_START +{ +;_start +;_stext + _text AlignExpr(+0, PAGE_SIZE) PADVALUE 0x9090 + { + *(.text*) + *(.text.cold) + *(.text.unlikely) + *(.fixup) + *(.gnu.warning) + } +;_etext + +;_srodata +;__start_bug_frames + _rodata_bug_frames_0 AlignExpr(+0, PAGE_SIZE) FIXED ZEROPAD + { + *(.bug_frames.0) + } +;__stop_bug_frames_0 + + _rodata_bug_frames_1 +0 FIXED ZEROPAD + { + *(.bug_frames.1) + } +;__stop_bug_frames_1 + + _rodata_bug_frames_2 +0 FIXED ZEROPAD + { + *(.bug_frames.2) + } +;__stop_bug_frames_2 + + _rodata_data +0 + { + *(.rodata) + *(.rodata.*) + *(.data.rel.ro) + *(.data.rel.ro.*) + } + +#ifdef CONFIG_LOCK_PROFILE +;__lock_profile_start + _rodata_lockprofile_data AlignExpr(+0, POINTER_ALIGN) FIXED ZEROPAD + { + *(.lockprofile.data) + } +;__lock_profile_end +#endif + +;__param_start + _rodata_data_param AlignExpr(+0, POINTER_ALIGN) FIXED ZEROPAD + { + *(.data.param) + } +;__param_end + +;__proc_info_start + _rodata_proc_info +0 FIXED ZEROPAD + { + *(.proc.info) + } +;__proc_info_end + +#if defined(CONFIG_HAS_VPCI) && defined(CONFIG_LATE_HWDOM) +;__start_vpci_array + _rodata_data_vpci AlignExpr(+0, POINTER_ALIGN) SORTTYPE Lexical FIXED ZEROPAD + { + *(SORT(.data.vpci.*)) + } +;__end_vpci_array +#endif + +#if defined(BUILD_ID) +;__note_gnu_build_id_start + _note_gnu_build_id +0 FIXED ZEROPAD + { + *(.note.gnu.build-id) + } +;__note_gnu_build_id_end +#endif + +;_erodata + + _data AlignExpr(+0, PAGE_SIZE) FIXED ZEROPAD + { + *(.data.page_aligned.*) + *(.data.*) + } + +;__start_schedulers_array + _data_schedulers AlignExpr(+0, 8) FIXED ZEROPAD + { + *(.data.schedulers) + } +;__end_schedulers_array + + _data_rel +0 FIXED ZEROPAD + { + *(.data.rel) + *(.data.rel.*) +;#CONSTRUCTORS ???? + } + +;__start___ex_table + _data_ex_table AlignExpr(+0, SMP_CACHE_BYTES) FIXED ZEROPAD + { + *(.ex_table) + } +;__stop___ex_table + +;__start___pre_ex_table + _data_ex_table_pre +0 FIXED ZEROPAD + { + *(.ex_table.pre) + } +;__stop___pre_ex_table + + _data_read_mostly +0 FIXED ZEROPAD + { + *(.data.read_mostly) + } + +;_splatform + _arch_info AlignExpr(+0, 8) FIXED ZEROPAD + { + *(.arch.info) + } +;_eplatform + +;_sdevice + _dev_info AlignExpr(+0, 8) FIXED ZEROPAD + { + *(.dev.info) + } +;_edevice + +;_asdevice + _adev_info AlignExpr(+0, 8) FIXED ZEROPAD + { + *(.adev.info) + } +;_aedevice + +;__init_begin +;_sinittext + _init_text AlignExpr(+0, PAGE_SIZE) FIXED ZEROPAD + { + *(.init.text) + } +;_einittext + + _init_rodata AlignExpr(+0, PAGE_SIZE) FIXED ZEROPAD + { + *(.init.rodata) + *(.init.rodata.rel) + *(.init.rodata.str*) + } + +;__setup_start + _init_setup AlignExpr(+0, POINTER_ALIGN) FIXED ZEROPAD + { + *(.init.setup) + } +;__setup_end + +;__initcall_start + _initcallpresmp_init +0 FIXED ZEROPAD + { + *(.initcallpresmp.init) + } +;__presmp_initcall_end + + _initcall1_init +0 FIXED ZEROPAD + { + *(.initcall1.init) + } +;__initcall_end + +;__alt_instructions + _altinstructions AlignExpr(+0, 4) FIXED ZEROPAD + { + *(.altinstructions) + } +;__alt_instructions_end + + _altinstr_replacement AlignExpr(+0, 4) FIXED ZEROPAD + { + *(.altinstr_replacement) + } + + _init_data +0 FIXED ZEROPAD + { + *(.init.data) + *(.init.data.rel) + *(.init.data.rel.*) + } + +;__ctors_start + _ctors AlignExpr(+0, 8) FIXED ZEROPAD + { + *(.ctors) + *(.init_array) + } + + _init_array_sorted AlignExpr(+0, 8) SORTTYPE Lexical FIXED ZEROPAD + { + *(.init_array.*) + } +;__ctors_end + +#if defined(CONFIG_HAS_VPCI) && !defined(CONFIG_LATE_HWDOM) + _data_vpci AlignExpr(+0, POINTER_ALIGN) SORTTYPE Lexical FIXED ZEROPAD + { + *(.data.vpci.*) + } +#endif +;__init_end_efi + +;__init_end +;__bss_start + _bss AlignExpr(+0, STACK_SIZE) FIXED ZEROPAD + { + *(.bss.stack_aligned*) + *(.bss.page_aligned*, OVERALIGN PAGE_SIZE) + *(.bss*) + } + +;__per_cpu_start + _bss_percpu AlignExpr(+0, SMP_CACHE_BYTES) FIXED ZEROPAD + { + *(.bss.percpu) + *(.bss.percpu.read_mostly, OVERALIGN SMP_CACHE_BYTES) + } +;__per_cpu_data_end +;__bss_end +;_end + +#ifdef CONFIG_DTB_FILE +;_sdtb + _dtb FIXED ZEROPAD + { + *(.dtb) + } +#endif + +} diff --git a/xen/arch/arm/xen.steer b/xen/arch/arm/xen.steer new file mode 100644 index 0000000..646e912 --- /dev/null +++ b/xen/arch/arm/xen.steer @@ -0,0 +1,5 @@ +RESOLVE _srodata AS Load$$_rodata_bug_frames_0$$Base +RENAME Load$$_text$$Base AS _stext +RENAME Load$$_text$$Limit AS _etext +RENAME Load$$_init_text$$Base AS _sinittext +RENAME Load$$_init_text$$Limit AS _einittext diff --git a/xen/include/asm-arm/armds.h b/xen/include/asm-arm/armds.h new file mode 100644 index 0000000..5ee2e5d --- /dev/null +++ b/xen/include/asm-arm/armds.h @@ -0,0 +1,91 @@ +#define _start Load$$_text$$Base +#define _stext Load$$_text$$Base + +#define _etext Load$$_text$$Limit + +//#define _srodata Load$$_rodata_bug_frames_0$$Base +#define __start_bug_frames Load$$_rodata_bug_frames_0$$Base + +#define __stop_bug_frames_0 Load$$_rodata_bug_frames_0$$Limit +#define __stop_bug_frames_1 Load$$_rodata_bug_frames_1$$Limit +#define __stop_bug_frames_2 Load$$_rodata_bug_frames_2$$Limit + +#ifdef CONFIG_LOCK_PROFILE +#define __lock_profile_start Load$$_rodata_lockprofile_data$$Base +#define __lock_profile_end Load$$_rodata_lockprofile_data$$Limit +#endif + +#define __param_start Load$$_rodata_data_param$$Base +#define __param_end Load$$_rodata_data_param$$Limit + +#define __proc_info_start Load$$_rodata_proc_info$$Base +#define __proc_info_end Load$$_rodata_proc_info$$Limit + +#define _erodata Load$$_rodata_proc_info$$Limit + +#if defined(CONFIG_HAS_VPCI) && defined(CONFIG_LATE_HWDOM) +#define __start_vpci_array Load$$_rodata_data_vpci$$Base +#define __end_vpci_array Load$$_rodata_data_vpci$$Limit + +#undef _erodata +#define _erodata Load$$_rodata_data_vpci$$Limit +#endif + +#if defined(BUILD_ID) +#define __note_gnu_build_id_start Load$$_note_gnu_build_id$$Base +#define __note_gnu_build_id_end Load$$_note_gnu_build_id$$Limit + +#undef _erodata +#define _erodata Load$$_note_gnu_build_id$$Limit +#endif + +#define __start_schedulers_array Load$$_data_schedulers$$Base +#define __end_schedulers_array Load$$_data_schedulers$$Limit + +/* Does not exist for ARM +#define __start___ex_table Load$$_data_ex_table$$Base +#define __stop___ex_table Load$$_data_ex_table$$Limit +*/ + +#define __start___pre_ex_table Load$$_data_ex_table_pre$$Base +#define __stop___pre_ex_table Load$$_data_ex_table_pre$$Limit + +#define _splatform Load$$_arch_info$$Base +#define _eplatform Load$$_arch_info$$Limit + +#define _sdevice Load$$_dev_info$$Base +#define _edevice Load$$_dev_info$$Limit + +#define _asdevice Load$$_adev_info$$Base +#define _aedevice Load$$_adev_info$$Limit + +#define __init_begin Load$$_init_text$$Base +#define _sinittext Load$$_init_text$$Base +#define _einittext Load$$_init_text$$Limit + +#define __setup_start Load$$_init_setup$$Base +#define __setup_end Load$$_init_setup$$Limit + +#define __initcall_start Load$$_initcallpresmp_init$$Base +#define __presmp_initcall_end Load$$_initcallpresmp_init$$Limit +#define __initcall_end Load$$_initcall1_init$$Limit + +#define __alt_instructions Load$$_altinstructions$$Base +#define __alt_instructions_end Load$$_altinstructions$$Limit + +#define __ctors_start Load$$_ctors$$Base +#define __ctors_end Load$$_init_array_sorted$$Limit +#define __init_end_efi Load$$_init_array_sorted$$Limit + +#if defined(CONFIG_HAS_VPCI) && !defined(CONFIG_LATE_HWDOM) +#undef __init_end_efi +#define __init_end_efi Load$$_data_vpci$$Limit +#endif + +#define __init_end Load$$_bss$$Base +#define __bss_start Load$$_bss$$Base + +#define __per_cpu_start Load$$_bss_percpu$$Base +#define __per_cpu_data_end Load$$_bss_percpu$$Limit +#define __bss_end Load$$_bss_percpu$$Limit +#define _end Load$$_bss_percpu$$Limit