[lld] [LLD][COFF] Align import directory chunk. (PR #80014)

Jacek Caban via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 30 07:53:37 PST 2024


cjacek wrote:

I think LLD always emitted unaligned import dir and it generally works fine (I just verified that it happened on aarch64, x86 and x86_64), the loader can handle it. It's not optimal and it's not what I observe with MSVC link.exe.

In my case, I was trying to find why some of ARM64X binaries load fine, while others don't (it requires my WIP branch). I narrowed it down to a subset of cases, where ARM64X base relocations need to modify import directory. Generally, aarch64 and arm64ec imports are shared. As long as they use the same set of functions from import directory, both the directory and import addresses chunk are just shared. When used set of functions differs, ARM64X dynamic relocations are used to modify import dir to point to different names and import addresses for its EC view.

Aligning import directory chunk fixed the problem. I suspect that loader expects some alignment on ARM64X dynamic relocation offset (but I didn't dig deeper into the loader itself) and it wasn't the case when relocated import dir was not aligned.

I will add a more specific test case.

https://github.com/llvm/llvm-project/pull/80014


More information about the llvm-commits mailing list