From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by sourceware.org (Postfix) with ESMTPS id ED9823858D20 for ; Thu, 28 Mar 2024 06:20:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org ED9823858D20 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org ED9823858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::42c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711606832; cv=none; b=GAEgNR946sIqCckSUjWjzz3jPcLS3wDUp3whdlfuxluu+BffzLYbo3tv7DF69VgTIpxbE3NxMDSxRgAeasGkkao0bKwNOoC1S/5RRK73y1uFro5Z2KElLAgIa/qI2W2mNnVNcX09fHmsdUHHDeBHbxxnKGhlINoy5Jd+vB+8SqE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1711606832; c=relaxed/simple; bh=SycJqmoUqWP/WPmzvVifP/NAP8n04iVYuNFJCXNQ7Nk=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=aHIOjHknDfrsQMS4+Eoo4tWNPgF94Lr7k+0fAHi6+Q/ml+ZLy2wHNc/+bU52NEIGNs9Rr7kY0rhLbXI+qRfWrz8RC2oAroFOMy7CL1CZz30uU0UEjZN9/ID4VDhD5TxMyTGpRgTL6BLGxPx5v6sRSVmX4WS7U6NC7WWJ5QgL7O4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-341cf28dff6so388564f8f.1 for ; Wed, 27 Mar 2024 23:20:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1711606828; x=1712211628; darn=sourceware.org; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to; bh=5w/eNF30TpjSByHPaqmg8F+m9Mj3KfE802caRK+Tw+o=; b=g5IRBWwe1HFeK1V6pA+oOQs6d/ohZHlUhGV3d0QFgCxmQCWFM7/fqtvSV6M0PoWRjK +HH63jb76KwgQEw7sasgD+/JZEZE+RM7dPh2WGGJgrN27UGmZHX/b7Qq9fCPBptuRnSO qlgFWIoqt+YQZ7v4qKqwQN7D9ZZZYIOhuDOL4tqIVSkcPdiIYDrppVJz3UmrubYKH+yS c9VDJuikWrRm0aEbSU3IG7Hs7hPCwI8n9kz7KKmACcyGbpxLJxd1HylgfAmKq0GBLtsw rGjeDOzVZtmxUbbkLxacGpfhGqlxKumLiFt7RZ6sK/LLPhYxEshwG3t68lw5wKGG27Ls S3BQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711606828; x=1712211628; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=5w/eNF30TpjSByHPaqmg8F+m9Mj3KfE802caRK+Tw+o=; b=Zb5z7CBi5AsKAMHiylgC6UoIDHCmS+OVr0PAxXct/9wm1De6x1QanYxXCd0i7spEJ0 wr9iYmAMxa72CGfl66Q4hhCVHz3QFkxQQvuthWWwkpZspqdB2x9r1/b9KErJGAMle66h IHH4yf99d1Kbaqp5CpekNbaI4OUzwxqMEDooc1ev5mRwhbs62ivRyPsF7GkrAV4EjDmH sQk/vBcHiUaq1z7OAPAXufRKbv97X3pYdREnYCDMmEAgyxhLBXCNcMiZa++flxOFqlZ+ CTV1TSzukj+0mfPOaLsQJX4pKcAVfLckzXv4VY/a9Qp1YpgCDdyLx74FTIUlTre3oZEt 98Mw== X-Gm-Message-State: AOJu0Yy8DNq851Bqgv7F7ZnSmwUOet0oioWP1ZCdCEiEFHzGABn8BK4k sJpDKY7jIW6oxX7jhMy6FgxRumvhusM2/Rnbds1w7nywEjeyehBKP6ARN3N4RBaDPz2LcbzpmsM = X-Google-Smtp-Source: AGHT+IEkEA67ssixw1Yd3rcpRhlUQdPZtOeb6b1H0bT7yQyWzBEX1VvNNlgW4DU2FJvCVo3rPrgmUQ== X-Received: by 2002:a05:6000:1046:b0:33e:1c91:2346 with SMTP id c6-20020a056000104600b0033e1c912346mr1018182wrx.31.1711606828594; Wed, 27 Mar 2024 23:20:28 -0700 (PDT) Received: from ?IPV6:2003:ca:b738:601a:1073:a6:6f09:9d9a? (p200300cab738601a107300a66f099d9a.dip0.t-ipconnect.de. [2003:ca:b738:601a:1073:a6:6f09:9d9a]) by smtp.gmail.com with ESMTPSA id dq6-20020a0560000cc600b00341c3071c93sm818229wrb.73.2024.03.27.23.20.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 27 Mar 2024 23:20:28 -0700 (PDT) Message-ID: <4ea041de-765a-4c76-a68f-6fd38c9e1e0f@suse.com> Date: Thu, 28 Mar 2024 07:20:26 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PING][PATCH] gas: gcfg: fix handling of non-local direct jmps in gcfg To: Indu Bhagat Cc: binutils@sourceware.org References: <20240327065317.183190-1-indu.bhagat@oracle.com> <089d1ae6-a4dc-4982-8318-c9f787cbcba8@oracle.com> Content-Language: en-US From: Jan Beulich Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyG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scEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: <089d1ae6-a4dc-4982-8318-c9f787cbcba8@oracle.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3031.1 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 27.03.2024 22:58, Indu Bhagat wrote: > On 3/27/24 00:05, Jan Beulich wrote: >> On 27.03.2024 07:53, Indu Bhagat wrote: >>> The ginsn infrastructure in GAS includes the ability to create a GCFG >>> (ginsn CFG).  A GCFG is currently used for SCFI passes. >>> >>> This patch fixes the following invalid assumptions / code blocks: >>>   - The function ginsn_direct_local_jump_p () was erroneously _not_ >>>     checking whether the symbol is locally defined (i.e., within the >>>     scope of the code block for which GCFG is desired).  Fix the code >>>     to do so. >>>   - Similarly, the GCFG creation code, in gcfg_build () itself had an >>>     assumption that a GINSN_TYPE_JUMP to a non-local symbol will not be >>>     seen.  The latter can indeed be seen, and in fact, needs to be treated >>>     the same way as an exit from the function in terms of control-flow. >>> >>> gas/ >>>          * ginsn.c (ginsn_direct_local_jump_p): Check if the symbol >>>     is local to the code block or function being assembled. >>>          (add_bb_at_ginsn): Remove buggy assumption. >>>          (frch_ginsn_data_append): Direct jmps do not disqualify a stream >>>     of ginsns from GCFG creation. >>> >>> gas/testsuite/ >>>     * gas/scfi/x86_64/scfi-cfg-3.d: New test. >>>     * gas/scfi/x86_64/scfi-cfg-3.l: New test. >>>     * gas/scfi/x86_64/scfi-cfg-3.s: New test. >>>     * gas/scfi/x86_64/scfi-x86-64.exp: Add new test. >>> --- >>>   gas/ginsn.c                                   | 43 +++++++++++-------- >>>   gas/testsuite/gas/scfi/x86_64/scfi-cfg-3.d    | 24 +++++++++++ >>>   gas/testsuite/gas/scfi/x86_64/scfi-cfg-3.l    |  2 + >>>   gas/testsuite/gas/scfi/x86_64/scfi-cfg-3.s    | 21 +++++++++ >>>   gas/testsuite/gas/scfi/x86_64/scfi-x86-64.exp |  2 + >>>   5 files changed, 73 insertions(+), 19 deletions(-) >>>   create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-cfg-3.d >>>   create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-cfg-3.l >>>   create mode 100644 gas/testsuite/gas/scfi/x86_64/scfi-cfg-3.s >>> >>> diff --git a/gas/ginsn.c b/gas/ginsn.c >>> index 661f51d23c5..9f8e2979ab2 100644 >>> --- a/gas/ginsn.c >>> +++ b/gas/ginsn.c >>> @@ -447,13 +447,19 @@ ginsn_indirect_jump_p (ginsnS *ginsn) >>>   static bool >>>   ginsn_direct_local_jump_p (ginsnS *ginsn) >>>   { >>> -  bool ret_p = false; >>> +  bool local_p = false; >>> +  const symbolS *taken_label; >>> + >>>     if (!ginsn) >>> -    return ret_p; >>> +    return local_p; >>>   -  ret_p |= (ginsn->type == GINSN_TYPE_JUMP >>> -        && ginsn->src[0].type == GINSN_SRC_SYMBOL); >>> -  return ret_p; >>> +  if (ginsn->type == GINSN_TYPE_JUMP >>> +      && ginsn->src[0].type == GINSN_SRC_SYMBOL) >>> +    { >>> +      taken_label = ginsn->src[0].sym; >>> +      local_p |= (label_ginsn_map_find (taken_label) != NULL); >> >> The new testcase covers just one of two possible cases, if I'm not mistaken. >> Besides JMPing to an external label, wouldn't you want to also cover the >> case of JMPing to a label in the same file (i.e. defined at least by the >> end of parsing all of the source file)? From its name alone it isn't clear, >> after all, whether label_ginsn_map_find() would treat such one way or the >> other. And even looking at the function doesn't clarify that, without >> further trying to understand what scope the consulted hash table covers. >> > > Sure, adding such a jmp is good to make the testcase complete. > > I have now added the following to the testcase: > >      jmp   .L2 > .L2: >      ... > > The above should cover for the case when there is a unconditional jump to a label defined in the block of insns currently being process for GCFG creation. I have checked that the GCFG contains the edge to the successor bb. That's useful too, but not what I asked for. What I meant was a JMP to a label defined in the same source file, but outside the block of insns currently being processed (e.g. into another, separate function). Jan