From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1386) id 2B9C13858C50; Wed, 19 Apr 2023 09:44:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2B9C13858C50 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Jan Beulich To: bfd-cvs@sourceware.org Subject: [binutils-gdb] gas: document that get_symbol_name() can clobber the input buffer X-Act-Checkin: binutils-gdb X-Git-Author: Jan Beulich X-Git-Refname: refs/heads/master X-Git-Oldrev: 4f0813127bc0c525fca152bca4fea30b7490ae14 X-Git-Newrev: ac164fa8540426238670184e0007e1d4261eaec8 Message-Id: <20230419094409.2B9C13858C50@sourceware.org> Date: Wed, 19 Apr 2023 09:44:09 +0000 (GMT) X-BeenThere: binutils-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Apr 2023 09:44:09 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Dac164fa85404= 26238670184e0007e1d4261eaec8 commit ac164fa8540426238670184e0007e1d4261eaec8 Author: Jan Beulich Date: Wed Apr 19 11:43:44 2023 +0200 gas: document that get_symbol_name() can clobber the input buffer =20 Callers which want to make further parsing attempts at the buffer passed to the function need to be aware that due to the potential of string concatenation the input buffer may be altered in ways beyond what can be undone by putting back at *input_line_pointer the character that the function returns. Diff: --- gas/expr.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/gas/expr.c b/gas/expr.c index afb346ebab3..680ec13b192 100644 --- a/gas/expr.c +++ b/gas/expr.c @@ -2388,12 +2388,17 @@ resolve_expression (expressionS *expressionP) here lessens the crowd at read.c. =20 Assume input_line_pointer is at start of symbol name, or the - start of a double quote enclosed symbol name. - Advance input_line_pointer past symbol name. - Turn that character into a '\0', returning its former value, - which may be the closing double quote. + start of a double quote enclosed symbol name. Advance + input_line_pointer past symbol name. Turn that character into a '\0', + returning its former value, which may be the closing double quote. + This allows a string compare (RMS wants symbol names to be strings) - of the symbol name. + of the symbol name. + + NOTE: The input buffer is further altered when adjacent strings are + concatenated by the function. Callers caring about the original buffer + contents will need to make a copy before calling here. + There will always be a char following symbol name, because all good lines end in end-of-line. */