Closed Mousavikia closed 1 year ago
And my second question is following: I have changed the simple code and added some malloc and free functions but even after adding
void *memcpy(void *dest, const void *src, size_t n)
{
for (size_t i = 0; i < n; i++)
{
((char*)dest)[i] = ((char*)src)[i];
}
}
which was the corrrect form of memcpy for my code at least I got this errors:
undefined reference to malloc
or undefined reference to free
I added version of sbrk for baremetal systems and .end at the end of .bss section of my linker but the errors are still there:
/* Version of sbrk for no operating system. */
void*
_sbrk(incr)
int incr;
{
extern char end; /* Set by linker. */
static char* heap_end;
char* prev_heap_end;
if (heap_end == 0)
heap_end = &end;
prev_heap_end = heap_end;
heap_end += incr;
return (void*)prev_heap_end;
}
Your link command is using -nostdlib
so no standard C library is being linked so no implementation of memcpy()
and other standard library functions is available. You should look at the GCC documentation about this option.
https://gcc.gnu.org/onlinedocs/gcc-11.2.0/gcc/Link-Options.html#Link-Options
Not a RISC-V GCC toolchain issue.
Hi and sorry it will be long question... I have installed Vector version of RiscV gnu toolchain with following setups:
And here is my makefile and linker file:
I have compiled a simple code with this setups and first after running make I got following error: I searched the internet and I found two pices of code that could handle this error: one is this:
And second one:
both of them cleared the error but first one with correct output and second one with different (wrong) output... How can I handle this problem? I even added -lc and -lgcc in linker:
but I get this error now:
Sorry it is very long but I am really confused right now...