Re: About gcc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Anticipating a Reply wrote:

>   Thank you for the information given by
> you . It would be more helpful if you
> could let me know if there is some document
> which helps me interpret & understand the
> " spec " file and tells how it is used
> by gcc .

GNU toolchain stuff is unfortunately oft rather under- and/or obscurely 
documented. In this case, the documentation lives in the GCC source. In 
my gcc-3.2 tree, this "spec language" is described/defined in a large 
comment in gcc/gcc.c.

Fortunately it's not a hard language. Let's take the *link spec 
including that -rdynamic as an example:

===
*link:
-m elf_i386 %{shared:-shared} %{!shared: %{!ibcs: %{!static:        
%{rdynamic:-export-dynamic} %{!dynamic-linker:-dynamic-linker 
/lib/ld-linux.so.2}} %{static:-static}}}
===

This spec only uses the "%{S:X}" and "%{!S:X}" constructs. Translating 
it into 'conventional pseudo-language' would give something like:

===
link = "-m elf_i386"

IF option("-shared") THEN
    link += " -shared"
ENDIF

IF NOT option("-shared") THEN
    IF NOT option("-ibcs") THEN
        IF NOT option("-static") THEN
            IF option("-rdynamic") THEN
                link += " -export-dynamic"
            ENDIF
            IF NOT option("-dynamic-linker") THEN
                link += " -dynamic-linker /lib/ld-linux.so.2"
            ENDIF
        ENDIF
        IF option("-static") THEN
            link += " -static"
        ENDIF
    ENDIF
ENDIF
===

As to how this *link spec is then used; look at the *link_command spec 
in the gcc specfile. Specs can be substituted into one another using 
the "%(...)" language-construct, and you will see the *link_command 
spec incorporating for example the *linker spec by specifying 
"%(linker)". The *link spec is special in that the language knows about 
it internally: it's pulled in simply by "%l".

GCC then uses the *link_command spec directly as the command to run the 
linker. See gcc-3.2/gcc/gcc.c:main(), near the end:

value = do_spec (link_command_spec);

Hope this helps.

Rene.

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux