Why is compiler adding an extra 'sxtw' instruction (resulting further in a Kernel Panic)?ArchLinux kernel...

Simple image editor tool to draw a simple box/rectangle in an existing image

How can I raise concerns with a new DM about XP splitting?

How do I repair my stair bannister?

Why does this part of the Space Shuttle launch pad seem to be floating in air?

Simple recursive Sudoku solver

Female=gender counterpart?

Bob has never been a M before

Taylor series of product of two functions

Giant Toughroad SLR 2 for 200 miles in two days, will it make it?

What do you call the infoboxes with text and sometimes images on the side of a page we find in textbooks?

Are taller landing gear bad for aircraft, particulary large airliners?

Have I saved too much for retirement so far?

I'm in charge of equipment buying but no one's ever happy with what I choose. How to fix this?

Who must act to prevent Brexit on March 29th?

What is the oldest known work of fiction?

How to deal with or prevent idle in the test team?

Can a Bard use an arcane focus?

Installing PowerShell on 32-bit Kali OS fails

Was the picture area of a CRT a parallelogram (instead of a true rectangle)?

Can I use my Chinese passport to enter China after I acquired another citizenship?

Do all polymers contain either carbon or silicon?

Organic chemistry Iodoform Reaction

Can I rely on these GitHub repository files?

Teaching indefinite integrals that require special-casing



Why is compiler adding an extra 'sxtw' instruction (resulting further in a Kernel Panic)?


ArchLinux kernel panic on bootKernel panic and keyboard led flashingKernel panic after power lossUnable to install debian on Lacie ss4000e Kernel PanicElastix kernel panicKernel panic - Linux - hardware or software?Creating own Linux distribution - Kernel PanicKernel panic - not syncing: No init foundFedora kernel panic after system updateSalix Won't Boot - Kernel Panic: Not Syncing













0















Issue/Symptom: At the end of a function return, compiler adds sxtw instruction as seen in the disassembly, resulting in a return address of only 32 bits instead of 64 bits, resulting in a kernel panic (Unable to handle kernel paging request at virtual address xxxx)



Build Environment:



Platform : ARMV7LE
gcc, linux-4.4.60
Arch : Arm64
gdb : aarch64-5.3-glibc-2.22/usr/bin/aarch64-linux-gdb



Details



Here's the simplified project structure.
It's been taken care of correctly in the corresponding makefile.
Also note that file1.c and file2.c are part of same module.



../src/file1.c /* It has func1() defined as well as called /
../src/file2.c
../inc/files.h /
There's no func1() declared in the header */



Cause of the issue



A call to the func1() was added from the file2.c w/o func1 declaration in files.h or file2.c
(Basically the inclusion of func1 was accidentally missed in the files.h)



Code compiled with NO ERRORS but a warning as expected -- Implicit declaration of function func1.



At the run time though, right after returning from func1 inside file2, system crashed as it tried de-referencing the returned address from func1.



Further analysis showed that at the end of a function return, compiler added sxtw instruction as seen in the disassembly, resulting in a return address of only 32 bits instead of 64 bits, resulting in a kernel panic (Unable to handle kernel paging request at virtual address xxxx)




  • Note that x19 is of 64 bit while w0 is of 32 bit.

  • Note that x0 LS word matches with that of x19

  • System crashed while de-referencing x19


sxtw x19, w0 /* This was added by compiler as extra instruction /
ldp x1, x0, [x19,#304] /
System crashed here */



