gcc doubts
Nick Clifton
nickc@redhat.com
Sat Oct 4 10:27:00 GMT 2003
Hi Dennis,
> I'm a beginner in gcc and have some doubts.Please clear.
I strongly recommend reading the documentation available on the GCC
and Binutils websites.
> Please suggest the syntax for the command line switch to compile a
> C program to obtain a elf output.
gcc -c <name-of-C-source-file>
> Can I specify the name of the output file?
Yes:
gcc -c <name-of-C-source-file> -o <name-of-object-file>
For example:
gcc -c foo.c -o foo.o
> Also specify the ld option to link more than one elf file to
> obtain a big elf file.
gcc <first-object-file> <second-object-file> <etc>
For example:
gcc foo.o bar.o fred.o jim.o
If you want to specify the name of the big elf file use the -o option
like this:
gcc foo.o bar.o fred.o jim.o -o my_program
> How should I specify my new linker script. In the info page it is
> written that the option -t may be used. Is it necessary that the
> script file must have a specific extension?
No, any (or no) extension can be used. Please note however that the
switch is -T not -t. The linker's switches are case sensitive. Also,
if you are using gcc to driver the linker (as suggested above) then
you need to use the -Wl switch to pass the -T switch on to the linker,
like this:
gcc -Wl,-T -Wl,scriptfilename foo.o bar.o fred.o jim.o -o my_program
Cheers
Nick
More information about the Binutils
mailing list