From nobody Sat May 18 19:24:28 2024 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=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1657891667; cv=none; d=zohomail.com; s=zohoarc; b=eNqZp36dmoBUYpG4i/OyYWFlfyYEihCAIXOme2HWhFXlxrWJWFBBHA0WJ/GDHToy4NkcDTo1Y+tVEumKx4qrOzaWUxP35hJvz+8SmI6kCjbU7q2uLA19P/MJFPktTWJhyIyM46Ox39R+EC8nCQQIIo2z3omSdkMAQvIJnbsSbdI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1657891667; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=KGm8mKsxVW4BITs/sq+JCCh8bE3K7B9JCnn7GWbnr6M=; b=WqzFXzDNSnE5yUx3QkTU2iLf8LdWmxWVZGNUQGpCuneJv9u49yeWGCqYgKQncFmUHz0L/cojIKYuTNKv/17ClYOPbayQ62d+WginPz/oeua/zUoZ1N1gSTqKxphC1qn5m62ta1wY26/ngHQM+dLv95OlpIyrRPu3wjV1zJmmKDQ= 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 165789166766143.35164689077715; Fri, 15 Jul 2022 06:27:47 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.368229.599423 (Exim 4.92) (envelope-from ) id 1oCLLl-0000OP-5Y; Fri, 15 Jul 2022 13:27:21 +0000 Received: by outflank-mailman (output) from mailman id 368229.599423; Fri, 15 Jul 2022 13:27:21 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oCLLl-0000OI-2j; Fri, 15 Jul 2022 13:27:21 +0000 Received: by outflank-mailman (input) for mailman id 368229; Fri, 15 Jul 2022 13:27:20 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oCLLk-00007s-4y for xen-devel@lists.xenproject.org; Fri, 15 Jul 2022 13:27:20 +0000 Received: from esa5.hc3370-68.iphmx.com (esa5.hc3370-68.iphmx.com [216.71.155.168]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id d9929a37-0441-11ed-924f-1f966e50362f; Fri, 15 Jul 2022 15:27:19 +0200 (CEST) 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: d9929a37-0441-11ed-924f-1f966e50362f DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1657891639; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=Bo8WYCUkVXZCZC7rokwVAr1QbuRms3WVx1QMppMlBro=; b=Qk3ZvARhIJABb0VmBkgNepGSvVHhiiIGx0vZrGBxMAXrCttjevaHikFN 3WXF+57lqgvDazTZtFDFqiRSdJAskfgctCJyuHA1lhAmGN2qCiMJCIyST 07+V86S7sDy/HhkJnf0QHPTbHekGiy/SV7+nyASp+Ee9nOjUh3esvaLvZ 0=; Authentication-Results: esa5.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 5.1 X-MesageID: 75187320 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:LZ1TWqMOoOa/7AbvrR1Tl8FynXyQoLVcMsEvi/4bfWQNrUp20DcPx zdMXT3XPvnbZzCjL912aNm18BgD7JLWxoVgSgto+SlhQUwRpJueD7x1DKtR0wB+jCHnZBg6h ynLQoCYdKjYdleF+lH3dOCJQUBUjcmgXqD7BPPPJhd/TAplTDZJoR94kqsyj5UAbeKRWmthg vuv5ZyFULOZ82QsaDhMtPve8EgHUMna41v0gHRvPZing3eG/5UlJMp3Db28KXL+Xr5VEoaSL woU5Ojklo9x105F5uKNyt4XQGVTKlLhFVHmZk5tc7qjmnB/Shkaic7XAha+hXB/0F1ll/gpo DlEWAfZpQ0BZsUgk8xFO/VU/r0X0QSrN9YrLFDm2fF/wXEqfFPnxfdMNEw5OLZF491IGTpPz 94da24kO0Xra+KemNpXS8Fpj8UnasLqIJkeqjdryjSx4fQOGM6ZBf+QvJkBgWl21psm8fX2P qL1bRJGahjabgIJEVAQEJ8kx8+jh2Xlci0eo1WQzUYyyzeOlVwui+K1WDbTUvyWftdwmUTCn z7t5UD8IRQlL+649wPQpxpAgceQxHimCer+DoaQ8/d2gFye2yoPAQcMXF+TueO+lkm4XtteL wof/S9Ghaov8E2mSPHtUhv+p2SL1jY2VsBMCeQ85Eeow7DN/geCLmEeS3hKb9lOnOsrTjVs+ FaPlN7tASFHuaeQD3ma89+8jxm/JCwUJm8qfjIfQE0O5NyLiJE+iFfDQ8huFIaxj8bpAnfgz jaSti88ir4Py8kR2M2T4lTvkz+q4J/TQWYd/R7LV2io6gd4Yo+NZIGy71Xfq/FaI+6kokKp5 SZe3ZLEtaZXUM/LxHflrPgx8K+B7PCHEgXRjltUQoAayCz2+kSBeMMOyWQrTKt2CfroaQMFc WeK514OtMMCYyLxBUNkS9nvUpp3lMAMAfygD6mJNYQWP/CdYSfdpElTiVisM3cBeaTGuYU2I t+lfMmlFh724ow3nWPtF4/xPVLGrx3SJF8/prihlnxLKZLEOBaopU4taTNilNwR4qKeuxny+ N1CLcaMwBg3eLSgP3aHq9VDdgBQciNT6XXKRyt/L7TrH+abMDt5V6+5LU0JIeSJYJi5Zs+Xp yrgCye0OXL0hGHdKBXiV02PnIjHBM4lxVpiZHREFQ/xixALPNf0hI9CJsRfQFXS3LE6pRKCZ 6JeIJvo7zUmYmmvxgnxmrGm/d05JEnx3FzfV8dnCRBmF6Ndq8Xy0oeMVmPSGOMmUkJbaeNWT 2Wc6z7m IronPort-HdrOrdr: A9a23:9u2/RK/CT4G883Uhn35uk+DaI+orL9Y04lQ7vn2YSXRuHPBw9v re5cjzuiWVtN98Yh0dcJW7Scy9qBDnhPhICOsqTNSftWDd0QPCRuxfBMnZslnd8kXFh4lgPM xbEpSWZueeMbEDt7eZ3DWF X-IronPort-AV: E=Sophos;i="5.92,274,1650945600"; d="scan'208";a="75187320" From: Andrew Cooper To: Xen-devel CC: Anthony PERARD , George Dunlap , Jan Beulich , "Stefano Stabellini" , Wei Liu , Julien Grall , Luca Fancellu , Mathieu Tarral , Bertrand Marquis Subject: [PATCH v2 1/2] xen: Fix check-endbr.sh with mawk Date: Fri, 15 Jul 2022 14:26:50 +0100 Message-ID: <20220715132651.1093-2-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20220715132651.1093-1-andrew.cooper3@citrix.com> References: <20220715132651.1093-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1657891669446100002 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Anthony PERARD check-endbr.sh works with gawk, but fails with mawk. The produced $ALL file is smaller as it is missing 0x$vma_lo on every line. With mawk, int(0x2A) just produces 0, instead of the expected value. The use of hexadecimal-constant in awk is an optional part of the posix spec, and mawk doesn't seems to implemented. There is a way to convert an hexadecimal to a number be putting it in a string, and awk as I understand is supposed to use strtod() to convert the string to a number when needed. The expression 'int("0x15") + 21' would produce the expected value in `mawk` but now `gawk` won't convert the string to a number unless we use the option "--non-decimal-data". So let's convert the hexadecimal number before using it in the awk script. The shell as no issue with dealing with hexadecimal-constant so we'll simply use the expression "$(( 0x15 ))" to convert the value before using it in awk. Note: This does introduce a latent portability bug, which fixed in a separa= te change to avoid mixing complexity/explanations. Fixes: 4d037425dc ("x86: Build check for embedded endbr64 instructions") Resolves: xen-project/xen#26 Reported-by: Luca Fancellu Reported-by: Mathieu Tarral Signed-off-by: Anthony PERARD Reviewed-by: Bertrand Marquis Reviewed-by: Andrew Cooper --- CC: George Dunlap CC: Jan Beulich CC: Stefano Stabellini CC: Wei Liu CC: Julien Grall CC: Anthony PERARD CC: Luca Fancellu CC: Mathieu Tarral CC: Bertrand Marquis v2: * Add comment explaining what's going on. * Tweak commit message. Add a note about the portibility issue. --- xen/tools/check-endbr.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/xen/tools/check-endbr.sh b/xen/tools/check-endbr.sh index f633846b0f79..b3febd6a4ccc 100755 --- a/xen/tools/check-endbr.sh +++ b/xen/tools/check-endbr.sh @@ -64,6 +64,11 @@ ${OBJDUMP} -j .text $1 -d -w | grep ' endbr64 *$' | cut = -f 1 -d ':' > $VALID & # split the VMA in half so AWK's numeric addition is only working on 32= bit # numbers, which don't lose precision. # +# 4) MAWK doesn't support plain hex constants (an optional part of the POS= IX +# spec), and GAWK and MAWK can't agree on how to work with hex constant= s in +# a string. Use the shell to convert $vma_lo to decimal before passing= to +# AWK. +# eval $(${OBJDUMP} -j .text $1 -h | $AWK '$2 =3D=3D ".text" {printf "vma_hi=3D%s\nvma_lo=3D%s\n", substr($= 4, 1, 8), substr($4, 9, 16)}') =20 @@ -79,7 +84,7 @@ then else grep -aob -e "$(printf '\363\17\36\372')" -e "$(printf '\363\17\36\373= ')" \ -e "$(printf '\146\17\37\1')" $TEXT_BIN -fi | $AWK -F':' '{printf "%s%x\n", "'$vma_hi'", int(0x'$vma_lo') + $1}' > = $ALL +fi | $AWK -F':' '{printf "%s%x\n", "'$vma_hi'", int('$((0x$vma_lo))') + $1= }' > $ALL =20 # Wait for $VALID to become complete wait --=20 2.11.0 From nobody Sat May 18 19:24:28 2024 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=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1657891666; cv=none; d=zohomail.com; s=zohoarc; b=mzqRDB35fGsABTWqQs7Y6ZkQNfyNW81U3fDAXR8L3urDev448tZHF77YPKowQYKe5eOHo/04cQFkDSgSWHs6R72WhBE3kI8dmB8kOvAM65SIKZUnR2l+6AQ5C8En+RxdTF0gPu3JBtFe46wqXSQ8NnSxyJn5YHXDvMqcs+eF0KM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1657891666; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=bvQ6NUE/Aim+TAVjyH/eXCZWcld98EbD5bjVNJC52ys=; b=h6J8MdET5GA7hNLI7dm6IVN5IJjkeDcYSL3iwHtkYMZnc70SAt431Oqrs5DUwqIeo1lEtAYM6Gmsyn3Who3qdPo8HRsXqyw6vvnvKFVlGDPldQXQAMBY8oaBRYJyvs/UTCUPy+LIsQmmwtJDEs1u4/oKVLx9ifDXu7net+WaNDU= 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 1657891666712996.3205054968506; Fri, 15 Jul 2022 06:27:46 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.368230.599434 (Exim 4.92) (envelope-from ) id 1oCLLn-0000ey-FK; Fri, 15 Jul 2022 13:27:23 +0000 Received: by outflank-mailman (output) from mailman id 368230.599434; Fri, 15 Jul 2022 13:27:23 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oCLLn-0000ep-BM; Fri, 15 Jul 2022 13:27:23 +0000 Received: by outflank-mailman (input) for mailman id 368230; Fri, 15 Jul 2022 13:27:21 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oCLLl-00007s-CD for xen-devel@lists.xenproject.org; Fri, 15 Jul 2022 13:27:21 +0000 Received: from esa5.hc3370-68.iphmx.com (esa5.hc3370-68.iphmx.com [216.71.155.168]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id da51210b-0441-11ed-924f-1f966e50362f; Fri, 15 Jul 2022 15:27:20 +0200 (CEST) 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: da51210b-0441-11ed-924f-1f966e50362f DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1657891640; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=U5l4uZAhsQRLLS5kMyqPK59gZmSwaebKw6RbWmoikFw=; b=XFOfC6UEt/X4f1cpX/J3Y9dCW8gz+L/NwVIzNQxErV1YvRHo43V4DDma EzM49tcvLXtYe6CTzjQi3lpxJsfTR3Lz/EHPF9KteFSGemCnUzCOysBfW NnTJUrl08EFnPBJ2Amjw+E0woPI8h2bj435Dii4AemWjE6Y+uiaxSzJ1C M=; Authentication-Results: esa5.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 5.1 X-MesageID: 75187322 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:B3v3G61K40KjDHM+X/bD5SVxkn2cJEfYwER7XKvMYLTBsI5bpz0Cn zMWXGnVbv/YZWSkeYh/OoS2ox5SusfTmIRnHQNtpC1hF35El5HIVI+TRqvS04J+DSFhoGZPt Zh2hgzodZhsJpPkjk7xdOKn9RGQ7InQLpLkEunIJyttcgFtTSYlmHpLlvUwx4VlmrBVOSvU0 T/Ji5CZaQXNNwJcaDpOsfrc8U4355wehRtD1rAATaET1LPhvyF94KI3fcmZM3b+S49IKe+2L 86rIGaRpz6xE78FU7tJo56jGqE4aue60Tum0xK6b5OKkBlazhHe545gXBYqheW7vB3S9zx54 I0lWZVd0m7FNIWU8AgWe0Ew/y2TocSqUVIISJSymZX78qHIT5fj6/5oDmMOMIIdwbtuOl5Wr v0iCjVOMDnW0opawJrjIgVtrsEqLc2tN4IDoHBwizreCJ7KQ7iaHf+Mv4UBmm5t2IYeRp4yZ OJAAdZrRD3GbwdCJRE8D5Umkf3zrnL+bydZuBSeoq9fD237k1EogOe2aoC9ltqiY90K3Rypq 1n8pUfSDD5EDoOC8WWfyyf57gPItXyiA99DfFGizdZviUGTx2EOTgEfT0GypdGhkEmiXNRaI k0QvCEpqMAa9lGvT9T7dw21pjiDpBF0c/BdCfEg4QeBjI/d+R+EB3MsRyRELtchsaceYSEh3 xmnltXiCDhrrZWcU3fb/bCRxRuQEyUIKW4JZQcfUBAIpdLkpekbnh/JC9puDqOxptn0Ai3rh SCHqjAkgLcehtJN0L+0lXjYhxq8q56PSRQ6ji3MRX6s5A59YI+jZqSr5ELd4PIGK5yWJmRtp 1BdxZLYtrpXS8jQymrdG43hAY1F+d6ONj/+uVNgGqJ87g+S4yWiR6JVo29XcRIB3tk/RdP5X KPCkVoPucADYCr1NPQfj5GZUJpzk/W5fTjxfrWNN4cVPMAsHOOS1Hs2DXN8yVwBh6TFfUsXH Z6AOfihAn8BYUiM5GrnHrxNuVPHK81X+I8yeXwY507+uVZmTCTJIYrpyXPXBgzD0IuKoR/O7 /FUPNaQxhNUXYXWO3eKrt5JdgBRfSJkXvgaTvC7kcbaeGJb9JwJUaeNkdvNhaQ/90iqqgs41 i7kARIJoLYOrXbGNR+LehheVV8bZr4m9ShTFXV1ZT6AgiFzCa7yvfx3X8ZmItEaGBlLkKcco w8tIJ7bXJyii13vplwgUHUKhNczJU/72FjXYXvNjfpWV8cIejElM+TMJmPHnBTixALt3Sfii 9VMDj/mfKc= IronPort-HdrOrdr: A9a23:Sqxqj6ickQ/t/Xk8JOH9arjRfnBQXt4ji2hC6mlwRA09TySZ// rOoB17726NtN9/YgBCpTntAsa9qDbnhPpICOoqTM6ftWvdyQmVxehZhOOIqVCNJ8S9zJ876U 4JSdkZNDSaNzhHZKjBjjVQa+xQpeW6zA== X-IronPort-AV: E=Sophos;i="5.92,274,1650945600"; d="scan'208";a="75187322" From: Andrew Cooper To: Xen-devel CC: Andrew Cooper , George Dunlap , Jan Beulich , "Stefano Stabellini" , Wei Liu , Julien Grall , Anthony PERARD , Luca Fancellu , Mathieu Tarral , Bertrand Marquis Subject: [PATCH v2 2/2] xen: Fix latent check-endbr.sh bug with 32bit build environments Date: Fri, 15 Jul 2022 14:26:51 +0100 Message-ID: <20220715132651.1093-3-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20220715132651.1093-1-andrew.cooper3@citrix.com> References: <20220715132651.1093-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1657891669445100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" While Xen's current VMA means it works, the mawk fix (i.e. using $((0xN)) in the shell) isn't portable in 32bit shells. See the code comment for the fi= x. The fix found a second latent bug. Recombining $vma_hi/lo should have used printf "%s%08x" and only worked previously because $vma_lo had bits set in it's top nibble. Combining with the main fix, %08x becomes %07x. Fixes: $XXX patch 1 Reported-by: Jan Beulich Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: George Dunlap CC: Jan Beulich CC: Stefano Stabellini CC: Wei Liu CC: Julien Grall CC: Anthony PERARD CC: Luca Fancellu CC: Mathieu Tarral CC: Bertrand Marquis v2: * New --- xen/tools/check-endbr.sh | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/xen/tools/check-endbr.sh b/xen/tools/check-endbr.sh index b3febd6a4ccc..d6aa117de13b 100755 --- a/xen/tools/check-endbr.sh +++ b/xen/tools/check-endbr.sh @@ -61,19 +61,36 @@ ${OBJDUMP} -j .text $1 -d -w | grep ' endbr64 *$' | cut= -f 1 -d ':' > $VALID & # the lower bits, rounding integers to the nearest 4k. # # Instead, use the fact that Xen's .text is within a 1G aligned region,= and -# split the VMA in half so AWK's numeric addition is only working on 32= bit -# numbers, which don't lose precision. +# split the VMA so AWK's numeric addition is only working on <32 bit +# numbers, which don't lose precision. (See point 5) # # 4) MAWK doesn't support plain hex constants (an optional part of the POS= IX # spec), and GAWK and MAWK can't agree on how to work with hex constant= s in # a string. Use the shell to convert $vma_lo to decimal before passing= to # AWK. # +# 5) Point 4 isn't fully portable. POSIX only requires that $((0xN)) be +# evaluated as long, which in 32bit shells turns negative if bit 31 of = the +# VMA is set. AWK then interprets this negative number as a double bef= ore +# adding the offsets from the binary grep. +# +# Instead of doing an 8/8 split with vma_hi/lo, do a 9/7 split. +# +# The consequence of this is that for all offsets, $vma_lo + offset nee= ds +# to be less that 256M (i.e. 7 nibbles) so as to be successfully recomb= ined +# with the 9 nibbles of $vma_hi. This is fine; .text is at the start o= f a +# 1G aligned region, and Xen is far far smaller than 256M, but leave sa= fety +# check nevertheless. +# eval $(${OBJDUMP} -j .text $1 -h | - $AWK '$2 =3D=3D ".text" {printf "vma_hi=3D%s\nvma_lo=3D%s\n", substr($= 4, 1, 8), substr($4, 9, 16)}') + $AWK '$2 =3D=3D ".text" {printf "vma_hi=3D%s\nvma_lo=3D%s\n", substr($= 4, 1, 9), substr($4, 10, 16)}') =20 ${OBJCOPY} -j .text $1 -O binary $TEXT_BIN =20 +bin_sz=3D$(stat -c '%s' $TEXT_BIN) +[ "$bin_sz" -ge $(((1 << 28) - $vma_lo)) ] && + { echo "$MSG_PFX Error: .text offsets can exceed 256M" >&2; exit 1; } + # instruction: hex: oct: # endbr64 f3 0f 1e fa 363 017 036 372 # endbr32 f3 0f 1e fb 363 017 036 373 @@ -84,7 +101,7 @@ then else grep -aob -e "$(printf '\363\17\36\372')" -e "$(printf '\363\17\36\373= ')" \ -e "$(printf '\146\17\37\1')" $TEXT_BIN -fi | $AWK -F':' '{printf "%s%x\n", "'$vma_hi'", int('$((0x$vma_lo))') + $1= }' > $ALL +fi | $AWK -F':' '{printf "%s%07x\n", "'$vma_hi'", int('$((0x$vma_lo))') + = $1}' > $ALL =20 # Wait for $VALID to become complete wait --=20 2.11.0