I'm using GRUB to boot and expect it to boot me into protected mode, but it looks like it's booting me into long mode.
I ran my operating system on a virtual machine with 5120 megabytes of RAM and got this output:
THIS INT32 OUTPUT SECTION
ram_available = 1073282048 bytes
ram_available = 1023 MB
THIS UINT32 OUTPUT SECTION
ram_available = 1073282048 bytes
ram_available = 1023 MB
It is obvious that I get such numbers because of variable overflow, but I expected to see 4 GB because in protected mode it is no longer available. In the end, you can see that all 5 GB are indexed but they are not impossible to remove.
I tried using uint64_t to implement the char* itoaUINT64(uint64_t value, char* result, int base); function, but got a compilation error: Undefined reference to '__divdi3'.
-static-libgcc -lgcc not help.
Source code here
gcc args here in string №73
itoaUINT64() here
How do I solve this problem?
Unclear in what mode I work and how to use uint64_t
-
Octocontrabass
- Member

- Posts: 6280
- Joined: Mon Mar 25, 2013 7:01 pm
Re: Unclear in what mode I work and how to use uint64_t
If you use PAE, you can access all memory even in protected mode.mrjbom wrote:It is obvious that I get such numbers because of variable overflow, but I expected to see 4 GB because in protected mode it is no longer available.
All code compiled with GCC must be linked with libgcc. You can do that by changing line 94 to use GCC instead of LD for linking, and adding "-lgcc" to the command line after your object files. (You may also need to add ./i386-elf-4.9.1-Linux-x86_64/bin/ to your $PATH.)mrjbom wrote:I tried using uint64_t but got a compilation error: Undefined reference to '__divdi3'.
- iocoder
- Member

- Posts: 208
- Joined: Sun Oct 18, 2009 5:47 pm
- Libera.chat IRC: iocoder
- Location: Alexandria, Egypt | Ottawa, Canada
- Contact:
Re: Unclear in what mode I work and how to use uint64_t
Because in your build_all_crosscompile.sh, you added '-lgcc' to your compiler command line, not the linker...mrjbom wrote:-static-libgcc -lgcc not help.
Re: Unclear in what mode I work and how to use uint64_t
Thanks.Octocontrabass wrote:If you use PAE, you can access all memory even in protected mode.mrjbom wrote:It is obvious that I get such numbers because of variable overflow, but I expected to see 4 GB because in protected mode it is no longer available.
All code compiled with GCC must be linked with libgcc. You can do that by changing line 94 to use GCC instead of LD for linking, and adding "-lgcc" to the command line after your object files. (You may also need to add ./i386-elf-4.9.1-Linux-x86_64/bin/ to your $PATH.)mrjbom wrote:I tried using uint64_t but got a compilation error: Undefined reference to '__divdi3'.
