When compiling and linking a free-standing C program using gcc, a linker error can occur due to an undefined reference to __gxx_personality_v0. To understand the purpose of this symbol, let's explore its role in the context of the error message you provided.
What is the role of __gxx_personality_v0?
The symbol __gxx_personality_v0 is utilized in the stack unwinding tables, which are visible in the assembly output of stack unwinding. According to the Itanium C ABI, it is referred to as the Personality Routine.
In the absence of exceptions, defining this symbol as a global NULL void pointer will "work" because no exceptions are being thrown. However, attempting to throw an exception will result in unexpected behavior.
Alternative solutions:
The above is the detailed content of Why does linking a free-standing C program with gcc result in an undefined reference to `__gxx_personality_v0`?. For more information, please follow other related articles on the PHP Chinese website!