linker scripts & section names & more

David Williams
Wed Jul 19 21:59:00 GMT 2000

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

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 */
    SHORT (0x4e5e) /* unlk %fp */
    SHORT (0x4e75) /* rts */

    __FINI_SECTION__ = . ;
    LONG (0x4e560000) /* linkw %fp,#0 */
    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)
    __CTOR_END__ = .;
    __DTOR_LIST__ = .;
    LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2)
    __DTOR_END__ = .;


Want more information?  See the CrossGCC FAQ,
Want to unsubscribe? Send a note to

More information about the crossgcc mailing list