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 {
10781078 write32le (buf + 10 , target->getRVA () - rva - 14 );
10791079}
10801080
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+
10811097size_t CHPERedirectionChunk::getSize () const {
10821098 return exportThunks.size () * sizeof (chpe_redirection_entry);
10831099}
Original file line number Diff line number Diff line change @@ -749,6 +749,17 @@ class ECCodeMapChunk : public NonSectionChunk {
749749 std::vector<ECCodeMapEntry> ↦
750750};
751751
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+
752763class CHPERedirectionChunk : public NonSectionChunk {
753764public:
754765 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) {
24442444 ctx.symtab .addAbsolute (" __arm64x_redirection_metadata_count" , 0 );
24452445 ctx.symtab .addAbsolute (" __hybrid_code_map" , 0 );
24462446 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 );
24472449 }
24482450
24492451 if (config->pseudoRelocs ) {
Original file line number Diff line number Diff line change @@ -2071,6 +2071,12 @@ void Writer::createECChunks() {
20712071 replaceSymbol<DefinedSynthetic>(codeMapSym, codeMapSym->getName (),
20722072 codeMapChunk);
20732073
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+
20742080 CHPERedirectionChunk *entryPoints = make<CHPERedirectionChunk>(exportThunks);
20752081 a64xrmSec->addChunk (entryPoints);
20762082 Symbol *entryPointsSym =
@@ -2186,6 +2192,10 @@ void Writer::setECSymbols() {
21862192 pdata.first ->getRVA ());
21872193 }
21882194
2195+ Symbol *rangesCountSym =
2196+ ctx.symtab .findUnderscore (" __x64_code_ranges_to_entry_points_count" );
2197+ cast<DefinedAbsolute>(rangesCountSym)->setVA (exportThunks.size ());
2198+
21892199 Symbol *entryPointCountSym =
21902200 ctx.symtab .findUnderscore (" __arm64x_redirection_metadata_count" );
21912201 cast<DefinedAbsolute>(entryPointCountSym)->setVA (exportThunks.size ());
Original file line number Diff line number Diff line change @@ -66,7 +66,7 @@ __chpe_metadata:
6666 .word 1
6767 .rva __hybrid_code_map
6868 .word __hybrid_code_map_count
69- .word 0 // __x64_code_ranges_to_entry_points
69+ .rva __x64_code_ranges_to_entry_points
7070 .rva __arm64x_redirection_metadata
7171 .rva __os_arm64x_dispatch_call_no_redirect
7272 .rva __os_arm64x_dispatch_ret
@@ -75,7 +75,7 @@ __chpe_metadata:
7575 .rva __os_arm64x_check_icall_cfg
7676 .word 0 // __arm64x_native_entrypoint
7777 .word 0 // __hybrid_auxiliary_iat
78- .word 0 // __x64_code_ranges_to_entry_points_count
78+ .word __x64_code_ranges_to_entry_points_count
7979 .word __arm64x_redirection_metadata_count
8080 .rva __os_arm64x_get_x64_information
8181 .rva __os_arm64x_set_x64_information
Original file line number Diff line number Diff line change @@ -58,7 +58,10 @@ EXP-CHPE: CodeMap [
5858EXP-CHPE-NEXT: 0x1000 - 0x100C ARM64EC
5959EXP-CHPE-NEXT: 0x2000 - 0x3020 X64
6060EXP-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: ]
6265EXP-CHPE-NEXT: RedirectionMetadata [
6366EXP-CHPE-NEXT: 0x3000 -> 0x1000
6467EXP-CHPE-NEXT: 0x3010 -> 0x1000
@@ -121,7 +124,9 @@ ENTRY-CHPE: CodeMap [
121124ENTRY-CHPE-NEXT: 0x1000 - 0x100C ARM64EC
122125ENTRY-CHPE-NEXT: 0x2000 - 0x2010 X64
123126ENTRY-CHPE-NEXT: ]
124- ENTRY-CHPE-NEXT: CodeRangesToEntryPoints: 0
127+ ENTRY-CHPE-NEXT: CodeRangesToEntryPoints [
128+ ENTRY-CHPE-NEXT: 0x2000 - 0x2010 -> 0x2000
129+ ENTRY-CHPE-NEXT: ]
125130ENTRY-CHPE-NEXT: RedirectionMetadata [
126131ENTRY-CHPE-NEXT: 0x2000 -> 0x1000
127132ENTRY-CHPE-NEXT: ]
Original file line number Diff line number Diff line change @@ -34,7 +34,9 @@ PATCH-CHPE: CodeMap [
3434PATCH-CHPE-NEXT: 0x1000 - 0x1008 ARM64EC
3535PATCH-CHPE-NEXT: 0x2000 - 0x2010 X64
3636PATCH-CHPE-NEXT: ]
37- PATCH-CHPE-NEXT: CodeRangesToEntryPoints: 0
37+ PATCH-CHPE-NEXT: CodeRangesToEntryPoints [
38+ PATCH-CHPE-NEXT: 0x2000 - 0x2010 -> 0x2000
39+ PATCH-CHPE-NEXT: ]
3840PATCH-CHPE-NEXT: RedirectionMetadata [
3941PATCH-CHPE-NEXT: 0x2000 -> 0x1000
4042PATCH-CHPE-NEXT: ]
You can’t perform that action at this time.
0 commit comments