0

I am trying to link a c file for my custom kernel and I keep getting this error. This is my c file:

#include <string.h>
#define TRUE 1
#define FALSE 0

void main() {
    char vmem_back_buffer[3932160];
    char** vmem_descriptor = (char**)0x00008128;

    for(int i = 0; i < 1280*1024*3; ++i) {
        vmem_back_buffer[i] = 0xfb;
        vmem_back_buffer[i++] = 0xfb;
        vmem_back_buffer[i++] = 0xfb;
    }

    memcpy(*vmem_descriptor, vmem_back_buffer, 3932160);

    while(TRUE) {
        int i = 1;
    }
}

And here is how I compile and link

gcc -m32 -fno-pie -ffreestanding  -c src/kernel.c -o bin/kernel.o
ld   -m elf_i386 -o bin/kernel.bin -T src/linker.l bin/kernel_entry.o bin/kernel.o --oformat binary

I have uninstalled and installed different c library packages, tried to include stuff like crti.o as many sources online recommend, among other things.

What am I doing wrong?

Cal W
  • 167
  • 1
  • 14
  • none of the included libraries contain the definition of `memcpy` – Alex Lop. Sep 13 '20 at 16:30
  • 3
    You are writing a kernel and doing it freestanding. The C library isn't available. You will need to implement/provide your own `memcpy` . – Michael Petch Sep 13 '20 at 16:30
  • Thanks. I was not aware you could not use other libraries. Made the mistake of copy-pasting those command options without understanding them – Cal W Sep 13 '20 at 17:50

0 Answers0