Hightech Compiler Linking Error (related to libos library)

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Hedi
Level 1
Level 1
First reply posted First question asked Welcome!

Hello i was working on a migration from eclipse CDT build environment to a CMake build environment.

after building all the files in my project (Big project) i reached the linking step and i have the following error:

"....tricore/lib/tc161\libos.a(libos_sbrk.o):(.data+0x0): error: undefined reference to `__HEAP'"
 
From what i understood the project is using this library, and the linker has automatically linked it to my binary. Inside this library there is a variable (external variable) in the file "libos_sbrk.c" called __HEAP, but there is no actual definition for it.
 
The __HEAP variable is declared in a linker script inside the compiler's folder. Here i'm not sure what to do or how to solve this dependency ?
 
Can anyone help ?
 
Thanks in advance.
0 Likes
1 Solution
Di_W
Moderator
Moderator
Moderator
500 solutions authored 1000 replies posted 250 solutions authored

Hi Hedi, 

I have found libos_sbrk.c in my project.

C:\HighTec\toolchains\tricore\v4.9.3.0-infineon-1.0\tricore\libos.src\

And in Lcf_Gnuc_Trico.lsl, I do found 4k HEAP define.

Have you successfuly BUILD the project in BIFACES  with Hightec? If so, then you could refer the BIFACES's settings, i.e. *.mk *.lsl ...

 

    .heap  : FLAGS(aw)
    {
    . = ALIGN(4);
    __HEAP = .;
    . += LCF_HEAP_SIZE;
    __HEAP_END = .;
    } > default_ram

 

View solution in original post

0 Likes
5 Replies
Di_W
Moderator
Moderator
Moderator
500 solutions authored 1000 replies posted 250 solutions authored

Hi Hedi, 

I have found libos_sbrk.c in my project.

C:\HighTec\toolchains\tricore\v4.9.3.0-infineon-1.0\tricore\libos.src\

And in Lcf_Gnuc_Trico.lsl, I do found 4k HEAP define.

Have you successfuly BUILD the project in BIFACES  with Hightec? If so, then you could refer the BIFACES's settings, i.e. *.mk *.lsl ...

 

    .heap  : FLAGS(aw)
    {
    . = ALIGN(4);
    __HEAP = .;
    . += LCF_HEAP_SIZE;
    __HEAP_END = .;
    } > default_ram

 

0 Likes
Di_W
Moderator
Moderator
Moderator
500 solutions authored 1000 replies posted 250 solutions authored
# Make-rule to build: elf
$(B_GEN_ELF_TRICORE_TC): $(B_GEN_OBJS_TRICORE_TC) $(B_GEN_CUSTOBJS_TRICORE_TC) $(B_GEN_LCF_FILE_TRICORE_TC) $(B_GEN_CONFIG_TRICORE_GNUC)
	@mkdir -p $(@D)
	@-rm -f $@
	@echo 'Building output $(B_GEN_ELF_TRICORE_TC)'
	$(B_GEN_TRICORE_GNUC_LD) $(B_GNUC_TRICORE_LD_OPTIONS) -Wl,-T $(B_GEN_LCF_FILE_TRICORE_TC) -Wl,-Map=$(@:.elf=.map) -Wl,--extmap=a @$(B_GEN_OBJLIST_FILE_TRICORE_TC) $(B_GEN_CUSTOBJS_TRICORE_TC) $(B_GNUC_TRICORE_LIB_INC) $(B_GNUC_TRICORE_LIBS) -o $@

# Make-rule to build: hex
$(B_GEN_HEX_TRICORE_TC): $(B_GEN_ELF_TRICORE_TC) $(B_GEN_CONFIG_TRICORE_GNUC)
	@mkdir -p $(@D)
	@-rm -f $@
	@echo 'Building output $(B_GEN_HEX_TRICORE_TC)'
	$(B_GEN_TRICORE_GNUC_HEX) $< -O ihex $@@

above code is in project.mk

0 Likes
Hedi
Level 1
Level 1
First reply posted First question asked Welcome!

Hi dw,

Thanks for you answer. What is BIFACES ?

The same project that i have was building using the Hightech CDT integrated in eclipse, it was generating the makefiles automatically, but i wanted to have a CMake build environment so i used the same compiler and same linker_script but i got this dependency to a built-in library.

The linker command that i use is pretty similar to what you mentioned here.

as far as i know the same linker script that does not define the __HEAP symbol should work in both environment.

does the options order matter, when invoking the linker ?

0 Likes
Prudhvi_E
Moderator
Moderator
Moderator
250 replies posted 100 solutions authored 25 likes received

Hi Hedi,

The library libos.a expects that __HEAP is defined in the Linker file with a defined memory range & size. You could define the same in the linker file taking reference from what dw mentioned above. This should fix the issue.

Regards,

Prudhvi.

0 Likes