How Single App Binary Supports 64-bit and 32-bit Apps

后端 未结 6 842
栀梦
栀梦 2021-01-31 06:25

We can see apple announcement here.. According to this doc, we can submit same binary with supporting 32-bit and also 64-bit. I found one stack overflow answer here. But Accordi

6条回答
  •  渐次进展
    2021-01-31 06:29

    iOS apps rely on a low-level application binary interface and coding conventions established by the Objective-C language and the system frameworks. Starting with iOS 7, some iOS devices use 64-bit processors and offer both a 32-bit and a 64-bit runtime environment. For most apps, the 64-bit runtime environment differs from the 32-bit runtime environment in two significant ways:

    In the 64-bit runtime, many data types used by Cocoa Touch frameworks (as well as the Objective-C language itself) have increased in size or have stricter memory alignment rules. See “Changes to Data Types.” The 64-bit runtime requires proper function prototypes to be used when making function calls. See “Changes to Function Calling.”

    application binary interface (ABI)

    Other Changes to the 64-Bit Runtime

    The 64-bit ARM instruction set is significantly different from the 32-bit instruction set. If your app includes any assembly language code, you need to rewrite it to use the new instruction set. You also need a more detailed description of the 64-bit calling conventions in iOS, because the conventions do not exactly match the ARM standard. For more information, see iOS ABI Function Call Guide.

    At a high level, to make your code 64-bit clean, you must do the following:

    1. Avoid assigning 64-bit long integers to 32-bit integers.
    2. Avoid assigning 64-bit pointers to 32-bit integers.
    3. Avoid pointer and long integer truncation during arithmetic operations (or other arithmetic problems caused by the change in integer types).
    4. Fix alignment issues caused by changes in data type sizes.
    5. Ensure that memory structures that are shared between the 32-bit and 64-bit runtimes share a similar layout.
    6. Rewrite any assembly language code so that your code uses the new 64-bit opcodes and runtime.
    7. Avoid casting variadic functions to functions that take a fixed number of parameters, or vice versa.

提交回复
热议问题