How to catch data-alignment faults on x86 (aka SIGBUS on Sparc)

前端 未结 6 1016
耶瑟儿~
耶瑟儿~ 2020-12-25 15:30

Is it somehow possible to catch data-alignment faults even on i386? Maybe by setting a i386 specific machine register or something like that.

On Solaris-Sparc I am r

6条回答
  •  没有蜡笔的小新
    2020-12-25 15:52

    To expand on Vokuhila-Oliba's answer looking at the "SOF Mis-aligned pointers on x86." thread it seems that gcc can generate code with mis-aligned memory access. AFAIK you don't have any control over this.

    Enabling alignment checks on gcc compiled code would be a bad idea. You risk getting SIGBUS errors for good C code.

    ReEdited: Sorry about that

提交回复
热议问题