• Show log

    Commit

  • Hash : e70dd1aa
    Author : Iain Sandoe
    Date : 2023-02-02T11:44:13

    libffi: Fix X86 32b Darwin build and EH frames. (#757) This addresses a number of issues in the X86 Darwin 32b port for libffi. 1. The pic symbol stubs are weak definitions; the correct section placement for these depends on the linker version in use. We do not have access to that information, but we can use the target OS version (assumes that the user has installed the latest version of xcode available). When a coalesced section is in use (OS versions earlier than Darwin12 / OSX 10.8), its name must differ from __TEXT,__text since otherwise that would correspond to altering the attributes of the .text section (which produces a diagnostic from the assembler). Here we use __TEXT, __textcoal_nt for this which is what GCC emits for these stubs. For later versions than Darwin 12 (OS X 10.8) we can place the stubs in the .text section (if we do not we get a diagnostic from clang -cc1as saying that the use of coalesced sections for this is deprecated). 2. The EH frame is specified manually, since there is no support for .cfi_ directives in 'cctools' assemblers. The implementation needs to provide offsets for CFA advance, code size and to the CIE as signed values rather than relocations. However the cctools assembler will produce a relocation for expressions like ' .long Lxx-Lyy' which then leads to a link-time error. We correct this by forming the offset values using ' .set' directives and then assigning the results of them. 3. The register numbering used by m32 X86 Darwin EH frames is not the same as the DWARF debug numbering (the Frame and Stack pointer numbers are swapped). 4. The FDE address encoding used by the system tools is '0x10' (PCrel + abs) where the value provided was PCrel + sdata4. 5. GCC does not use compact unwind at present, and it was not implemented until Darwin10 / OSX 10.6. There were some issues with function location in 10.6 so that the solution here suppresses emitting the compact unwind section until Darwin11 / OSX 10.7.