This is the mail archive of the binutils@sourceware.cygnus.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

gas .macro quirks, and an ARM bug


I don't know if these are bugs, features, or coding errors on my part.
The first two apply to x86 and ARM, the third applies to ARM alone and
looks like a genuine bug.  The version of "as" doesn't seem to matter.

1) String arguments passed to macros have their quoting removed.

Example:
	.macro  hello   arg1, arg2
		.data
		.long   arg1
		.ascii  \arg2
	.endm
	hello   11, "hello world"

bug1.s: Assembler messages:
bug1.s:6: Error: Rest of line ignored. First ignored character is `h'.

A "fix" for this is quoting the arg in the macro, but IMHO this
shouldn't be necessary.

	.macro  hello   arg1, arg2
		.data
		.byte   arg1
		.ascii  "\arg2"
	.endm
	hello   11, "hello world"


2) Cannot pass a string argument with escaped characters to macros.

Example:
	.macro  hello   arg1, arg2
		.data
		.byte   arg1
		.ascii  "\arg2"
	.endm
	hello   13, "\"hello world\""
bug2.s: Assembler messages:
bug2.s:6: Error: too many positional arguments


3) Cannot pass a string argument ending in "=".  The "=" cannot be
escaped with "\=" either.

Example:
	.macro  hello   arg1
		.data
		.ascii  "\arg1"
	.endm
	answer   "answer ="

bug3.s: Assembler messages:
bug3.s:5: Error: bad instruction `answer "answer ="'

4) ARM Specific:  The .byte directive causes a long to be assembled
instead of a byte.

Example:
	.macro	hello	arg1
		.data
		.byte	(2f - 1f)
1:		.ascii	"\arg1"
2:
	.endm
	hello	"hello world"

a.out:     file format elf32-littlearm
Contents of section .text:
Contents of section .data:
 0000 0b000000 6c6f2077 6f726c64           ....lo world
Disassembly of section .text:

Notice how the "hel" bytes have been overwritten.

--
Andrew E. Mileski - Software Engineer
Rebel.com  http://www.rebel.com/

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]