x86 GNU Assembler Strange Change Seg Fault

前端 未结 1 1795
说谎
说谎 2021-01-14 15:15

The following x86 assembly code assembles fine, and it used to run flawlessly on my school\'s linux server, but when applying the same code to my linux virtual machine (ubun

相关标签:
1条回答
  • 2021-01-14 15:53

    I'm guessing that you have a 64-bit machine, while your program is obviously 32-bit.

    I have a 64-bit machine, if I compile it with this command, it fails, same line as you:

    $ gcc -nostdlib test.s
    

    However, if I compile a 32-bit executable:

    $ gcc -nostdlib -m32 test.s
    

    And all is fine.

    Note that you may need some packages to be able to compile a 32-bit program in a 64-bit machine (g++-multilib or whatever they call it these days).

    0 讨论(0)
提交回复
热议问题