Skip to content
  • Marius Gerbershagen's avatar
    fix for calling conventions treating fixed and variadic arguments differently · 18cb1b35
    Marius Gerbershagen authored and Daniel Kochmański's avatar Daniel Kochmański committed
    Previously, we assumed that the fixed and variadic arguments of a
    variadic function were passed to the function in the same way. The
    arm64 calling convention used by iOS breaks this assumption by passing
    fixed arguments in registers or on the stack, depending on the
    position, while variadic arguments are always passed on the stack.
    
    Solving this problem while still allowing function redefinition at
    runtime requires introducing additional dispatch functions. These
    dispatch functions take no fixed arguments and pass all their
    arguments to the actual function. This dispatch is enabled by passing
    -DECL_C_COMPATIBLE_VARIADIC_DISPATCH to the C compiler.
    
    This problem was originally identified and a solution provided by
    thewhimer@gmail.com. This commit based on his work with minor
    improvements.
    18cb1b35