Skip to content

lld-link ignores section alignments greater than /ALIGN #137043

New issue

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

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

Already on GitHub? # to your account

Open
beetrees opened this issue Apr 23, 2025 · 1 comment
Open

lld-link ignores section alignments greater than /ALIGN #137043

beetrees opened this issue Apr 23, 2025 · 1 comment
Labels

Comments

@beetrees
Copy link
Contributor

The COFF object format supports section alignments up to 8192, whereas the default value of the /ALIGN command line argument (used as the alignment of all sections in the PE output) is 4096. If a section in a COFF object file has an alignment greater than the value of /ALIGN (such as in this Rust example), MSVC link.exe will exit with an LNK1164 linker error, whereas LLVM lld-link will ignore it and continue to use the smaller value of /ALIGN as the alignment of the sections in the PE output.

@llvmbot
Copy link
Member

llvmbot commented Apr 23, 2025

@llvm/issue-subscribers-lld-coff

Author: None (beetrees)

The COFF object format supports section alignments up to 8192, whereas the default value of the `/ALIGN` command line argument (used as the alignment of all sections in the PE output) is 4096. If a section in a COFF object file has an alignment greater than the value of `/ALIGN` (such as in [this Rust example](https://github.com/rust-lang/rust/issues/70144#issuecomment-2825245012)), MSVC `link.exe` will exit with an [LNK1164 linker error](https://learn.microsoft.com/en-us/cpp/error-messages/tool-errors/linker-tools-error-lnk1164?view=msvc-170), whereas LLVM `lld-link` will ignore it and continue to use the smaller value of `/ALIGN` as the alignment of the sections in the PE output.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants