How to trap unaligned memory access?

前端 未结 2 882
梦如初夏
梦如初夏 2020-11-30 09:55

I am working on a pet open-source project that implements some stream cipher algorithms and I am having trouble with a bug triggered only when I run it on an ARM processor.

2条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-30 10:33

    Linux can do the fixup for you or warn about the access.

    You can enable the behavior in /proc/cpu/alignment, see http://www.mjmwired.net/kernel/Documentation/arm/mem_alignment for an explanation of the different values.

    0 - Do nothing (default behavior)
    1 - Warning in kernel-log with PC and Memory-Address printed.
    2 - Fixup error
    3 - Warn and Fixup
    4 - Send a SIGBUS to the process
    5 - Send SIGBUS and output Warning
    

提交回复
热议问题