osdev

undefined reference to `_GLOBAL_OFFSET_TABLE_' in gcc 32-bit code for a trivial function, freestanding OS

回眸只為那壹抹淺笑 提交于 2020-01-24 15:05:27
问题 I have a small c code file(function.c): int function() { return 0x1234abce; } I am using a 64 bit machine. However, I want to write a small 32 bit OS. I want to compile the code into a 'pure' assembly/binary file. I compile my code with: gcc function.c -c -m32 -o file.o -ffreestanding # This gives you the object file I link it with: ld -o function.bin -m elf_i386 -Ttext 0x0 --oformat binary function.o I am getting the following error: function.o: In function `function': function.c:(.text+0x9)

undefined reference to `_GLOBAL_OFFSET_TABLE_' in gcc 32-bit code for a trivial function, freestanding OS

耗尽温柔 提交于 2020-01-24 15:04:51
问题 I have a small c code file(function.c): int function() { return 0x1234abce; } I am using a 64 bit machine. However, I want to write a small 32 bit OS. I want to compile the code into a 'pure' assembly/binary file. I compile my code with: gcc function.c -c -m32 -o file.o -ffreestanding # This gives you the object file I link it with: ld -o function.bin -m elf_i386 -Ttext 0x0 --oformat binary function.o I am getting the following error: function.o: In function `function': function.c:(.text+0x9)

How to implement Dynamically Growing Heap

安稳与你 提交于 2020-01-16 12:18:51
问题 Finished implementing the minimal Heap structure with awesome help from Micheal . Right now I have one thing missing so it dynamically grows. As you can see in this image, it isn't dynamic: Instead of having a fixed size when I do pmm_map_physical_virtual(0x800000,0xC0800000) , the max I can go to is 8MB which is from 0xC00000000-0xC0800000 ... but then I have to be aware not to overwrite the kernel, so I will technically have less than 8MB . Is there a way so that the heap just continues

How to implement Dynamically Growing Heap

青春壹個敷衍的年華 提交于 2020-01-16 12:18:51
问题 Finished implementing the minimal Heap structure with awesome help from Micheal . Right now I have one thing missing so it dynamically grows. As you can see in this image, it isn't dynamic: Instead of having a fixed size when I do pmm_map_physical_virtual(0x800000,0xC0800000) , the max I can go to is 8MB which is from 0xC00000000-0xC0800000 ... but then I have to be aware not to overwrite the kernel, so I will technically have less than 8MB . Is there a way so that the heap just continues

How to implement Dynamically Growing Heap

蹲街弑〆低调 提交于 2020-01-16 12:18:33
问题 Finished implementing the minimal Heap structure with awesome help from Micheal . Right now I have one thing missing so it dynamically grows. As you can see in this image, it isn't dynamic: Instead of having a fixed size when I do pmm_map_physical_virtual(0x800000,0xC0800000) , the max I can go to is 8MB which is from 0xC00000000-0xC0800000 ... but then I have to be aware not to overwrite the kernel, so I will technically have less than 8MB . Is there a way so that the heap just continues

How to implement Dynamically Growing Heap

无人久伴 提交于 2020-01-16 12:17:34
问题 Finished implementing the minimal Heap structure with awesome help from Micheal . Right now I have one thing missing so it dynamically grows. As you can see in this image, it isn't dynamic: Instead of having a fixed size when I do pmm_map_physical_virtual(0x800000,0xC0800000) , the max I can go to is 8MB which is from 0xC00000000-0xC0800000 ... but then I have to be aware not to overwrite the kernel, so I will technically have less than 8MB . Is there a way so that the heap just continues

“times 510-($-$$) db 0” does not work

天涯浪子 提交于 2020-01-13 20:32:12
问题 I am learning about boot sectors. I downloaded nasm-installer-x64.exe from the NASM website. My operating system is win7-64bit. When I run the following code it does not work correctly mov ah, 0x0e; mov al, the_secret; int 0x10; mov al, [the_secret]; int 0x10; mov bx, [the_secret]; add bx, 0x7c00; mov al, [bx]; int 0x10; mov al, [0x7c1e]; int 0x10; jmp $; the_secret:; db 'X'; times 510-($-$$) db 0; dw 0xaa55; 回答1: I don't believe there is anything wrong with times 510-($-$$) db 0 . It seems

“times 510-($-$$) db 0” does not work

和自甴很熟 提交于 2020-01-13 20:27:39
问题 I am learning about boot sectors. I downloaded nasm-installer-x64.exe from the NASM website. My operating system is win7-64bit. When I run the following code it does not work correctly mov ah, 0x0e; mov al, the_secret; int 0x10; mov al, [the_secret]; int 0x10; mov bx, [the_secret]; add bx, 0x7c00; mov al, [bx]; int 0x10; mov al, [0x7c1e]; int 0x10; jmp $; the_secret:; db 'X'; times 510-($-$$) db 0; dw 0xaa55; 回答1: I don't believe there is anything wrong with times 510-($-$$) db 0 . It seems

When I modify code the disk image becomes unbootable

浪尽此生 提交于 2020-01-07 09:16:11
问题 I'm developing an operating system in assembly language. When making changses o the code the output file isn't seen as bootable. This is my code: BITS 16 start: mov ax, 07C0h ; Set up 4K stack space after this bootloader add ax, 288 ; (4096 + 512) / 16 bytes per paragraph mov ss, ax mov sp, 4096 mov ax, 07C0h ; Set data segment to where we're loaded mov ds, ax call cls MOV AH, 06h ; Scroll up function XOR AL, AL ; Clear entire screen XOR CX, CX ; Upper left corner CH=row, CL=column MOV DX,

When I modify code the disk image becomes unbootable

为君一笑 提交于 2020-01-07 09:14:32
问题 I'm developing an operating system in assembly language. When making changses o the code the output file isn't seen as bootable. This is my code: BITS 16 start: mov ax, 07C0h ; Set up 4K stack space after this bootloader add ax, 288 ; (4096 + 512) / 16 bytes per paragraph mov ss, ax mov sp, 4096 mov ax, 07C0h ; Set data segment to where we're loaded mov ds, ax call cls MOV AH, 06h ; Scroll up function XOR AL, AL ; Clear entire screen XOR CX, CX ; Upper left corner CH=row, CL=column MOV DX,