Skip to main content
Visitor II
August 26, 2005
Question

GNU compiler

  • August 26, 2005
  • 22 replies
  • 3188 views
Posted on August 26, 2005 at 05:19

GNU compiler

    This topic has been closed for replies.

    22 replies

    ezanen9Author
    Visitor II
    August 23, 2005
    Posted on August 23, 2005 at 11:33

    I copy/paste the contense op the Example.ld file below:

    ***************************************************************************/

    SEARCH_DIR( ''C:\Program Files\Hitex\GnuToolPackageArm\arm-elf\lib'' )

    /*******************************************

    Define Files

    *******************************************/

    GROUP ( objects\startup.o

    objects\main.o

    objects\interrupt.o )

    /*******************************************

    Memory Definitions

    *******************************************/

    MEMORY

    {

    IntCodeRAM (rx) : ORIGIN = 0x00000000, LENGTH = 32K

    IntDataRAM (rw) : ORIGIN = 0x20008000, LENGTH = 32k

    }

    /*******************************************

    Section Definitions

    *******************************************/

    SECTIONS

    {

    /*******************************************/

    .text :

    {

    __code_start__ = .;

    objects\startup.o (.text) /* Startup code */

    objects\*.o (.text)

    . = ALIGN(4);

    __code_end__ = .;

    *(.glue_7t) *(.glue_7)

    } >IntCodeRAM =0

    . = ALIGN(4);

    /* .rodata section which is used for read-only data (constants) */

    .rodata . :

    {

    *(.rodata)

    } >IntCodeRAM

    . = ALIGN(4);

    _etext = . ;

    PROVIDE (etext = .);

    /*******************************************/

    .data : AT (_etext)

    {

    /* used for initialized data */

    __data_start__ = . ;

    PROVIDE (__data_start__ = .) ;

    *(.data)

    SORT(CONSTRUCTORS)

    __data_end__ = . ;

    PROVIDE (__data_end__ = .) ;

    } >IntDataRAM

    . = ALIGN(4);

    _edata = . ;

    PROVIDE (edata = .);

    /*******************************************/

    .bss :

    {

    /* used for uninitialized data */

    __bss_start = . ;

    __bss_start__ = . ;

    *(.bss)

    . = ALIGN(4);

    __bss_end__ = . ;

    } >IntDataRAM

    .bss2 :

    {

    /* used for uninitialized data */

    __bss2_start = . ;

    __bss2_start__ = . ;

    *(COMMON)

    . = ALIGN(4);

    __bss2_end__ = . ;

    } >IntDataRAM

    /*******************************************/

    _end = .;

    PROVIDE (end = .);

    /*******************************************/

    .comment 0 : { *(.comment) }

    /* DWARF debug sections.

    Symbols in the DWARF debugging sections are relative to the beginning

    of the section so we begin them at 0. */

    /* DWARF 1 */

    .debug 0 : { *(.debug) }

    .line 0 : { *(.line) }

    /* GNU DWARF 1 extensions */

    .debug_srcinfo 0 : { *(.debug_srcinfo) }

    .debug_sfnames 0 : { *(.debug_sfnames) }

    /* DWARF 1.1 and DWARF 2 */

    .debug_aranges 0 : { *(.debug_aranges) }

    .debug_pubnames 0 : { *(.debug_pubnames) }

    /* DWARF 2 */

    .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }

    .debug_abbrev 0 : { *(.debug_abbrev) }

    .debug_line 0 : { *(.debug_line) }

    .debug_frame 0 : { *(.debug_frame) }

    .debug_str 0 : { *(.debug_str) }

    .debug_loc 0 : { *(.debug_loc) }

    .debug_macinfo 0 : { *(.debug_macinfo) }

    }

    Visitor II
    August 23, 2005
    Posted on August 23, 2005 at 11:39

    Ok the SEARCH_DIR statement at the top sets where the linker is looking for the libraries. is libgcc.a in that directory ?

    If not try adding it to the end, probably seperated by a colon although not sure on that.

    But unless it gets passed to the linker on the command line (-lgcc) it shouldnt include the library. You need to get the -lgcc option to appear on the linker output. Perhpas try setting the option, saving everything and restarting the IDE. Perhaps it only checks the option when it runs (not very good if it does).

    ezanen9Author
    Visitor II
    August 23, 2005
    Posted on August 23, 2005 at 13:14

    I have tried changing the settings>linker option and changing the make file but nothing works.

    I just can't find the right option to set:-(

    In the buid report the lgcc is still missing. Do you have an explanation for the fact that I can use the *(multiply) sign in my C program but not the divide / sign?

    Thanks for your help till now,

    Visitor II
    August 23, 2005
    Posted on August 23, 2005 at 13:38

    yes the multiply does not need the gcc library.

    Do you have cygwin installed ? I would assume you do, in which case

    you could run make with a makeifle from a console window.

    Sounds to me like it is a problem with the IDE.

    Do you have any support available for it ?

    ezanen9Author
    Visitor II
    August 24, 2005
    Posted on August 24, 2005 at 06:24

    I finally found the option to include the libgcc.a library. The problem is that with installing the GNUToolpackage for ARM there are a lot of different libgcc.a files in different folders(default not in the target directory). All of them are different in size. I tried all of them by placing them (alone) in the target directory. Still the same error:

    arm-elf-ld.exe --cref -t -static -lc -lm -lgcc -Map=Example.map -o .\objects\Example.elf -T.\objects\Example.ld

    objects\main.o(.text+0x2f4): In function `main':

    source/main.c:273: undefined reference to `__divsi3'

    arm-elf-ld: link errors found, deleting executable `.\objects\Example.elf'

    But as you can see it does include the libgcc library. I checked this by placing none libgcc.a in the target directory. The copiling error than say's:

    arm-elf-ld.exe --cref -t -static -lc -lm -lgcc -Map=Example.map -o .\objects\Example.elf -T.\objects\Example.ld

    arm-elf-ld: cannot find -lgcc

    arm-elf-ld: mode armelf

    So it does include it. It's strange that I still have the error. Could it be that I do not have the proper version of the libgcc.a file? Because it was't default in the target directory. Or do I mis some other option?

    Regards,

    Visitor II
    August 24, 2005
    Posted on August 24, 2005 at 06:38

    Did you modify the SEARCH_DIR statement in example.ld to include the extra path ?

    The extra copies of the libraries depend on how you are compiling.

    e.g thumb directory has the libraries if you are using thumb mode.

    From the output you included earlier it looks like you are using thumb-interwork mode so you should probably use libraries in the interwork directory.

    ***** from man page ******

    The paths can also be specified in a link script with the

    ''SEARCH_DIR'' command. Directories specified this way are searched

    at the point in which the linker script appears in the command

    line.

    you may also try moving the ''-T.\objects\Example.ld'' to before the library include if you can, as the man page for the linker implies that it matters. Alternativly you could add a -L with path otpion.

    Visitor II
    August 24, 2005
    Posted on August 24, 2005 at 06:43

    Is there any reason why you call ld directly, normally this is done via gcc which will use the correct libs etc (collect2 normally does this function).

    Regards

    sjo

    ezanen9Author
    Visitor II
    August 24, 2005
    Posted on August 24, 2005 at 08:02

    The .LD file now contains:

    SEARCH_DIR( ''C:\Program Files\Hitex\GnuToolPackageArm\arm-elf\lib'' )

    SEARCH_DIR( ''C:\Program Files\Hitex\GnuToolPackageArm\lib\gcc-lib\arm-elf\3.3.2\thumb\interwork'' )

    and the complier finds the lidgcc.a file. I tied again directing to all de different libgcc library's but still the same error.

    In the linker option box I filled in:

    --cref -t -static -lc -lm -lgcc -Map=Example.map

    If I look in the C-compiler .map file the compiler find the library.

    I friend and someone form Hitex(IDE manufacturer) told me dat the order of the text filled in in the linker option box matters.

    They told me that the -lgcc should be somewere at the end. Well I tried it on every place in the sentence but still the same error.

    I do not know were ''-T.\objects\Example.ld'' stands for and I don't have an option to move it.

    think that the problem is no longer in the PATH because the compiler does find the library(if I remove it from the taget directory, I receive a compiler error)

    The problem is to find the proper library or the order of linking.

    Regards,

    Jim

    Visitor II
    August 24, 2005
    Posted on August 24, 2005 at 08:17

    assuming you can place options for the linker you could try putting

    -L C:\Program Files\Hitex\GnuToolPackageArm\lib\gcc-lib\arm-elf\3.3.2\thumb\interwork

    before the other options and not include it in SEARCH_DIR.

    in my makefile the order of including libraries is -lc -lgcc -lm -lg

    I am specifing the paths before these.

    according to the man page you can use -( c gcc m -) format instead of the -l format. by using the -( -) format the linker will keep searching through the libraries until it finds all symbols, no matter the order. However this does mean that linking can take alot longer longer.

    If you specify the libraries using the -l option they are searched only once in the order they are specified.

    ezanen9Author
    Visitor II
    August 24, 2005
    Posted on August 24, 2005 at 13:43

    Hi, in the .LD file I can put any location to locate the libgcc.a. I now putted there:

    SEARCH_DIR( ''C:\Program Files\Hitex\GnuToolPackageArm\arm-elf\lib'' )

    SEARCH_DIR( ''C:\Program Files\Hitex\GnuToolPackageArm\lib\gcc-lib\arm-elf\3.3.2\thumb\interwork'' )

    I think this works because if I remove the libraries from these folders I get compiler error: ''missing -lgcc'' etc.

    But this does not solve my problem.

    I have no option to put sentence in:

    -L C:\Program Files\Hitex\GnuToolPackageArm\lib\gcc-lib\arm-elf\3.3.2\thumb\interwork

    I also implemented your order of including the libraries. I also specified to the thumb/interwork paths. No effect:-(

    All the (GNU) experts of Hitex are on vacation, but they promised me that I can speak to someone who knows 'something'' about it tomorrow. I really he knows the problem.

    I really appreciate your work till now, thanks,

    To be continued............