entry.S 765 B

12345678910111213141516171819202122232425262728
  1. /*
  2. * Copyright (c) 2021, Gunnar Beutner <gbeutner@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. .align 4
  7. .globl _invoke_entry
  8. .hidden _invoke_entry
  9. .type _invoke_entry,@function
  10. _invoke_entry: # (argc, argv, envp, entry)
  11. addl $4, %esp # return address
  12. popl %edi # argc
  13. popl %esi # argv
  14. popl %edx # envp
  15. popl %ecx # entry
  16. // The System V ABI for x86 and x86_64 prescribes that the stack pointer is 16-byte aligned
  17. andl $~15, %esp
  18. // We're going to push three arguments so we need to align the stack for that
  19. subl $4, %esp
  20. // FIXME: The way we're setting up the stack and passing arguments to the entry point isn't ABI-compliant
  21. pushl %edx
  22. pushl %esi
  23. pushl %edi
  24. jmp *%ecx