Is there any stdlib-like library for bare-metal programming?
I am trying to build a program (supposed to be built on linux) for bare-metal environment. The program is dependent on stdlib and posix lib (malloc, calloc, realloc, free, and pthread usage). I will modify it for single thread anyway.
I was reading https://www.ibm.com/developerworks/aix/tutorials/au-memorymanager/ and maybe I will implement my own memory management. But in my case the program has malloc/realloc/free s of various sizes. If there is any program (open source) supporting memory management (and hopefully pthread too.) please give me an advice. The language is C.
Asked
Active
Viewed 327 times
0

Chan Kim
- 5,177
- 12
- 57
- 112
-
1Implementation of `malloc` typically somehow depends on what your device is and provides, so "bare metal" isn't specific enough. You can [look here](https://github.com/zirias/clang-libdos) for ideas, this is what I did on DOS. – May 26 '17 at 05:16
-
Thanks I'll have a close look at it sometime later. – Chan Kim May 26 '17 at 05:28
-
FreeRTOS? ...... – ThingyWotsit May 26 '17 at 06:33
1 Answers
0
For the memory allocation functions, you should be able to adapt Doug Lea's public domain dlmalloc implementation. Read the file for details, but you will need to supply a function for MORECORE
that requests a chunk of memory - if you're on bare metal then this will probably just return consecutive blocks starting above the location your code is loaded.

caf
- 233,326
- 40
- 323
- 462
-
Thanks, I will look into it sometime later.(I need to find out what to define for comipile. I'm using sparc-xx-elf-gcc.) – Chan Kim May 26 '17 at 05:45