You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
swift-ci opened this issue
Jan 24, 2017
· 4 comments
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler in itselfIRGenLLVM IR generation
Apple Swift version 3.0.1 (swiftlang-800.0.58.6 clang-800.0.42.1)
ld64-274.1
Additional Detail from JIRA
Votes
0
Component/s
Compiler
Labels
Bug, IRGen
Assignee
mpetrov (JIRA)
Priority
Medium
md5: 8a872b674041ac969b54d108104bff60
Issue Description:
Generated Mach-O binaries use non word-aligned references that can break some Mach-O parsing libraries.
For example, the pointer for a Swift class' class_ro_t* is at 0x1000042d9, when in practice it starts at 0x1000042d8. This may just be a linker bug, but I've only seen this happen with Swift classes (and not with ObjC).
Repro case is below:
~> cat hello.swift
class Foo {}
class Bar {}
class Baz {}
~> otool hello -o | grep "Swift class"
data 0x1000042d9 (struct class_ro_t *) Swift class
data 0x100004369 (struct class_ro_t *) Swift class
data 0x1000043f9 (struct class_ro_t *) Swift class
The text was updated successfully, but these errors were encountered:
This is correct and necessary behavior for Swift class metadata records, which have information located at negative offsets. That said I'm a little concerned about not respecting alignment within the class_ro_t.
The low bit of class_ro_t is the "is Swift, using an app-packaged runtime" bit. The rodata pointer itself is still aligned, but the alignment bits (and on 64-bit platforms, unused address space high bits) are reserved to the ObjC runtime.
Right. The pointer is not "unaligned". It's a pointer to a correctly-aligned ro_t, and a low bit is being used to encode extra information in that pointer. Those Mach-O parsing libraries should just be fixed to ignore sub-word offsets.
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler in itselfIRGenLLVM IR generation
Environment
Apple Swift version 3.0.1 (swiftlang-800.0.58.6 clang-800.0.42.1)
ld64-274.1
Additional Detail from JIRA
md5: 8a872b674041ac969b54d108104bff60
Issue Description:
Generated Mach-O binaries use non word-aligned references that can break some Mach-O parsing libraries.
For example, the pointer for a Swift class' class_ro_t* is at 0x1000042d9, when in practice it starts at 0x1000042d8. This may just be a linker bug, but I've only seen this happen with Swift classes (and not with ObjC).
Repro case is below:
~> cat hello.swift
class Foo {}
class Bar {}
class Baz {}
~> swiftc hello.swift -v -Xlinker -v
Apple Swift version 3.0.1 (swiftlang-800.0.58.6 clang-800.0.42.1)
Target: x86_64-apple-macosx10.9
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file hello.swift -target x86_64-apple-macosx10.9 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -color-diagnostics -module-name hello -o /var/folders/r7/q5y959494nl8rg1yy6th6gd40045kr/T/hello-522055.o
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld /var/folders/r7/q5y959494nl8rg1yy6th6gd40045kr/T/hello-522055.o -force_load /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/arc/libarclite_macosx.a -framework CoreFoundation -v -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -lobjc -lSystem -arch x86_64 -L /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx -rpath /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx -macosx_version_min 10.9.0 -no_objc_category_merging -o hello
@(#)PROGRAM:ld PROJECT:ld64-274.1
configured to support archs: armv6 armv7 armv7s arm64 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em (tvOS)
Library search paths:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/lib
Framework search paths:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks/
~> otool hello -o | grep "Swift class"
data 0x1000042d9 (struct class_ro_t *) Swift class
data 0x100004369 (struct class_ro_t *) Swift class
data 0x1000043f9 (struct class_ro_t *) Swift class
The text was updated successfully, but these errors were encountered: