]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
gas: gcfg: fix handling of non-local direct jmps in gcfg
authorIndu Bhagat <indu.bhagat@oracle.com>
Thu, 28 Mar 2024 18:57:23 +0000 (11:57 -0700)
committerIndu Bhagat <indu.bhagat@oracle.com>
Thu, 28 Mar 2024 18:57:23 +0000 (11:57 -0700)
commite67388a6a475ab1ddaac596f9995789363f1f10c
tree861cf979be4a1365886d892265eb8a7fed216224
parentb58829cdeff4644528ec06dfdb63ffb22910088f
gas: gcfg: fix handling of non-local direct jmps in gcfg

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
gas/testsuite/gas/scfi/x86_64/scfi-cfg-3.d [new file with mode: 0644]
gas/testsuite/gas/scfi/x86_64/scfi-cfg-3.l [new file with mode: 0644]
gas/testsuite/gas/scfi/x86_64/scfi-cfg-3.s [new file with mode: 0644]
gas/testsuite/gas/scfi/x86_64/scfi-x86-64.exp