login
Header Space

 
 

help with gcc

May 17, 2007 - 4:40pm
Submitted by AaronCloyd on May 17, 2007 - 4:40pm.
Applications and Utilities

When compiling with the -S flag, I need to be able to modify what gets written. As a first step I'd like to be able to just print out "Hello World!" somewhere in the main.s file.
I know I need to modify some gcc code and recompile gcc, but I'm having trouble finding the file that I need to change.
Any help would be great.
Thank you.

What?

May 17, 2007 - 5:25pm
Anonymous (not verified)

It's not clear to me what you're trying to do...

Do you want to modify gcc so that it outputs different assembler code?

Or do you want to modify the assembler code created by gcc, then assemble it?

Either way, I don't really see why you would need to modify the gcc source code.

To modify assembler code created by gcc on the fly:

gcc -S hello.c -o - | sed 's/Hello, world/Goodbye, cruel world/' > hello.s

(That was hard, wasn't it?)

To modify and assemble asm code created by gcc:

gcc -S hello.c -o hello.s
vi hello.s              # edit hello.s
as hello.s -o hello.o   # assemble with the gnu assembler
gcc hello.o -o hello    # link
./hello

clarification

May 17, 2007 - 6:08pm

I want to add code to the source code of gcc, then recompile gcc, so that it outputs different assebly code with no flags ( other than -S). This is part of a bigger project and I figured a good first step would be being able to insert a line into the assembly code. Thanks.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
speck-geostationary