Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Signing fails on app extension targets: appex stub has no __text section, zsign aborts on free-space check

Đang mở
#379 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
45/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
swift
Lĩnh vực
build-system

Hướng nghiên cứu

The failure occurs when bundled zsign processes an extension stub; the issue points to ZArchO::Init in archo.cpp and ReallocCodeSignSpace. Start by reading the free-space calculation and how existing LC_CODE_SIGNATURE commands are handled, then inspect the stub’s Mach-O load commands. Done means extension stubs without a __text section can be signed successfully; the issue does not name tests to run.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Bug

xtool dev build --sign fails on an app whose package declares an extension when zsign processes the appex trampoline stub:

>>> Can't find free space of LoadCommands for CodeSignature!
Error: Signing failed

Root cause

The -Extension-product link step emits a stub Mach-O whose __TEXT segment contains only __stubs and __got — there is no __text section. The bundled zsign fork computes load-command free space as

m_uLoadCommandsFreeSpace = __text.offset - sizeofcmds - headerSize

(ZArchO::Init, archo.cpp). With no __text section the value is 0, so ReallocCodeSignSpace refuses to append LC_CODE_SIGNATURE and aborts. A __text-less stub is legal Mach-O — codesign signs these fine; the abort is specific to zsign's free-space shortcut.

Repro

xtool 1.21.0, aarch64 Linux (Arch/Asahi), Darwin SDK artifactbundle. Any SwiftPM app package with an extensions: entry in xtool.yml — in my case a WidgetKit ControlWidget extension. The stub binary at .build/out/Products/Debug-iphoneos/<Name>-Extension has ncmds=24, __TEXT with __stubs at fileoff 16384 and no __text section.

Workaround that unblocked me

Post-link hook in the artifactbundle's toolset/bin/ld64.lld wrapper: after orig/ld64.lld succeeds, inject an empty LC_CODE_SIGNATURE { dataoff: filesize, datasize: 0 } into the stub's load-command padding (it has ~15 KB free). zsign then takes its existing-pcslc path, skips the free-space check, and writes the real signature at dataoff — both app and appex sign and the bundle deploys.

Possible fixes

  • Emit a __text section in the extension stub link (e.g. a real entry-point object), or
  • Patch zsign's ZArchO::Init to fall back to the __TEXT segment's fileoff/filesize when no __text section exists.

Happy to send a PR against whichever side you prefer.

Ngôn ngữ chính
Swift
Star
5.5k
Fork
163
Merge trung bình
19 giờ 33 phút
Pull request đã merge (30 ngày)
25

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của xtool-org/xtool

Tất cả issue của xtool-org/xtool

Issue tương tự

Thêm issue về Swift

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.