Skip to content

Commit 791ca54

Browse files
author
Alexander Shaposhnikov
committed
Add .note.swift_reflection_metadata
1 parent fa38b01 commit 791ca54

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

stdlib/public/runtime/ImageInspectionELF.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#ifndef SWIFT_RUNTIME_IMAGEINSPECTIONELF_H
2020
#define SWIFT_RUNTIME_IMAGEINSPECTIONELF_H
2121

22+
#define SWIFT_REFLECTION_METADATA_ELF_NOTE_MAGIC_STRING "swift_reflection_metadata_magic_string"
23+
2224
#if defined(__ELF__)
2325

2426
#include "../SwiftShims/Visibility.h"
@@ -54,6 +56,8 @@ struct MetadataSections {
5456
Range swift5_assocty;
5557
Range swift5_replace;
5658
Range swift5_replac2;
59+
Range swift5_builtin;
60+
Range swift5_capture;
5761
};
5862
} // namespace swift
5963

stdlib/public/runtime/SwiftRT-ELF.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ DECLARE_SWIFT_SECTION(swift5_fieldmd)
3434
DECLARE_SWIFT_SECTION(swift5_assocty)
3535
DECLARE_SWIFT_SECTION(swift5_replace)
3636
DECLARE_SWIFT_SECTION(swift5_replac2)
37+
DECLARE_SWIFT_SECTION(swift5_builtin)
38+
DECLARE_SWIFT_SECTION(swift5_capture)
3739
}
3840

3941
#undef DECLARE_SWIFT_SECTION
@@ -65,10 +67,22 @@ static void swift_image_constructor() {
6567
SWIFT_SECTION_RANGE(swift5_assocty),
6668
SWIFT_SECTION_RANGE(swift5_replace),
6769
SWIFT_SECTION_RANGE(swift5_replac2),
70+
SWIFT_SECTION_RANGE(swift5_builtin),
71+
SWIFT_SECTION_RANGE(swift5_capture),
6872
};
6973

7074
#undef SWIFT_SECTION_RANGE
7175

7276
swift_addNewDSOImage(&sections);
7377
}
7478

79+
__asm__(".section \".note.swift_reflection_metadata\", \"aw\"");
80+
81+
static __attribute__((__used__))
82+
__attribute__((__section__(".note.swift_reflection_metadata")))
83+
__attribute__((__aligned__(1)))
84+
struct {
85+
const char MagicString[sizeof(SWIFT_REFLECTION_METADATA_ELF_NOTE_MAGIC_STRING)];
86+
const swift::MetadataSections *Sections;
87+
} __attribute__((__packed__))
88+
Note = {SWIFT_REFLECTION_METADATA_ELF_NOTE_MAGIC_STRING, &sections};

0 commit comments

Comments
 (0)