Why doesn't this assemble for elf but does for pe?

Nick Clifton nickc@redhat.com
Wed Apr 30 11:37:00 GMT 2003


Hi Stephen,

> I have some code that looks like this.  The code assembles when
> compiled with  i686-pc-pe-as but chokes when compiled with
> i686-pc-elf-as.  The version of the assembler is the same:

How does the assembler choke ?

> $ i686-pc-elf-as --version
> GNU assembler 030415 20030415

> --------------------- example ------------
>   .equ numRawHandlers, NumEntries
> table:
>        <some code goes here>
> common:
> .equ size, ((common - table/ numRawHandlers)

There are a couple of problem with this test case:

  * The value of NumEntries is not defined.
  * There is a missing closing brace after 'table' on the last line.

Anyway, if the problem is that the assembler is complaining about a
missing closing parenthesis:

  fred.s: Assembler messages:
  fred.s:5: Error: missing ')' (

then the reason is that the i386-pc-elf target defines the forward
slash character ('/') as starting a comment, so the second .equ
directive in the example above is interpreted as:

  .equ size, ((common - table

The answer is to disable pre-processing at the start of the file by
using the #NO_APP directive, like this:

  #NO_APP 
  	.equ NumEntries, 5
  	.equ numRawHandlers, NumEntries
  table:
         nop
  common:
	.equ size, ((common - table) / numRawHandlers)


Cheers
        Nick



More information about the Binutils mailing list