gas: Fix internal error on long local labels
authorAlex Coplan <alex.coplan@arm.com>
Thu, 6 Aug 2020 16:39:03 +0000 (17:39 +0100)
committerAlex Coplan <alex.coplan@arm.com>
Thu, 6 Aug 2020 16:39:03 +0000 (17:39 +0100)
commitd27aad4ec307d91a6b9056127c6c248044391d7f
tree24940c28bd633fa92d1d8e9602fb958b4ee70b94
parented908db649cd48452fa4c1476a6be437ce9a0126
gas: Fix internal error on long local labels

Prior to this commit, on an input such as "88888888888:", GAS hits a
signed integer overflow and likely an assertion failure. I see:

$ echo "88888888888:" | bin/aarch64-none-elf-as
{standard input}: Assembler messages:
{standard input}:1: Internal error in fb_label_name at ../gas/symbols.c:2049.
Please report this bug.

To fix this issue, I've taken two steps:

1. Change the type used for processing local labels in
   read_a_source_file() from int to long, to allow representing more
   local labels, and also since all uses of this variable (temp) are
   actually of type long.

2. Detect if we would overflow and bail out with an error message
   instead of actually overflowing and hitting the assertion in
   fb_label_name().

gas/ChangeLog:

2020-08-06  Alex Coplan  <alex.coplan@arm.com>

* read.c (read_a_source_file): Use long for local labels, detect
overflow and raise an error for overly-long labels.
* testsuite/gas/all/gas.exp: Add local-label-overflow test.
* testsuite/gas/all/local-label-overflow.d: New test.
* testsuite/gas/all/local-label-overflow.l: Error output.
* testsuite/gas/all/local-label-overflow.s: Input.
gas/ChangeLog
gas/read.c
gas/testsuite/gas/all/gas.exp
gas/testsuite/gas/all/local-label-overflow.d [new file with mode: 0644]
gas/testsuite/gas/all/local-label-overflow.l [new file with mode: 0644]
gas/testsuite/gas/all/local-label-overflow.s [new file with mode: 0644]