[lld] [lld][macho] Support order cstrings with -order_file_cstring (PR #140307)
Ellis Hoag via llvm-commits
llvm-commits at lists.llvm.org
Tue May 20 10:51:53 PDT 2025
ellishg wrote:
`--symbol_ordering_file` is only available for ELF and for MachO we have `-order_file`. On MachO we have a special `__cstring` section that only holds string data instead of the `__data` section. For ELF, that string data is stored in the `.rodata` data section which presumably could be ordered relative to other read-only data.
https://godbolt.org/z/sKqfWj5Kq
The format of `-order_file` already allows for prefixes depending on the platform and object file.
https://github.com/llvm/llvm-project/blob/51e222ef48222e6e5745b96a484164dbdcaea239/lld/MachO/SectionPriorities.cpp#L307-L314
I think we could extend this to support the literal prefix `<cstr>:`. I do see the benefit of reusing the same flag and input file, especially if we can share the same format with ELF.
And on ELF it looks like the format doesn't support any prefixes yet, but I can't think of any reason why it couldn't.
https://github.com/llvm/llvm-project/blob/0931874b219cfdae38fcf24d33c8efa001697d5a/lld/ELF/Driver.cpp#L1237-L1246
https://github.com/llvm/llvm-project/pull/140307
More information about the llvm-commits
mailing list