_memcpy
_memcpy
Today I changed some stuff in my OS, so that an ASM-handler calls a C handler and pushes some arguments. I know the code is working (cause the error only occured when I changed this for lots of functions). I get this error:
Exceptions.o(.text+0x15a):Exceptions.c: undefined reference to `_memcpy'
I?ve had trouble with this before and I?ve forgotten how to get around this. Must be something with the linker..
Exceptions.o(.text+0x15a):Exceptions.c: undefined reference to `_memcpy'
I?ve had trouble with this before and I?ve forgotten how to get around this. Must be something with the linker..
Re:_memcpy
How? Like this
gcc -c System.c -o System.o
Should I replace that with
gcc -c --no-builtin System.c -o System.o
gcc -c System.c -o System.o
Should I replace that with
gcc -c --no-builtin System.c -o System.o
Re:_memcpy
yes. my compile line is:-
gcc -c -O2 -fno-builtin -Wall -W -nostdinc -Iinclude -o file.c
Pete
gcc -c -O2 -fno-builtin -Wall -W -nostdinc -Iinclude -o file.c
Pete
Re:_memcpy
if you haven't figured it out by now, yeah thats about it
you could also use the freestanding being another option.
you could also use
Code: Select all
-ffreestanding -fno-builtin
Only Human
Re:_memcpy
I dont get it, why does the linker try to use memcpy (when my code doesnt?). really need help with this (cant run/modify my OS right now)
Re:_memcpy
it doesnt work.. I use this now:
gcc -c -ffreestanding -fno-builtin Exceptions.c -o Exceptions.o
but no, same error (I use the -ffrestanding / fnobultin for all files I compile)
gcc -c -ffreestanding -fno-builtin Exceptions.c -o Exceptions.o
but no, same error (I use the -ffrestanding / fnobultin for all files I compile)
Re:_memcpy
can tell you something more.. my exceptionhandlers(called from the asm-written ISR) looks like this:
void int_00(exception_descriptor status)
{
panic("Divide By Zero Error", status);
}
void int_01(exception_descriptor status)
{
panic("Debug Error", status);
}
...
when I remove the panic (..) lines (panic is a function in the same file), I dont get the memcpy error..
void int_00(exception_descriptor status)
{
panic("Divide By Zero Error", status);
}
void int_01(exception_descriptor status)
{
panic("Debug Error", status);
}
...
when I remove the panic (..) lines (panic is a function in the same file), I dont get the memcpy error..
Re:_memcpy
Ah. Maybe GCC is trying to use memcpy to pass one of the arguments. If the "exception_descriptor" structure is too big maybe GCC has decided it won't fit on the stack? What is the code for panic()?When I remove the panic (..) lines (panic is a function in the same file), I dont get the memcpy error..
Pete
Re:_memcpy
The code for the panic:
The code for the struct
Code: Select all
void panic(char *message, char *code, exceptions_descriptor status)
{
printf("\nAn Exception has occured\n%s at EIP=%i\n", WHITE_TXT, 2, message, status.eip);
printf("eax=%i ebx=%i ecx=%i edx=%i esi=%i edi=%i ebp=%i esp=%i\n", WHITE_TXT, 8, status.regs[0],status.regs[1],status.regs[2],status.regs[3],status.regs[4], status.regs[5], status.regs[6], status.regs[7]);
printf("Error Code=%i\ncs register=%i\n", WHITE_TXT, 1, status.errcode, status.cs);
print("System halted\n", RED_TXT);
enableInt(false);
asm("hlt");
}
Code: Select all
struct exception_descriptor{
unsigned long gs, fs, es, ds;
unsigned long regs[8]; // eax, ecx, edx, ebx and friends.
unsigned long errcode;
unsigned long eip;
unsigned long cs;
unsigned long eflags;
}__attribute__ ((packed));
typedef struct exception_descriptor exception_descriptor;
so the struct is 64 bytes..
Re:_memcpy
Why not just pass it by pointer instead of copy? If that doesn't fix it, attach your exceptions.c file so we can take a look.