From nobody Mon Feb 9 20:55:04 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=cloud.com ARC-Seal: i=1; a=rsa-sha256; t=1730893343; cv=none; d=zohomail.com; s=zohoarc; b=Y1IDe/+pnsNM7OMpEHCIF9/vB10deJAY7u5d/nLb0ChK8BBBWvqG7Qx35T/2JuTcCKzplhsWN68wYkke/L9Ej3H9GL1mTp2kBoxucBI8aQ+4RZ+TEbRHi8pxpPHxkivk/5+d4UB8yrxw3tqDgSKKqeRJo+nY/+OBRCMGFkFGM9k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730893343; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=JqBG/ejxY0G3tcFASKQ8s4CSPdRpi1GybkGCC/y1PZI=; b=I7JitT+qLlYcOZuRCUqeLfYmYJore8TtCCXhUGXTLItpBB8T8+nmYWRnHRKPOffrSf6aix/S+g5S1XkKr/1+vLs1TjARFcMIsh0HxznSdqPg0w8nZ9BzarbMfDHvoGwubiyNQ5QDuhOAUIQoK1zCn6Hf+D7p7qD6/NdBLnC51dc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 173089334396399.25676763637841; Wed, 6 Nov 2024 03:42:23 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.830780.1245870 (Exim 4.92) (envelope-from ) id 1t8eQI-0007qk-Kg; Wed, 06 Nov 2024 11:42:06 +0000 Received: by outflank-mailman (output) from mailman id 830780.1245870; Wed, 06 Nov 2024 11:42:06 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t8eQI-0007qd-GB; Wed, 06 Nov 2024 11:42:06 +0000 Received: by outflank-mailman (input) for mailman id 830780; Wed, 06 Nov 2024 11:42:04 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1t8eQG-0007aw-QF for xen-devel@lists.xenproject.org; Wed, 06 Nov 2024 11:42:04 +0000 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [2a00:1450:4864:20::436]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 23bce103-9c34-11ef-a0c6-8be0dac302b0; Wed, 06 Nov 2024 12:42:02 +0100 (CET) Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-37d4d1b48f3so3793776f8f.1 for ; Wed, 06 Nov 2024 03:42:02 -0800 (PST) Received: from fziglio-desktop.lan (99.149.115.87.dyn.plus.net. [87.115.149.99]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381c10e7465sm18840783f8f.53.2024.11.06.03.42.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Nov 2024 03:42:01 -0800 (PST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 23bce103-9c34-11ef-a0c6-8be0dac302b0 X-Custom-Connection: eyJyZW1vdGVpcCI6IjJhMDA6MTQ1MDo0ODY0OjIwOjo0MzYiLCJoZWxvIjoibWFpbC13cjEteDQzNi5nb29nbGUuY29tIn0= X-Custom-Transaction: eyJpZCI6IjIzYmNlMTAzLTljMzQtMTFlZi1hMGM2LThiZTBkYWMzMDJiMCIsInRzIjoxNzMwODkzMzIyLjU1MzQwOSwic2VuZGVyIjoiZnJlZGlhbm8uemlnbGlvQGNsb3VkLmNvbSIsInJlY2lwaWVudCI6Inhlbi1kZXZlbEBsaXN0cy54ZW5wcm9qZWN0Lm9yZyJ9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1730893322; x=1731498122; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JqBG/ejxY0G3tcFASKQ8s4CSPdRpi1GybkGCC/y1PZI=; b=M0LKNKb4MzltoxZVOmCmo1FazkBchinZQZ1MkT22ddDEa2SVKMQJK9Okw2z3ngevdM 42+G+Qm12FH3g773b+yfsU5kGNc4DksYon/DelUKmXXKK9dw2uCdfJzgyGyOIHqrIPw9 EXvFk9yh7klEMrXEIvC0bJeoXgKXjocqZ4D9A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730893322; x=1731498122; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JqBG/ejxY0G3tcFASKQ8s4CSPdRpi1GybkGCC/y1PZI=; b=cMznNoGnkn38aZ5QNkSscRxFIXCzBM2ntLpuFe+s289RQF8S/dMAI/y1lhB3s6C9E2 S8GazyjeC8OI9101hPS1/rWAYXAhMJzV4SArU04m6A3DzRCru94ZKTZDCu03BpOGf8gj UsOaZiUi05i/i0UKC38MtobQ5964ZjSDANFRdrFFIKkwRZjtsfa73PuUtY6TFeiUwUjG E4AwbItmVWn5v2+NmVw7KQbSm6RNBvOPpcE56lzQQPjZWkkQD9qY4gho0iLV6Y4ogTFS 3ih3cBOgpg7azJUihvICq787TTC7stW1jhRZM8G0duniSJTEMdLpx6UUhHYpHW4XeYXn I1hA== X-Gm-Message-State: AOJu0Yz7vSf9Zq/oY/oxI3wHTyWCsAwcYa/vpkCGe62B/1coat1rmqKp WwgPX+Zra4JhUPBiP8JlVGxfuwefTFcqzqbLHjOmrJqF1n8yCMK6QP86C7+WIoQsnJeYjx/OTrK umlY= X-Google-Smtp-Source: AGHT+IFD0Xyd4TJ84//eoDdUUxQkCWpWoZGmc7QsnwCtLxo/N+BKH3P92x9UO8Aq7fy35wObAzOaEA== X-Received: by 2002:adf:f204:0:b0:37d:39aa:b9f4 with SMTP id ffacd0b85a97d-381b708ae51mr18136525f8f.26.1730893321695; Wed, 06 Nov 2024 03:42:01 -0800 (PST) From: Frediano Ziglio To: xen-devel@lists.xenproject.org Cc: Frediano Ziglio , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Julien Grall , Stefano Stabellini Subject: [PATCH v2 2/3] x86/boot: Uses nm command instead of map file to get symbols Date: Wed, 6 Nov 2024 11:41:49 +0000 Message-Id: <20241106114150.1432512-3-frediano.ziglio@cloud.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241106114150.1432512-1-frediano.ziglio@cloud.com> References: <20241106114150.1432512-1-frediano.ziglio@cloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @cloud.com) X-ZM-MESSAGEID: 1730893345052116600 Content-Type: text/plain; charset="utf-8" Map file format is not standard making it code readind it not portable and potentially hard to maintain. Use nm command instead to get list of symbols; specifically BSD format as it does not truncate symbols names like sysv one. Fixes: aa9045e77130 ('x86/boot: Rework how 32bit C is linked/included for e= arly boot') Signed-off-by: Frediano Ziglio --- xen/arch/x86/boot/Makefile | 5 +++-- xen/tools/combine_two_binaries.py | 28 ++++++++++++++++++---------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/xen/arch/x86/boot/Makefile b/xen/arch/x86/boot/Makefile index 777b4befeb..01100a4b72 100644 --- a/xen/arch/x86/boot/Makefile +++ b/xen/arch/x86/boot/Makefile @@ -67,7 +67,8 @@ $(obj)/built-in-32.tmp.o: $(obj32) # If possible we use --orphan-handling=3Derror option to make sure we acco= unt # for all possible sections from C code. $(obj)/built-in-32.%.bin: $(obj)/build32.%.lds $(obj)/built-in-32.tmp.o - $(LD32) $(orphan-handling-y) -N -T $< -Map $(@:bin=3Dmap) -o $(@:bin=3Do)= $(filter %.o,$^) + $(LD32) $(orphan-handling-y) -N -T $< -o $(@:bin=3Do) $(filter %.o,$^) + $(NM) -p --format=3Dbsd $(@:bin=3Do) > $(@:bin=3Dnm) $(OBJCOPY) -j .text -O binary $(@:bin=3Do) $@ rm -f $(@:bin=3Do) =20 @@ -79,7 +80,7 @@ cmd_combine =3D \ --script $(obj)/build32.base.lds \ --bin1 $(obj)/built-in-32.base.bin \ --bin2 $(obj)/built-in-32.offset.bin \ - --map $(obj)/built-in-32.base.map \ + --symbols $(obj)/built-in-32.base.nm \ --exports cmdline_parse_early,reloc,reloc_trampoline32 \ --output $@ =20 diff --git a/xen/tools/combine_two_binaries.py b/xen/tools/combine_two_bina= ries.py index 447c0d3bdb..db02494b28 100755 --- a/xen/tools/combine_two_binaries.py +++ b/xen/tools/combine_two_binaries.py @@ -28,8 +28,8 @@ parser.add_argument('--text-diff', dest=3D'text_diff', help=3D'Difference between code section start') parser.add_argument('--output', dest=3D'output', help=3D'Output file') -parser.add_argument('--map', dest=3D'mapfile', - help=3D'Map file to read for symbols to export') +parser.add_argument('--symbols', dest=3D'symbols_file', + help=3D'Nm command output to read for symbols to expor= t') parser.add_argument('--exports', dest=3D'exports', help=3D'Symbols to export') parser.add_argument('--section-header', dest=3D'section_header', @@ -65,15 +65,23 @@ exports =3D [] if args.exports is not None: exports =3D dict([(name, None) for name in args.exports.split(',')]) =20 -# Parse mapfile, look for ther symbols we want to export. -if args.mapfile is not None: - symbol_re =3D re.compile(r'\s{15,}0x([0-9a-f]+)\s+(\S+)\n') - for line in open(args.mapfile): - m =3D symbol_re.match(line) - if not m or m.group(2) not in exports: +# Parse symbols file, look for symbols we want to export. +if args.symbols_file is not None: + dummy_start =3D -1 + for line in open(args.symbols_file): + v =3D line.split() + if len(v) !=3D 3 or v[1].upper() !=3D 'T': continue - addr =3D int(m.group(1), 16) - exports[m.group(2)] =3D addr + addr =3D int(v[0], 16) + if v[2] =3D=3D 'dummy_start': + dummy_start =3D addr + continue + if v[2] not in exports: + continue + exports[v[2]] =3D addr + if dummy_start !=3D 0: + raise Exception("dummy_start symbol expected to be present and 0") + for (name, addr) in exports.items(): if addr is None: raise Exception("Required export symbols %s not found" % name) --=20 2.34.1