[lld] [LLD] [COFF] Print a warning when using /dependentloadflag without load config (PR #117400)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 2 01:06:45 PST 2024
alvinhochun wrote:
Sorry for the late reply.
I'm still hesitant about the positioning of the check. May I suggest @rnk to take a look?
I also want to point out that
https://github.com/llvm/llvm-project/blob/3a31427224d4fa49d7ef737b21f6027dc4928ecf/lld/COFF/Writer.cpp#L2634-L2635
only sets the `DependentLoadFlags` field of `_load_config_used` if it is set to a non-zero value. This means passing `/dependentloadflag:0` is effectively a no-op, so that if the `_load_config_used` struct already has a non-zero value set in that field, LLD will *not* clear the flag. I am not sure if this is intended – if it is, then setting it to 0 should probably not give the warning. (CC @nurmukhametov @tru @aganea from #71537)
One more note that is not strictly related to this PR: Before setting the field, there seems to be no checks to make sure the `_load_config_used` points to a struct that is actually big enough to contain the field. Is it possible that if a user supplies a malformed `_load_config_used` struct, LLD would end up corrupting something else in the output binary?
> `lld-link: warning: '_load_config_used' is misaligned (expected alignment to be 8 bytes, got 1 instead)`
(It probably just needs a `.p2align 3` before the start of the struct.)
https://github.com/llvm/llvm-project/pull/117400
More information about the llvm-commits
mailing list