Assembly Calling Convention - x86_64 AMD64 ABI and Stack Frame

Поделиться
HTML-код
  • Опубликовано: 15 дек 2024

Комментарии • 23

  • @StackMemory0x00
    @StackMemory0x00 6 месяцев назад +8

    You mixed up prologue (start) with Epilogue(end). Prologue is the start of function call and Epilogue is the end. It took me lots of time to differnciate them. An easy way to remember the order is to link letter E from Epilogue with End ( both words start with letter E). In addition, the size of all registers is 8 bytes in 64bit arch.

  • @OlivierDubois
    @OlivierDubois 10 месяцев назад

    Nice video! I found it pretty clear. One note: I think the reason why there is no sub done on rsp when d0 is a tail call is that the compiler is using the red zone in this case.

  • @Roman-cx7ym
    @Roman-cx7ym 7 месяцев назад

    do you have a video on analyzing partial contents of stack memory?

  • @ruvutoian8403
    @ruvutoian8403 Год назад +2

    why doesn't the main's Stack Frame also subtract the stack pointer to reserve memory for the calling function 'd' ?

    • @redcrafterlppa303
      @redcrafterlppa303 Год назад +3

      He explained it a bit weird. The reason d0 is first reserving space on the stack and then moving all arguments(a1, a2, a3) passed to it by registers to the stack, is that printf could use the registers(edi, esi, edx) to be other values and would therefore overwrite the parameters passed to d0. d0 needs to reserve space because it stores local variables (a1, a2, a3, a, b) on the stack.
      main doesn't have local variables and therefore doesn't need to reserve any space.
      Also the reason the substrate instruction disappeared when he removed printf is because "reservating space" means moving the value telling the next (inner) function epilog (printf) where it can start to put it's local variables so they are located after the variables of the enclosing function instead of at the same location. When he removes printf d0 has no function to tell that and it would basically sub 20 and add 20 without anything looking at that value change making it a noop.

  • @LeoMakizo
    @LeoMakizo 11 месяцев назад

    I dont know why, but I really liked that frame 0:32

  • @qsmfoui
    @qsmfoui 3 месяца назад

    very well explained

  • @funkykong9001
    @funkykong9001 2 года назад +2

    great, thank you!

    • @soliduscode
      @soliduscode  2 года назад

      Glad it was helpful FunkyKong!

  • @minchengzhang315
    @minchengzhang315 2 года назад +2

    why not "sub rsp, 0x1c" , but "sub rsp, 0x20"? why 4 bytes is extra?

    • @PanduPoluan
      @PanduPoluan Год назад +4

      I suspect the reason is to ensure 64-bit (8-byte) alignment.
      0x1c is not a multiple of 8.

  • @johnmckown1267
    @johnmckown1267 3 месяца назад

    To look at assembler, there is the S switch in gcc "gcc -S -o prog.s prog.c".

  • @MyMineBlocky
    @MyMineBlocky 9 месяцев назад

    I'm pretty sure the EAX 0x0 is the return value of printf

    • @soliduscode
      @soliduscode  7 месяцев назад

      You are correct my dude :)

  • @coin5207
    @coin5207 2 года назад +1

    Good video!

  • @user-ze4qq8mm1q
    @user-ze4qq8mm1q 2 года назад +6

    I think you mixed up epilogue and prologue...

    • @soliduscode
      @soliduscode  2 года назад +5

      My mistake. Thank you for keeping me honest. Hope you enjoyed the video.

  • @stephenodogwu7359
    @stephenodogwu7359 11 месяцев назад +1

    This doesn't seem like Windows..

  • @collinsflaize3165
    @collinsflaize3165 Год назад

    Buy a better mic man