hello everyoone
I encountered a problem that the PC program counter register in a core file is misaligned!!! The info of registers as follow
(gdb) info registers x0 0x1 1x1 0x0 0x2 0x5be5503d1f1bab00 6621787050563316480x3 0x98629ade8a03f19f -7466234951637929569x4 0xffff829f5310 281472873222928x5 0x2000 8192x6 0xffff829f4000 281472873218048x7 0xc0c0 49344x8 0x0 0x9 0x3b9aca00000000 16777216000000000x10 0x61559894 1632999572x11 0x88f83 561027x12 0x18 24x13 0x3e8000000 16777216000x14 0x1 1x15 0x509091a34a45 88581848910405x16 0x5fe0278 100532856x17 0xffff827c1ac0 281472870914752x18 0xfffdacba0bf7 281464989682679x19 0x5 5x20 0xfffdacba68a0 281464989706400x21 0x0 0x22 0xfffdf4194330 281466187105072x23 0x1cd7a 118138x24 0xfffdb57f6196 281465136832918x25 0x1 1x26 0x12903da4 311442852x27 0x5fde000 100524032x28 0x91 145x29 0x100fffdacba34c0 72339059027621056x30 0x4ba701 4957953sp 0xfffdacba34a0 0xfffdacba34a0pc 0x4ba701 0x4ba701 <mac_prepare_pucch_harq+705>cpsr 0x60000000 [ EL=0 C Z ]fpsr 0x11 17fpcr 0x0 0
The program is compiled with gcc version 7.5.0 (Ubuntu/Linaro 7.5.0-3ubuntu1~18.04) and runs on Arm® Cortex®-A72 .After running a while , the program
received signal SIGBUS, Bus error and generated a core file. Use gdb to analysis the core file ,I found that the pc register is misaligned and I guess it results the
Bus error.The Program Counter (PC) contains the address of the currently executing instruction. It is incremented by the size of the instruction executed, which is
always four bytes.So i don't know in what condition the PC may be misaligned. Would you please help me ,thank you very much!
Thank you very much for the reply , but i still don't understand who has written the misaligned address into the PC register
As I wrote, it is likely because of a return instruction or a jump to x30. And this likely because the stack was corrupted. You should check if the address points to something meaningful.
The misaligned address in x30 and pc register really points to a address in code segment,you mean the value 0x4ba701 may not be a code address but a meaningful data of something?But after I read the assemble code around the 0x4ba701,the value of some other register corrsponds with the assemble code.
0x00000000004ba6e8 <+680>: mov w5, w21 0x00000000004ba6ec <+684>: mov x2, x26 0x00000000004ba6f0 <+688>: ldr x0, [x0] 0x00000000004ba6f4 <+692>: bl 0x404000 <fprintf@plt> 0x00000000004ba6f8 <+696>: ldr w0, [x26] 0x00000000004ba6fc <+700>: cmp w0, #0x1 0x00000000004ba700 <+704>: b.eq 0x4ba734 <mac_prepare_pucch_harq+756> // b.none 0x00000000004ba704 <+708>: sub w0, w0, #0x2 0x00000000004ba708 <+712>: tst w0, #0xfffffffd
For example , after 0x00000000004ba6f8 executed , the w0 should be 0x01 and the value of x0 is really 0x01