Bug 18581 - (ARM): issue with function names with a dash inside
Summary: (ARM): issue with function names with a dash inside
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: gas (show other bugs)
Version: 2.25
: P2 normal
Target Milestone: 2.25
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-06-23 08:28 UTC by adrien
Modified: 2015-09-02 12:06 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
failing test case (1005 bytes, application/x-tar)
2015-06-23 08:28 UTC, adrien
Details

Note You need to log in before you can comment on or make changes to this bug.
Description adrien 2015-06-23 08:28:24 UTC
Created attachment 8384 [details]
failing test case

here is an issue when assembling an ARM assembly file which has one or multiple functions which have a dash in their name.

For instance, the file bug-arm.s in the attached archive contains a "test-a" function, and fails to assemble use GNU as:

I've used binutils-arm-linux-gnueabi debian package that includes binutils 2.25. The ARM toolchain from the android NDK has the same issue (binutils 2.24.90, see https://code.google.com/p/android/issues/detail?id=177830 for the original issue from which this one is derived). 

$ arm-linux-gnueabi-as bug-arm.s -o bug-arm.o
bug-arm.s: Assembler messages:
bug-arm.s:23: Error: Missing symbol name in directive
bug-arm.s:23: Error: unrecognized symbol type "test"
bug-arm.s:23: Error: junk at end of line, first unrecognized character is `-'
bug-arm.s:26: Error: junk at end of line, first unrecognized character is `"'
bug-arm.s:39: Error: expected comma after name `' in .size directive
bug-arm.s:62: Error: bad expression -- `bl "test-a"(PLT)'

If "test-a" is replaced by "test_a" (cf. the file work-arm.s), then GNU as manages to correctly assemble the object.

Note: even if the C language forbids dash in function names, some compilers like LLVM can create functions with dash inside their name after some optimisations.

Note bis: this works fines with the x86 GNU AS from binutils 2.25 (you can try with the file bug-x86.s).

Thanks for any help/feedbacks/thoughts about this issue!
Comment 1 cvs-commit@gcc.gnu.org 2015-08-21 15:43:42 UTC
The master branch has been updated by Nick Clifton <nickc@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=d02603dc201f80cd9d2a1f4b1a16110b1e04222b

commit d02603dc201f80cd9d2a1f4b1a16110b1e04222b
Author: Nick Clifton <nickc@redhat.com>
Date:   Fri Aug 21 16:42:14 2015 +0100

    Allow symbol and label names to be enclosed in double quotes.
    
    gas	PR gas/18581
    	* expr.c (get_symbol_end): Rename to get_symbol_name.  Add a
    	return parameter pointing to the start of the symbol.  Allow
    	symbol names enclosed in double quotes.
    	(restore_line_pointer): New function.  Replace the NUL character
    	inserted into the input stream with the given character.  If the
    	character was a double quote, advance the input pointer.
    	* expr.h (get_symbol_end): Delete.
    	(get_symbol_name): Add prototype.
    	(restore_line_pointer): Prototype.
    	* read.h (SKIP_WHITESPACE_AFTER_NAME): New macro.
    	* doc/as.texinfo (Symbol Intro): Document that symbol names can
    	now be enclosed in double quotes.
    	* cond.c (s_ifdef): Replace get_symbol_end with get_symbol_name.
    	Use restore_line_pointer to replace the NUL in the input stream.
    	Use SKIP_WHITESPACE_AFTER_NAME to skip past the end of a symbol.
    	Check for the use of double quoted symbol names.
    	* expr.c: Likewise.
    	* config/obj-aout.c: Likewise.
    	* config/obj-coff-seh.c: Likewise.
    	* config/obj-coff.c: Likewise.
    	* config/obj-elf.c: Likewise.
    	* config/obj-evax.c: Likewise.
    	* config/obj-macho.c: Likewise.
    	* config/obj-som.c: Likewise.
    	* config/tc-alpha.c: Likewise.
    	* config/tc-arc.c: Likewise.
    	* config/tc-arm.c: Likewise.
    	* config/tc-dlx.c: Likewise.
    	* config/tc-h8300.c: Likewise.
    	* config/tc-hppa.c: Likewise.
    	* config/tc-i370.c: Likewise.
    	* config/tc-i386-intel.c: Likewise.
    	* config/tc-i386.c: Likewise.
    	* config/tc-i960.c: Likewise.
    	* config/tc-ia64.c: Likewise.
    	* config/tc-iq2000.c: Likewise.
    	* config/tc-m32r.c: Likewise.
    	* config/tc-m68hc11.c: Likewise.
    	* config/tc-m68k.c: Likewise.
    	* config/tc-microblaze.c: Likewise.
    	* config/tc-mips.c: Likewise.
    	* config/tc-mmix.c: Likewise.
    	* config/tc-mn10200.c: Likewise.
    	* config/tc-mn10300.c: Likewise.
    	* config/tc-nios2.c: Likewise.
    	* config/tc-ppc.c: Likewise.
    	* config/tc-s390.c: Likewise.
    	* config/tc-score.c: Likewise.
    	* config/tc-score7.c: Likewise.
    	* config/tc-sparc.c: Likewise.
    	* config/tc-tic4x.c: Likewise.
    	* config/tc-tic54x.c: Likewise.
    	* config/tc-tic6x.c: Likewise.
    	* config/tc-tilegx.c: Likewise.
    	* config/tc-tilepro.c: Likewise.
    	* config/tc-v850.c: Likewise.
    	* config/tc-xtensa.c: Likewise.
    	* config/tc-z80.c: Likewise.
    	* dw2gencfi.c: Likewise.
    	* dwarf2dbgc.: Likewise.
    	* ecoff.c: Likewise.
    	* read.c: Likewise.
    	* stabs.c: Likewise.
    
    tests	PR gas/18581
    	* gas/all/byte.d: Disable this test.  Quoted expressions
    	are now allowed in .byte directives.
    	* gas/all/quoted-sym-names.s: New test.
    	* gas/all/quoted-sym-names.d: Expected output.
    	* gas/all/gas.exp: Run the new test.
