Preprocessing before assembling

OP #1174329
Environment details:

make:                3.18
binutils:            2.18
arm-elf-gcc:    4.2.2
newlib:              1.16.0
gdb:                  6.8.50-20080308-cvs

I am trying to compile a assembly file which is 'board_startup.S'
received as a part of the 'at91lib' package.

the file is provided in the attachment.

Questions:
1) How to make the assembler pre process the .s file before assembling?
2) What are the most essential options with which the assembler should
be invoked to generate the object file out of the assembly file (arm
architecture specific options are being taken care of)

Thanks
Vinit
#1174332
> 1) How to make the assembler pre process the .s file before assembling?

You can run teh C pre-processor independently of the compiler. It is
called cpp (for an arm-elf cross-toolchain arm-elf-cpp [.exe extension
under Windows]). You can pass it any GCC options, only those that
control the pre-processor will have any affect. So you would pass the
-I<include-path> options for example, and any -D<macro>[=<value>]
options for example. Often it is just as easy to pass all CFLAGS or
AFLAGS.

> 2) What are the most essential options with which the assembler should
> be invoked to generate the object file out of the assembly file (arm
> architecture specific options are being taken care of)

Its your project, that's up to you. Assembler code has no options that
affect code generation since you generate the code manually. The
architecture options simply determine the instruction set and endianness
to validate against.


Clifford
OP #1174333
Clifford Slocombe wrote:

> Its your project, that's up to you. Assembler code has no options that
> affect code generation since you generate the code manually. The
> architecture options simply determine the instruction set and endianness
> to validate against.
>
>
> Clifford

Ok. got it.
#1174334
In case it is useful, my make file invokes the following commands for
assembler file builds:

  cpp $(INCLUDES) $< $(patsubst %.s, %_temp.s, $<)
  $(AS) $(AFLAGS) $(patsubst %.s, %_temp.s, $<) -o $@
  rm $(patsubst %.s, %_temp.s, $<)

The first executes the pre-processor on xxxx.s to produce xxxx_temp.s.
The second takes xxxx_temp.s to produce xxxx.o
The third deletes xxxx_temp.s

INCLUDES is the macro defining the project include paths. AFLAGS is
defined thus:

AFLAGS   = -gdwarf2 -marmv4t --defsym THUMB_ONLY=0

This specifies the symbolic debugger format THUMB_ONLY is a macro used
in ny C runtime startup to produce THUMB specific code, when set to non
zero.

Clifford
OP #1174335
Clifford Slocombe wrote:
> In case it is useful, my make file invokes the following commands for
> assembler file builds:
>
>   cpp $(INCLUDES) $< $(patsubst %.s, %_temp.s, $<)
>   $(AS) $(AFLAGS) $(patsubst %.s, %_temp.s, $<) -o $@
>   rm $(patsubst %.s, %_temp.s, $<)
>
> Clifford

Thanks very much Clifford.

I will try this on my code.

Regards
Vinit

Reply

A question of your own? This thread is over 18 years old. Ask it in a thread of its own – more people read along there, and it gets answered more often and sooner.

Start a new thread

A fix, an addition or feedback on this thread? Then reply here.

Formatting
  • [c]C-Code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.