C++ In Early Boot
Elazar Leibovich
Core C++ 2025�19 Oct. 2025 :: Tel-Aviv
C++ in Early Boot
And other bad ideas
Agenda
Prior Art
Keep in mind that U-Boot is a boot loader. If you have fancy things
like C++ code you should use an operating system instead.
Best regards,
Wolfgang Denk
Private Correspondence
I've had a very quick glance [in this presentation EL]. While I think the the experiment is interesting, I don't think that C++ in a bootloader is a good idea.
(anonymous u-boot contributor reviewer)
OSv, includeOS
Not that maintained
Not that early boot
Allows all C++ features possible!
OSv, includeOS
Not that maintained
Not that early boot
Allows all C++ features possible!
Early boot code is actually… assembly…
ARM recap
PSCI (lives after boot, e.g., RAM frequency)
OP-TEE
ELI
Trustzone
SPL
ATF
C is not (just?) a language!
“C is the lingua franca of programming. We must all speak C, and therefore C is not just a programming language anymore – it’s a protocol that every general-purpose programming language needs to speak.”
Our Goal
Prerequisites
Build
Run
C++
C++
C+
C++
C++
libstdc++?
Existing libstdc++? Arch dependent
libc++?
libc++? GPT has bugs
libc++? 1271 for include <string>
ETL? With std
ETL? No std
ETL? Needs libc anyhow
ETL. Use u-boot libc? No math.h, no sine in early boot
ETL? Let’s use embedded libc!
ETL? Exceptions have personality
ETL? Exceptions have personality
ETL
ETL? DSOs? Where we’re going we don’t need DSOs
ETL? DSOs? Where we’re going we don’t need DSOs
ETL? Static is thread safe!
ETL? Static is thread safe!
ETL? We have not threads!
Hurray!
If result is a global variable?
Who calls the constructor?
Better now!
The cost?
2255 bytes == 2Kb
Almost another 1K
SPL == Secondary Program loader size?
More issues
More issues
Summary