cancel
Showing results for 
Search instead for 
Did you mean: 

GNU compiler

ezanen9
Associate II
Posted on August 26, 2005 at 05:19

GNU compiler

22 REPLIES 22
ben2
Associate II
Posted on August 23, 2005 at 11:24

the options being passed to the linker set the path. arm-elf-ld probably has a default search path or according the the man page a link script.

the -L sets a path to look for libraries. you can have more than 1. e.g -Lc:/gnuarm/lib

the -l (small L) tells the linker which libraries you want to include. For libraries you dont specifiy the ''lib'' or ''.a'' part, so to use libgcc.a you use -lgcc.

What is the contents of the Example.ld file ? this may list additional paths or libraries.

Looking at the output of the linker it would appear to not be using the options you have added. I dont know why that is, unless it is picking the options for someplace else.

ezanen9
Associate II
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) }

}

ben2
Associate II
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).

ezanen9
Associate II
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,

ben2
Associate II
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 ?

ezanen9
Associate II
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,

ben2
Associate II
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.

sjo
Associate II
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

ezanen9
Associate II
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

ben2
Associate II
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.