Skip to content

Commit 017c65f

Browse files
committed
added expected functions when optimization is off for some standard library functions
1 parent 3888d04 commit 017c65f

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

klib/entry/entry.c

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,31 @@ void __attribute__((__noreturn__, __naked__)) __reset_handler() {
7777
* @brief Default handler that locks the cpu.
7878
*
7979
*/
80-
void __default_handler() {
80+
void __attribute__((noreturn)) __default_handler() {
8181
// do nothing and wait
8282
while (true) {}
8383
}
8484

8585
// called when a vft entry is not yet filled in
86-
void __attribute__((weak)) __cxa_pure_virtual() {}
86+
void __attribute__((weak)) __cxa_pure_virtual() {}
87+
88+
// when optimization is off we need to provide these
89+
// functions for some standard library features. These
90+
// are just stubs that call the default handler. When
91+
// optimization is on these are not needed as they do
92+
// not do anything.
93+
#if __OPTIMIZATION_LEVEL__ == 0
94+
void __attribute__((weak)) _exit(int) {
95+
__default_handler();
96+
}
97+
98+
void __attribute__((weak)) _kill() {
99+
__default_handler();
100+
}
101+
102+
int __attribute__((weak)) _getpid() {
103+
return 1;
104+
}
105+
106+
void __attribute__((weak)) _fini() {}
107+
#endif

0 commit comments

Comments
 (0)