I compile this code.
// a.swift
struct Stone {
var weight: Int = 3
}
I emitted LLVM-IR with $ swiftc -emit-ir a.swift
.
I found a pointer to nominal type descriptor in full type metadata.
@"$s1a5StoneVMf" = internal constant <{ i8**, i64, <{ i32, i32, i32, i32, i32, i32, i32 }>*, i32, [4 x i8] }>
<{
i8** @"$sBi64_WV",
i64 512,
<{ i32, i32, i32, i32, i32, i32, i32 }>* @"$s1a5StoneVMn",
i32 0,
[4 x i8] zeroinitializer
}>, align 8
I emitted object file and looked it with
$ swiftc -emit-object a.swift
$ objdump -x -s a.o
I found it.
SYMBOL TABLE:
0000000000000100 l O __DATA,__const _$s1a5StoneVMf
Contents of section __const:
0100 00000000 00000000 00020000 00000000 ................
0110 00000000 00000000 00000000 00000000 ................
RELOCATION RECORDS FOR [__const]:
0000000000000000 X86_64_RELOC_UNSIGNED _$sBi64_WV
Relocation records about _$sBi64_WV
corresponds to first field of full type metadata in LLVM-IR.
Value 00020000 00000000
at 0108
also corresponds to second field which is 512 in decimal.
But I couldn't find relocation record about $s1a5StoneVMn
for third field.
Why does not exist in relocation records?
How does represent linking to nominal type descriptor in object format?
Environment:
Xcode-beta Version 11.0 beta 4 (11M374r)
Apple Swift version 5.1 (swiftlang-1100.0.257.2 clang-1100.0.31.3)
Target: x86_64-apple-darwin19.0.0