This adds the /filealign parameter to lld, which allows to specify the section alignment in the output file (as it does on Microsoft's link.exe).
This is required to be able to load dynamically linked libraries on the original Xbox, where the debugger monitor expects the section alignment in the file to be the same as in memory.
Details
- Reviewers
ruiu
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Can you write a patch description? Please mention that Microsoft link.exe has this option.
Could you tell me a little bit about why you wanted this option?
It needs a testcase.
lld/COFF/Config.h | ||
---|---|---|
183 | We use the same name for a command line option and a Config member name, so FileAlign. |
Changed Config member name, added a test.
The test currently only checks the FileAlignment header field - I wanted to check the individual section offsets, too, but llvm-objdump doesn't expose this information.
Did you personally need this? Or are you adding this just for completeness?
Either case is fine, but I'd like to know what is a use case of this feature.
I didn't need this myself, but the need for it came up during the work of another XboxDev member who worked on adding support for debug extensions to our toolchain targeting the original Xbox (called nxdk), and I decided to try and add this feature. Due to the lack of /filealign-support we currently have a workaround in place: https://github.com/JayFoxRox/nxdk/pull/10/commits/1822465478b04ca18d5544c103bfe743ad47876c#diff-6ffdcfc2a5d215955b49510d4547fc8cR19
Ideally we would be able to have filealign==align (which this patch makes possible, removing the need for the workaround) and be able to choose a small value for this (which would require hooking up /align, which I do plan to do, too) to minimize memory usage (the Xbox only has 64MiB of RAM and there has to be enough left for the application, so our debug extensions aren't allowed to consume much space).
Th
lld/COFF/Driver.cpp | ||
---|---|---|
1190 | Thank you for your explanation. One last thing -- can you add a check to make sure that a parsed value is a power of two? |
We use the same name for a command line option and a Config member name, so FileAlign.