44 questions
17
votes
3
answers
1k
views
Stack memory in a freestanding environment
I'm reading a GNU as introductory book for programs running on top of an OS. I'm at the stack memory part and I was curious how the stack looks like in a freestanding environment.
I'm guessing that ...
0
votes
1
answer
114
views
What is the correct way to receive a lambda with capture in a function argument?
In freestanding environment without standard library I use:
template <typename Func>
auto for_each_until_false(Func func) const -> void {
for (size_t i = 0; i < len; ++i) {
if ...
0
votes
0
answers
82
views
The use of swift macros prevents the execution of other code
I created a unwrap freestanding macro that unwraps optional values.
The implementation looks like the following code:
{ [\(raw: argumentName)] in
guard let \(raw: argumentName) else {
...
3
votes
1
answer
302
views
Disable generation of deleting destructor
I am developing a program for embedded system that will not use dynamic memory allocation. How can I prevent the GCC from producing deleting destructor (the destructor with D0 in its mangled name)? It ...
0
votes
1
answer
2k
views
Unable to find uint8_t despite having build the freestanding libs for C++
Edit: Is this related to this bug report?
Unable to find uint8_t despite having build the freestanding libs for C++
The error I get is:
FAILED: CMakeFiles/nak.dir/Kernel/src/kernel.cpp.o
/home/jared/...
0
votes
1
answer
1k
views
How to compile C++ freestanding / baremetal with g++?
C++ has many aspects, included by default, that are not desirable or even functional on embedded bare metal / free standing platforms.
How can I configure g++ to compile C++ in a manner suitable for ...
1
vote
1
answer
347
views
How can I detect if C malloc available for freestanding target platform?
In C, how can I detect if a some form of malloc has been made available, regardless of target platform or compiler? Is it enough to detect _STDLIB_H_?
I would like to include a header utility ...
4
votes
2
answers
4k
views
How to prevent GCC from inserting memset during link-time optimization?
While developping a bare metal firmware in C for a RV32IM target (RISC-V), I encountered a linking error when LTO is enabled:
/home/duranda/riscv/lib/gcc/riscv64-unknown-elf/10.2.0/../../../../riscv64-...
1
vote
1
answer
144
views
Character apparently doesn't get translated to its ASCII value in a C kernel
I'm developing a basic C kernel in a Kali machine and testing it inside QEMU. This is the kernel code:
void kernel_main();
void print();
void print() {
char* vidMem = (char*)0xb8000;
*vidMem =...
4
votes
1
answer
132
views
Why do these two pointers that should be the same point to different data?
I'm writing a FAT16 driver in GNU C for a hobby operating system, and I have a structure defined as such:
struct directory_entry {
uint8_t name[11];
uint8_t attrib;
uint8_t name_case;
uint8_t ...
0
votes
1
answer
234
views
undefined reference to `WinMain` while compiling my own kernel
I've started writing my very own kernel and am developing on Windows 10.
I am using the following tools:
gcc 8.1.0 elf x86_64 for compiling my C code, and for linking.
I am using this Windows package....
2
votes
0
answers
335
views
Why the printf function is still usable after adding the freestanding option
Generally, I've already read the following articles, checked the "freestanding/hosted" definition in gcc language standard, but not got my doubts resolved yet.
https://gcc.gnu.org/onlinedocs/gcc/...
0
votes
1
answer
495
views
Split char* at delimiter in freestanding mode c++
I am trying to write my own operating system. I have followed the tutorials on the OSDev Wiki, and I am now working on writing a console mode, with commands. I need to be able to split a char* into a ...
2
votes
1
answer
816
views
error: function declared 'ms_abi' here was previously declared without calling convention (clang)
when I try to compile C code that includes another C header I get this error:
x86_64-uefi/../../libk/string.h:9:10: error: function declared 'ms_abi' here was
previously declared without ...
9
votes
1
answer
2k
views
C++ freestanding features
What are the features that I can use in c++ freestanding environment? I am developing a little kernel (for my own pleasure) and I know that I can't use the whole stdlib library, but what else ? when I ...
-1
votes
2
answers
278
views
uintx_t to const char* in freestanding c++ using GNU compiler
so I am trying to convert some integers in to character arrays that my terminal can write. so I can see the value of my codes calculations for debugging purposes when its running.
as in if the int_t ...
4
votes
1
answer
191
views
Does a port of the C library need to be implemented in C?
I'm working on a kernel. One of the tasks in writing a kernel is that a C library must be ported. Some functions such as memcmp, strlen and so on have to be rewritten. Most of the time I see the code ...
26
votes
4
answers
12k
views
Is there a meaningful distinction between freestanding and hosted implementations?
The question I have is mostly related to section four, paragraph six.
The two forms of conforming implementation are hosted and freestanding. A conforming hosted implementation shall accept any ...
3
votes
2
answers
9k
views
Call assembly procedure from another assembly file?
Just a simple question:
Let's say I had the following two assembly programs:
1:
add10:
add eax, 10
ret
;call add5 from other file
2:
add5:
add eax, 5
ret
;call add10 from other file
...
64
votes
1
answer
51k
views
What is -ffreestanding option in gcc?
What is ffreestanding in gcc ? What is it used for ? I came across the following :
gcc -ffreestanding -m32 -c kernel.c -o kernel.o
and do not understand, what does it mean exactly.
4
votes
1
answer
510
views
What are the differences between the various WG14 C standards for freestanding implementations?
How would compilers implementing the freestanding portion of each different standard below have to differ? What would be the fewest number of modes (specified by command line flags, for example) ...
25
votes
2
answers
7k
views
How to compile for a freestanding environment with GCC?
The code I'm working on is supposed to be possible to build for both hosted and freestanding environments, providing private implementations for some stdlib functions for the latter case.
Can I ...