Registers :-
[ 91.388130] pc : [] lr : [] pstate: 80000145
[ 91.462090] sp : ffffff80094333b0
[ 91.552708] x29: ffffff80094333d0 x28: ffffffc06995408a
[ 91.652701] x27: ffffffc06c400a00 x26: 0000000000000000
[ 91.716243] x25: 0000000000000000 x24: ffffffc069958000
[ 91.779784] x23: ffffffc076e00000 x22: ffffffc06c400a00
[ 91.843326] x21: 0000000000000031 x20: ffffffc073060000
[ 91.906867] x19: 0000000066bfc780 x18: ffffff8009436888
[ 91.970409] x17: 0000000000000000 x16: ffffff8008193074
[ 92.033952] x15: 00000000000a8c06 x14: 2c30323030387830
[ 92.097492] x13: 3d7367616c66202c x12: 3038653030303030
[ 92.161034] x11: 3038666666666666 x10: 78303d646e65202c
[ 92.224576] x9 : 3063303030303030 x8 : 3030303030303030
[ 92.288117] x7 : 0000000000000880 x6 : 0000000000000000
[ 92.351659] x5 : ffffffc07fd10ad8 x4 : 0000000000000001
[ 92.415202] x3 : 0000000000000007 x2 : cb88537fdc8ba63c
[ 92.478743] x1 : 0000000000000000 x0 : ffffffc066bfc780



After adding the declaration of func1 in the files.h, the extra instruction and hence the crash was NOT seen.



Can someone please explain as to why the compiler added sxtw in this case?









share







New contributor




