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

See the CrossGCC FAQ for lots more infromation.


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

linker scripts & section names & more


Hi all,

I have decided to optimise my linker script and while doing so started
wondering what all these section names are for and other symbols and
commands. I am using GCC 2.91.66 (ecgs 1.1.2) for M68K-COFF.  My program
is a C only application (no C++). I have found that my program does not
seem to use most of the section names that were defined in my linker
script and worked fine without them. However I would like to know
more...

What is placed into the following sections (my guesses in brackets -
even then I dont really know what my guesses mean!)

    .shbss             (short bss?)
    .shdata            (short data?)
    .rodata            (read only data?)
    .ctors              (C++ constructor stuff?)
    .dtors              (C++ destructor stuff?)
    .init                 (initialisers?)
    .fini                  (finalisers?)
    .gcc_except_table    (exception table?)
    .eh_frame        (exception handler frame?)
    .eh_fram         (alternate exception handler frame?)
    .lit                    (literals?)
    .stab                (debugging stuff)
    .stabstr             (more debugging stuff?)

Other sections that I do use and think I understand are
    .data - initialised data
    .bss - uninitialised data
    .text - code
    COMMON - common symbols - global variables - I dont really
understand why something is COMMON as apposed to .data or .bss.
Especially if the variables concerned are in the C source code. Reading
the GCC/LD manuals on this has not really helped me understand it.

Is there any reference somewhere that describes these? I have looked at
GCC and LD manuals. Also crossgcc FAQ and porting GCC document. I
thought I may have seen some info on this in the past but now cannot
find any references. Any help here most appreciated.

Also what does  '__DYNAMIC = 0 ' really mean? The only reference I found
says it means that my program does not use shared libraries.

What does the following fragment from the linker script actual do? It
appears to allow the execution of some init code by calling
__INIT_SECTION__ somehow.

    __INIT_SECTION__ = . ;
    LONG (0x4e560000) /* linkw %fp,#0 */
    *(.init)
    SHORT (0x4e5e) /* unlk %fp */
    SHORT (0x4e75) /* rts */

    __FINI_SECTION__ = . ;
    LONG (0x4e560000) /* linkw %fp,#0 */
    *(.fini)
    SHORT (0x4e5e) /* unlk %fp */
    SHORT (0x4e75) /* rts */

Am I correct in assuming that I do not need the following fragment if
not using C++?

     __CTOR_LIST__ = .;
    LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2)
    *(.ctors)
    LONG(0)
    __CTOR_END__ = .;
    __DTOR_LIST__ = .;
    LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2)
    *(.dtors)
     LONG(0)
    __DTOR_END__ = .;

TIA
Dave.


------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com


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