Comment 2 Nick Clifton 2015-08-21 15:45:58 UTC
Hi Adrien,

  I have checked in a patch which should resolve this problem.  Please let me know if you have any more difficulties.

Cheers
  Nick
Comment 3 cvs-commit@gcc.gnu.org 2015-08-26 13:42:06 UTC
The master branch has been updated by Alan Modra <amodra@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=2d011dc1696f38580ca08cdccf9cb8147527063a

commit 2d011dc1696f38580ca08cdccf9cb8147527063a
Author: Alan Modra <amodra@gmail.com>
Date:   Wed Aug 26 22:55:41 2015 +0930

    Fallout from "Allow symbol and label names to be enclosed in double quotes"
    
    	PR gas/18581
    	* config/tc-mn10200.c (md_assemble <mdr>): Move restore_line_pointer
    	call to where input line used to be restored.
    	* config/tc-mn10300.c (md_assemble <usp>): Remove redundant input
    	line restore.
    	* config/tc-tilepro.c (parse_reg_expression): Add regname var.
Comment 4 cvs-commit@gcc.gnu.org 2015-08-27 13:51:08 UTC
The master branch has been updated by Alan Modra <amodra@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=2e57ce7b1422a025a65ad4ef0b1f2f4c214b9eec

commit 2e57ce7b1422a025a65ad4ef0b1f2f4c214b9eec
Author: Alan Modra <amodra@gmail.com>
Date:   Thu Aug 27 22:50:38 2015 +0930

    More fallout from "Allow symbol and label names to be enclosed in double quotes"
    
    Some of the TC_START_LABEL implementations need to adjust the end of
    the symbol, when a colon doesn't mean a label definition.  That means
    they need access to nul_char both the restore the NUL location (it may
    be a quote rather than a colon) and to store the new nul_char.  Others
    need adjusting to step over a potential trailing quote.
    
    	PR gas/18581
    	* config/tc-aarch64.h (TC_START_LABEL): Redefine.
    	* config/tc-arm.c (tc_start_label_without_colon): Delete params.
    	Use input_line_pointer directly.
    	* config/tc-arm.h (TC_START_LABEL): Redefine.
    	(TC_START_LABEL_WITHOUT_COLON): Redefine.
    	(tc_start_label_without_colon): Update prototype.
    	* config/tc-bfin.c (bfin_start_label): Delete ptr param.  Check
    	for NUL instead.
    	* config/tc-bfin.h (bfin_start_label): Update prototype.
    	(TC_START_LABEL): Redefine.
    	* config/tc-d30v.h (TC_START_LABEL): Redefine.
    	* config/tc-fr30.c (restore_colon): Rewrite.
    	(fr30_is_colon_insn): Add nul_char param.  Return int.  Bump
    	i_l_p over quote.  Update restore_colon calls.
    	* config/tc-fr30.h (TC_START_LABEL): Redefine.
    	(fr30_is_colon_insn): Update prototype.
    	* config/tc-m32c.c (restore_colon, m32c_is_colon_insn): As above.
    	* config/tc-m32c.h (TC_START_LABEL): Redefine.
    	(m32c_is_colon_insn): Update prototype.
    	* config/tc-m32r.h (TC_START_LABEL): Redefine.
    	* config/tc-mep.h (TC_START_LABEL): Redefine.
    	* config/tc-nds32.h (TC_START_LABEL): Redefine.
    	* config/tc-tic54x.c (tic54x_start_label): Replace params with
    	nul_char and next_char.  Step over trailing quote.
    	* config/tc-tic54x.h (TC_START_LABEL_WITHOUT_COLON): Redefine.
    	(tic54x_start_label): Update prototype.
    	* read.c (TC_START_LABEL): Redefine.  Update invocation.
    	(TC_START_LABEL_WITHOUT_COLON): Update invocation.
    	* config/tc-nios2.c (s_nios2_set): Save initial input_line_pointer
    	and restore if calling s_set.  Don't restore delim again.
Comment 5 Nick Clifton 2015-08-28 07:25:00 UTC
Hi Alan,

  Thanks very much for adding these fixes.  How did you discover the problems ?  I ran the gas/ld/binutils testsuites for all the targets and found no regressions...

Cheers
  Nick
Comment 6 Alan Modra 2015-09-01 12:58:00 UTC
Hi Nick, something must have gone wrong with your testsuite runs..  The fixes I made were in response to testsuite regressions.  From memory, tilepro didn't build, mn10200, nios2 and fr30 had failing tests.
Comment 7 Nick Clifton 2015-09-02 12:06:43 UTC
Hi Alan,

> Hi Nick, something must have gone wrong with your testsuite runs..  The fixes I
> made were in response to testsuite regressions.  From memory, tilepro didn't
> build, mn10200, nios2 and fr30 had failing tests.

Doh!  I did not have the tilepro and nios2 targets in my test farm.  I 
am not sure why the mn10200 and fr30 failures did not show up though, as 
I was definitely testing them.  Anyway thanks again for picking up my slack.

Cheers
   Nick