This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gcc doubts


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
        


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]