user1012064 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

























    0















    Issue/Symptom: At the end of a function return, compiler adds sxtw instruction as seen in the disassembly, resulting in a return address of only 32 bits instead of 64 bits, resulting in a kernel panic (Unable to handle kernel paging request at virtual address xxxx)



    Build Environment:



    Platform : ARMV7LE
    gcc, linux-4.4.60
    Arch : Arm64
    gdb : aarch64-5.3-glibc-2.22/usr/bin/aarch64-linux-gdb



    Details



    Here's the simplified project structure.
    It's been taken care of correctly in the corresponding makefile.
    Also note that file1.c and file2.c are part of same module.



    ../src/file1.c /* It has func1() defined as well as called /
    ../src/file2.c
    ../inc/files.h /
    There's no func1() declared in the header */



    Cause of the issue



    A call to the func1() was added from the file2.c w/o func1 declaration in files.h or file2.c
    (Basically the inclusion of func1 was accidentally missed in the files.h)



    Code compiled with NO ERRORS but a warning as expected -- Implicit declaration of function func1.



    At the run time though, right after returning from func1 inside file2, system crashed as it tried de-referencing the returned address from func1.



    Further analysis showed that at the end of a function return, compiler added sxtw instruction as seen in the disassembly, resulting in a return address of only 32 bits instead of 64 bits, resulting in a kernel panic (Unable to handle kernel paging request at virtual address xxxx)




    • Note that x19 is of 64 bit while w0 is of 32 bit.

    • Note that x0 LS word matches with that of x19

    • System crashed while de-referencing x19


    sxtw x19, w0 /* This was added by compiler as extra instruction /
    ldp x1, x0, [x19,#304] /
    System crashed here */



    Registers :-
    [ 91.388130] pc : [] lr : [] pstate: 80000145
    [ 91.462090] sp : ffffff80094333b0
    [ 91.552708] x29: ffffff80094333d0 x28: ffffffc06995408a
    [ 91.652701] x27: ffffffc06c400a00 x26: 0000000000000000
    [ 91.716243] x25: 0000000000000000 x24: ffffffc069958000
    [ 91.779784] x23: ffffffc076e00000 x22: ffffffc06c400a00
    [ 91.843326] x21: 0000000000000031 x20: ffffffc073060000
    [ 91.906867] x19: 0000000066bfc780 x18: ffffff8009436888
    [ 91.970409] x17: 0000000000000000 x16: ffffff8008193074
    [ 92.033952] x15: 00000000000a8c06 x14: 2c30323030387830
    [ 92.097492] x13: 3d7367616c66202c x12: 3038653030303030
    [ 92.161034] x11: 3038666666666666 x10: 78303d646e65202c
    [ 92.224576] x9 : 3063303030303030 x8 : 3030303030303030
    [ 92.288117] x7 : 0000000000000880 x6 : 0000000000000000
    [ 92.351659] x5 : ffffffc07fd10ad8 x4 : 0000000000000001
    [ 92.415202] x3 : 0000000000000007 x2 : cb88537fdc8ba63c
    [ 92.478743] x1 : 0000000000000000 x0 : ffffffc066bfc780



    After adding the declaration of func1 in the files.h, the extra instruction and hence the crash was NOT seen.



    Can someone please explain as to why the compiler added sxtw in this case?









    share







    New contributor




    user1012064 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.























      0












      0








      0








      Issue/Symptom: At the end of a function return, compiler adds sxtw instruction as seen in the disassembly, resulting in a return address of only 32 bits instead of 64 bits, resulting in a kernel panic (Unable to handle kernel paging request at virtual address xxxx)



      Build Environment:



      Platform : ARMV7LE
      gcc, linux-4.4.60
      Arch : Arm64
      gdb : aarch64-5.3-glibc-2.22/usr/bin/aarch64-linux-gdb



      Details



      Here's the simplified project structure.
      It's been taken care of correctly in the corresponding makefile.
      Also note that file1.c and file2.c are part of same module.



      ../src/file1.c /* It has func1() defined as well as called /
      ../src/file2.c
      ../inc/files.h /
      There's no func1() declared in the header */



      Cause of the issue



      A call to the func1() was added from the file2.c w/o func1 declaration in files.h or file2.c
      (Basically the inclusion of func1 was accidentally missed in the files.h)



      Code compiled with NO ERRORS but a warning as expected -- Implicit declaration of function func1.



      At the run time though, right after returning from func1 inside file2, system crashed as it tried de-referencing the returned address from func1.



      Further analysis showed that at the end of a function return, compiler added sxtw instruction as seen in the disassembly, resulting in a return address of only 32 bits instead of 64 bits, resulting in a kernel panic (Unable to handle kernel paging request at virtual address xxxx)




      • Note that x19 is of 64 bit while w0 is of 32 bit.

      • Note that x0 LS word matches with that of x19

      • System crashed while de-referencing x19


      sxtw x19, w0 /* This was added by compiler as extra instruction /
      ldp x1, x0, [x19,#304] /
      System crashed here */



      Registers :-
      [ 91.388130] pc : [] lr : [] pstate: 80000145
      [ 91.462090] sp : ffffff80094333b0
      [ 91.552708] x29: ffffff80094333d0 x28: ffffffc06995408a
      [ 91.652701] x27: ffffffc06c400a00 x26: 0000000000000000
      [ 91.716243] x25: 0000000000000000 x24: ffffffc069958000
      [ 91.779784] x23: ffffffc076e00000 x22: ffffffc06c400a00
      [ 91.843326] x21: 0000000000000031 x20: ffffffc073060000
      [ 91.906867] x19: 0000000066bfc780 x18: ffffff8009436888
      [ 91.970409] x17: 0000000000000000 x16: ffffff8008193074
      [ 92.033952] x15: 00000000000a8c06 x14: 2c30323030387830
      [ 92.097492] x13: 3d7367616c66202c x12: 3038653030303030
      [ 92.161034] x11: 3038666666666666 x10: 78303d646e65202c
      [ 92.224576] x9 : 3063303030303030 x8 : 3030303030303030
      [ 92.288117] x7 : 0000000000000880 x6 : 0000000000000000
      [ 92.351659] x5 : ffffffc07fd10ad8 x4 : 0000000000000001
      [ 92.415202] x3 : 0000000000000007 x2 : cb88537fdc8ba63c
      [ 92.478743] x1 : 0000000000000000 x0 : ffffffc066bfc780



      After adding the declaration of func1 in the files.h, the extra instruction and hence the crash was NOT seen.



      Can someone please explain as to why the compiler added sxtw in this case?









      share







      New contributor




      user1012064 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.












      Issue/Symptom: At the end of a function return, compiler adds sxtw instruction as seen in the disassembly, resulting in a return address of only 32 bits instead of 64 bits, resulting in a kernel panic (Unable to handle kernel paging request at virtual address xxxx)



      Build Environment:



      Platform : ARMV7LE
      gcc, linux-4.4.60
      Arch : Arm64
      gdb : aarch64-5.3-glibc-2.22/usr/bin/aarch64-linux-gdb



      Details



      Here's the simplified project structure.
      It's been taken care of correctly in the corresponding makefile.
      Also note that file1.c and file2.c are part of same module.



      ../src/file1.c /* It has func1() defined as well as called /
      ../src/file2.c
      ../inc/files.h /
      There's no func1() declared in the header */



      Cause of the issue



      A call to the func1() was added from the file2.c w/o func1 declaration in files.h or file2.c
      (Basically the inclusion of func1 was accidentally missed in the files.h)



      Code compiled with NO ERRORS but a warning as expected -- Implicit declaration of function func1.



      At the run time though, right after returning from func1 inside file2, system crashed as it tried de-referencing the returned address from func1.



      Further analysis showed that at the end of a function return, compiler added sxtw instruction as seen in the disassembly, resulting in a return address of only 32 bits instead of 64 bits, resulting in a kernel panic (Unable to handle kernel paging request at virtual address xxxx)




      • Note that x19 is of 64 bit while w0 is of 32 bit.

      • Note that x0 LS word matches with that of x19

      • System crashed while de-referencing x19


      sxtw x19, w0 /* This was added by compiler as extra instruction /
      ldp x1, x0, [x19,#304] /
      System crashed here */



      Registers :-
      [ 91.388130] pc : [] lr : [] pstate: 80000145
      [ 91.462090] sp : ffffff80094333b0
      [ 91.552708] x29: ffffff80094333d0 x28: ffffffc06995408a
      [ 91.652701] x27: ffffffc06c400a00 x26: 0000000000000000
      [ 91.716243] x25: 0000000000000000 x24: ffffffc069958000
      [ 91.779784] x23: ffffffc076e00000 x22: ffffffc06c400a00
      [ 91.843326] x21: 0000000000000031 x20: ffffffc073060000
      [ 91.906867] x19: 0000000066bfc780 x18: ffffff8009436888
      [ 91.970409] x17: 0000000000000000 x16: ffffff8008193074
      [ 92.033952] x15: 00000000000a8c06 x14: 2c30323030387830
      [ 92.097492] x13: 3d7367616c66202c x12: 3038653030303030
      [ 92.161034] x11: 3038666666666666 x10: 78303d646e65202c
      [ 92.224576] x9 : 3063303030303030 x8 : 3030303030303030
      [ 92.288117] x7 : 0000000000000880 x6 : 0000000000000000
      [ 92.351659] x5 : ffffffc07fd10ad8 x4 : 0000000000000001
      [ 92.415202] x3 : 0000000000000007 x2 : cb88537fdc8ba63c
      [ 92.478743] x1 : 0000000000000000 x0 : ffffffc066bfc780



      After adding the declaration of func1 in the files.h, the extra instruction and hence the crash was NOT seen.



      Can someone please explain as to why the compiler added sxtw in this case?







      linux 64-bit gcc arm





      share







      New contributor




      user1012064 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.










      share







      New contributor




      user1012064 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      share



      share






      New contributor




      user1012064 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 3 mins ago









      user1012064user1012064

      1




      1




      New contributor




      user1012064 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      user1012064 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      user1012064 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          0






          active

          oldest

          votes











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "3"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });






          user1012064 is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1417601%2fwhy-is-compiler-adding-an-extra-sxtw-instruction-resulting-further-in-a-kerne%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          user1012064 is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          user1012064 is a new contributor. Be nice, and check out our Code of Conduct.













          user1012064 is a new contributor. Be nice, and check out our Code of Conduct.












          user1012064 is a new contributor. Be nice, and check out our Code of Conduct.
















          Thanks for contributing an answer to Super User!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1417601%2fwhy-is-compiler-adding-an-extra-sxtw-instruction-resulting-further-in-a-kerne%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          VNC viewer RFB protocol error: bad desktop size 0x0I Cannot Type the Key 'd' (lowercase) in VNC Viewer...

          Tribunal Administrativo e Fiscal de Mirandela Referências Menu de...

          looking for continuous Screen Capture for retroactivly reproducing errors, timeback machineRolling desktop...