File tree Expand file tree Collapse file tree 7 files changed +51
-5
lines changed Expand file tree Collapse file tree 7 files changed +51
-5
lines changed Original file line number Diff line number Diff line change @@ -1078,6 +1078,22 @@ void ECExportThunkChunk::writeTo(uint8_t *buf) const {
1078
1078
write32le (buf + 10 , target->getRVA () - rva - 14 );
1079
1079
}
1080
1080
1081
+ size_t CHPECodeRangesChunk::getSize () const {
1082
+ return exportThunks.size () * sizeof (chpe_code_range_entry);
1083
+ }
1084
+
1085
+ void CHPECodeRangesChunk::writeTo (uint8_t *buf) const {
1086
+ auto ranges = reinterpret_cast <chpe_code_range_entry *>(buf);
1087
+
1088
+ for (uint32_t i = 0 ; i < exportThunks.size (); i++) {
1089
+ Chunk *thunk = exportThunks[i].first ;
1090
+ uint32_t start = thunk->getRVA ();
1091
+ ranges[i].StartRva = start;
1092
+ ranges[i].EndRva = start + thunk->getSize ();
1093
+ ranges[i].EntryPoint = start;
1094
+ }
1095
+ }
1096
+
1081
1097
size_t CHPERedirectionChunk::getSize () const {
1082
1098
return exportThunks.size () * sizeof (chpe_redirection_entry);
1083
1099
}
Original file line number Diff line number Diff line change @@ -749,6 +749,17 @@ class ECCodeMapChunk : public NonSectionChunk {
749
749
std::vector<ECCodeMapEntry> ↦
750
750
};
751
751
752
+ class CHPECodeRangesChunk : public NonSectionChunk {
753
+ public:
754
+ CHPECodeRangesChunk (std::vector<std::pair<Chunk *, Defined *>> &exportThunks)
755
+ : exportThunks(exportThunks) {}
756
+ size_t getSize () const override ;
757
+ void writeTo (uint8_t *buf) const override ;
758
+
759
+ private:
760
+ std::vector<std::pair<Chunk *, Defined *>> &exportThunks;
761
+ };
762
+
752
763
class CHPERedirectionChunk : public NonSectionChunk {
753
764
public:
754
765
CHPERedirectionChunk (std::vector<std::pair<Chunk *, Defined *>> &exportThunks)
Original file line number Diff line number Diff line change @@ -2444,6 +2444,8 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
2444
2444
ctx.symtab .addAbsolute (" __arm64x_redirection_metadata_count" , 0 );
2445
2445
ctx.symtab .addAbsolute (" __hybrid_code_map" , 0 );
2446
2446
ctx.symtab .addAbsolute (" __hybrid_code_map_count" , 0 );
2447
+ ctx.symtab .addAbsolute (" __x64_code_ranges_to_entry_points" , 0 );
2448
+ ctx.symtab .addAbsolute (" __x64_code_ranges_to_entry_points_count" , 0 );
2447
2449
}
2448
2450
2449
2451
if (config->pseudoRelocs ) {
Original file line number Diff line number Diff line change @@ -2071,6 +2071,12 @@ void Writer::createECChunks() {
2071
2071
replaceSymbol<DefinedSynthetic>(codeMapSym, codeMapSym->getName (),
2072
2072
codeMapChunk);
2073
2073
2074
+ CHPECodeRangesChunk *ranges = make<CHPECodeRangesChunk>(exportThunks);
2075
+ rdataSec->addChunk (ranges);
2076
+ Symbol *rangesSym =
2077
+ ctx.symtab .findUnderscore (" __x64_code_ranges_to_entry_points" );
2078
+ replaceSymbol<DefinedSynthetic>(rangesSym, rangesSym->getName (), ranges);
2079
+
2074
2080
CHPERedirectionChunk *entryPoints = make<CHPERedirectionChunk>(exportThunks);
2075
2081
a64xrmSec->addChunk (entryPoints);
2076
2082
Symbol *entryPointsSym =
@@ -2186,6 +2192,10 @@ void Writer::setECSymbols() {
2186
2192
pdata.first ->getRVA ());
2187
2193
}
2188
2194
2195
+ Symbol *rangesCountSym =
2196
+ ctx.symtab .findUnderscore (" __x64_code_ranges_to_entry_points_count" );
2197
+ cast<DefinedAbsolute>(rangesCountSym)->setVA (exportThunks.size ());
2198
+
2189
2199
Symbol *entryPointCountSym =
2190
2200
ctx.symtab .findUnderscore (" __arm64x_redirection_metadata_count" );
2191
2201
cast<DefinedAbsolute>(entryPointCountSym)->setVA (exportThunks.size ());
Original file line number Diff line number Diff line change @@ -66,7 +66,7 @@ __chpe_metadata:
66
66
.word 1
67
67
.rva __hybrid_code_map
68
68
.word __hybrid_code_map_count
69
- .word 0 // __x64_code_ranges_to_entry_points
69
+ .rva __x64_code_ranges_to_entry_points
70
70
.rva __arm64x_redirection_metadata
71
71
.rva __os_arm64x_dispatch_call_no_redirect
72
72
.rva __os_arm64x_dispatch_ret
@@ -75,7 +75,7 @@ __chpe_metadata:
75
75
.rva __os_arm64x_check_icall_cfg
76
76
.word 0 // __arm64x_native_entrypoint
77
77
.word 0 // __hybrid_auxiliary_iat
78
- .word 0 // __x64_code_ranges_to_entry_points_count
78
+ .word __x64_code_ranges_to_entry_points_count
79
79
.word __arm64x_redirection_metadata_count
80
80
.rva __os_arm64x_get_x64_information
81
81
.rva __os_arm64x_set_x64_information
Original file line number Diff line number Diff line change @@ -58,7 +58,10 @@ EXP-CHPE: CodeMap [
58
58
EXP-CHPE-NEXT: 0x1000 - 0x100C ARM64EC
59
59
EXP-CHPE-NEXT: 0x2000 - 0x3020 X64
60
60
EXP-CHPE-NEXT: ]
61
- EXP-CHPE-NEXT: CodeRangesToEntryPoints: 0
61
+ EXP-CHPE-NEXT: CodeRangesToEntryPoints [
62
+ EXP-CHPE-NEXT: 0x3000 - 0x3010 -> 0x3000
63
+ EXP-CHPE-NEXT: 0x3010 - 0x3020 -> 0x3010
64
+ EXP-CHPE-NEXT: ]
62
65
EXP-CHPE-NEXT: RedirectionMetadata [
63
66
EXP-CHPE-NEXT: 0x3000 -> 0x1000
64
67
EXP-CHPE-NEXT: 0x3010 -> 0x1000
@@ -121,7 +124,9 @@ ENTRY-CHPE: CodeMap [
121
124
ENTRY-CHPE-NEXT: 0x1000 - 0x100C ARM64EC
122
125
ENTRY-CHPE-NEXT: 0x2000 - 0x2010 X64
123
126
ENTRY-CHPE-NEXT: ]
124
- ENTRY-CHPE-NEXT: CodeRangesToEntryPoints: 0
127
+ ENTRY-CHPE-NEXT: CodeRangesToEntryPoints [
128
+ ENTRY-CHPE-NEXT: 0x2000 - 0x2010 -> 0x2000
129
+ ENTRY-CHPE-NEXT: ]
125
130
ENTRY-CHPE-NEXT: RedirectionMetadata [
126
131
ENTRY-CHPE-NEXT: 0x2000 -> 0x1000
127
132
ENTRY-CHPE-NEXT: ]
Original file line number Diff line number Diff line change @@ -34,7 +34,9 @@ PATCH-CHPE: CodeMap [
34
34
PATCH-CHPE-NEXT: 0x1000 - 0x1008 ARM64EC
35
35
PATCH-CHPE-NEXT: 0x2000 - 0x2010 X64
36
36
PATCH-CHPE-NEXT: ]
37
- PATCH-CHPE-NEXT: CodeRangesToEntryPoints: 0
37
+ PATCH-CHPE-NEXT: CodeRangesToEntryPoints [
38
+ PATCH-CHPE-NEXT: 0x2000 - 0x2010 -> 0x2000
39
+ PATCH-CHPE-NEXT: ]
38
40
PATCH-CHPE-NEXT: RedirectionMetadata [
39
41
PATCH-CHPE-NEXT: 0x2000 -> 0x1000
40
42
PATCH-CHPE-NEXT: ]
You can’t perform that action at this time.
0 commit comments