[lld] [lld] Align EC code region boundaries. (PR #69100)
Jacek Caban via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 20 10:30:43 PDT 2023
================
@@ -1421,8 +1421,19 @@ void Writer::assignAddresses() {
// If /FUNCTIONPADMIN is used, functions are padded in order to create a
// hotpatchable image.
uint32_t padding = sec->isCodeSection() ? config->functionPadMin : 0;
+ MachineTypes prevECMachine = IMAGE_FILE_MACHINE_UNKNOWN;
for (Chunk *c : sec->chunks) {
+ if (isArm64EC(ctx.config.machine) && sec->isCodeSection()) {
+ MachineTypes machine = c->getMachine();
+ if (machine != IMAGE_FILE_MACHINE_UNKNOWN) {
+ // We need additional alignment when crossing EC range baudaries.
+ if (prevECMachine != IMAGE_FILE_MACHINE_UNKNOWN &&
+ machine != prevECMachine)
+ virtualSize = alignTo(virtualSize, 4096);
+ prevECMachine = machine;
+ }
----------------
cjacek wrote:
We can't use continue here because we still need to run the rest of the loop. I looked as simplifying `IMAGE_FILE_MACHINE_UNKNOWN` handling, which inspired me to do more MSVC testing and finding a potentially interesting behavior. It seems to preserve the fact that a chunk is a data chunk even when it's merged to a code section. I need to think more about it and run more tests, we may want to do something similar.
https://github.com/llvm/llvm-project/pull/69100
More information about the llvm-commits
mailing list