Page 1 of 2
_memcpy
Posted: Tue Aug 03, 2004 8:41 am
by hElPnEeded
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..
Re:_memcpy
Posted: Tue Aug 03, 2004 8:42 am
by hElPnEeded
and, I do NOT use any memcpy function in my code or something like that
Re:_memcpy
Posted: Tue Aug 03, 2004 8:54 am
by df
is it a gcc builtin function? did you disable builtins?
Re:_memcpy
Posted: Tue Aug 03, 2004 8:59 am
by hElPnEeded
nope, how do I do that?
but I dont use it in my code..
Re:_memcpy
Posted: Tue Aug 03, 2004 11:18 am
by Solar
--no-builtin.
Re:_memcpy
Posted: Tue Aug 03, 2004 11:21 am
by hElPnEeded
How? Like this
gcc -c System.c -o System.o
Should I replace that with
gcc -c --no-builtin System.c -o System.o
Re:_memcpy
Posted: Tue Aug 03, 2004 11:26 am
by Therx
yes. my compile line is:-
gcc -c -O2 -fno-builtin -Wall -W -nostdinc -Iinclude -o file.c
Pete
Re:_memcpy
Posted: Tue Aug 03, 2004 11:28 am
by Neo
if you haven't figured it out by now, yeah thats about it
you could also use
the freestanding being another option.
Re:_memcpy
Posted: Tue Aug 03, 2004 11:28 am
by hElPnEeded
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
Posted: Tue Aug 03, 2004 11:40 am
by hElPnEeded
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)
Re:_memcpy
Posted: Tue Aug 03, 2004 12:08 pm
by hElPnEeded
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..
Re:_memcpy
Posted: Tue Aug 03, 2004 12:13 pm
by Neo
i guess we'll need to have a look at the code to help.
Re:_memcpy
Posted: Tue Aug 03, 2004 12:51 pm
by Therx
When I remove the panic (..) lines (panic is a function in the same file), I dont get the memcpy error..
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()?
Pete
Re:_memcpy
Posted: Tue Aug 03, 2004 1:02 pm
by hElPnEeded
The code for the panic:
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");
}
The code for the struct
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
Posted: Tue Aug 03, 2004 1:58 pm
by bkilgore
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.