Memory alignment today and 20 years ago

后端 未结 3 482
失恋的感觉
失恋的感觉 2021-02-05 15:49

In the famous paper \"Smashing the Stack for Fun and Profit\", its author takes a C function

void function(int a, int b, int c) {
  char buffer1[5];
  char buffe         


        
3条回答
  •  别那么骄傲
    2021-02-05 16:26

    What has changed is SSE, which requires 16 byte alignment, this is covered in this older gcc document for -mpreferred-stack-boundary=num which says (emphasis mine):

    On Pentium and PentiumPro, double and long double values should be aligned to an 8 byte boundary (see -malign-double) or suffer significant run time performance penalties. On Pentium III, the Streaming SIMD Extension (SSE) data type __m128 suffers similar penalties if it is not 16 byte aligned.

    This is also backed up by the paper Smashing The Modern Stack For Fun And Profit which covers this an other modern changes that break Smashing the Stack for Fun and Profit.

提交回复
热议问题