1

I have checked the assembler options of GNU assembler as and I didn't find an option to specify the output object file format. If I am using the following command

as -o foobar.o foobar.s

What object file format will I get?

The as manual says that "The GNU as can be configured to produce several alternative object file formats." But how? How can I change it to a ELF format?

Many thanks.

2 Answers 2

2

On linux the output from gas is ELF already, it is unlikely you have a version which is building the old a.out format, or that you are using a cross compiler to say build to MachO or PE.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks tyranid. I noticed that I can specify differnt object file formats when using the "NASM" assembler. It seems the GNU "as" is not as good as NASM in this aspect. I have to use the "objcopy" to change the object file format. Is there some more direct approach with the "as"?
I don't think you can do directly, you would always have to use objcopy.
0

Use a cross-compiler for specific formats (ARM,MIPS etc.)

Get the entire CODESOURCERY toolchain here for free:

www.codesourcery.com/sgpp/lite_edition.html

GoodLUCK!!

1 Comment

Thansk CVS26. I am not making a cross compiling. I386 is my target. I will give it a try, if i am desperate enough...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.