Skip to content

[LLD][COFF] Emit base relocation for native CHPE metadata pointer on ARM64X #121500

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions lld/COFF/Chunks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,22 @@ void SectionChunk::getBaserels(std::vector<Baserel> *res) {
continue;
res->emplace_back(rva + rel.VirtualAddress, ty);
}

// Insert a 64-bit relocation for CHPEMetadataPointer in the native load
// config of a hybrid ARM64X image. Its value will be set in prepareLoadConfig
// to match the value in the EC load config, which is expected to be
// a relocatable pointer to the __chpe_metadata symbol.
COFFLinkerContext &ctx = file->symtab.ctx;
if (ctx.hybridSymtab && ctx.symtab.loadConfigSym &&
ctx.symtab.loadConfigSym->getChunk() == this &&
ctx.hybridSymtab->loadConfigSym &&
ctx.symtab.loadConfigSize >=
offsetof(coff_load_configuration64, CHPEMetadataPointer) +
sizeof(coff_load_configuration64::CHPEMetadataPointer))
res->emplace_back(
ctx.symtab.loadConfigSym->getRVA() +
offsetof(coff_load_configuration64, CHPEMetadataPointer),
IMAGE_REL_BASED_DIR64);
}

// MinGW specific.
Expand Down
6 changes: 5 additions & 1 deletion lld/test/COFF/arm64x-loadconfig.s
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,14 @@
// BASERELOC: BaseReloc [
// BASERELOC-NEXT: Entry {
// BASERELOC-NEXT: Type: DIR64
// BASERELOC-NEXT: Address: 0x10C8
// BASERELOC-NEXT: }
// BASERELOC-NEXT: Entry {
// BASERELOC-NEXT: Type: DIR64
// BASERELOC-NEXT: Address: 0x1208
// BASERELOC-NEXT: }
// BASERELOC-NEXT: Entry {
// BASERELOC: Type: DIR64
// BASERELOC-NEXT: Type: DIR64
// BASERELOC-NEXT: Address: 0x2074
// BASERELOC-NEXT: }

Expand Down
Loading