This afternoon, I wrote a C program file named test. cpp. For the file content, see the appendix. /Tmp/ccyogqyq. O :(. eh_frame + 0x12): Undefined reference to '_ gxx_personality_v0' collect2: LD returned 1 exit status error occurs during GCC compilation. The problem of using C ++ compilation disappears. This error is caused by the filename suffix. I changed test. cpp to test. C, and then compiled it using gcc again. The specific reasons are to be further studied.
Appendix: Test. cpp
# Include <stdio. h>
# Include <stdlib. h>
# Include <sys/types. h>
U_int64_t gen64 (char type, char data, int CID, int mid)
{
U_int64_t ret = 0;
Unsigned char TMP = 0;
Switch (type)
{
Case 'p ':
TMP = 0;
Break;
Case 'C ':
TMP = 0x10;
Break;
Case 'N ':
TMP = 0x20;
Break;
Case 'A ':
TMP = 0x30;
Break;
Default:
Fprintf (stderr, "gen64 type has problem./N ");
}
Switch (data)
{
Case 'M ':
TMP | = 0x00;
Break;
Case's ':
TMP | = 0x01;
Break;
Case 'A ':
TMP | = 0x02;
Break;
Case 'p ':
TMP | = 0x03;
Break;
Default:
Fprintf (stderr, "gen64 data has problem./N ");
}
RET | = (u_int64_t) TMP <56) + (u_int64_t) (CID & 0 xFFFF) <32) + (u_int64_t) (Mid & 0 xffffffff );
Return ret;
}
Int main ()
{
Printf ("P, M, 1,1: % lu/N", gen64 ('P', 'M', 1, 1 ));
Return 0;
}