-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
write/macho: ensure Mach-O subsections are not zero size #676
Conversation
This is to fix rust-lang/rustc_codegen_cranelift#1456, along with the cranelift change in philipc/wasmtime@d851125 |
Note that rustc_codegen_cranelift isn't currently setting |
This code in llvm confirms that basing this on llvm always sets |
For zero length functions, llvm emits a noop instead: I'm not keen on handling this here. I think that's better done in cranelift if needed. |
@bjorn3 Are you happy with this change? |
This PR looks fine to me. |
For Mach-O, `add_symbol_data` now ensures that the symbol size is at least 1 when subsections via symbols are enabled. This change was made to support linking with ld-prime. It is also unclear how this previously managed to work with ld64. `write::Object::add_subsection` no longer enables subsections via symbols for Mach-O. Use `set_subsections_via_symbols` instead. This change was made because Mach-O subsections are all or nothing, so this decision must be made before any symbols are added. `write::Object::add_subsection` no longer adds data to the subsection. This change was made because it was done with `append_section_data`, but this is often not the correct way to add data to the subsection. Usually `add_symbol_data` is a better choice.
For Mach-O, `add_symbol_data` now ensures that the symbol size is at least 1 when subsections via symbols are enabled. This change was made to support linking with ld-prime. It is also unclear how this previously managed to work with ld64. `write::Object::add_subsection` no longer enables subsections via symbols for Mach-O. Use `set_subsections_via_symbols` instead. This change was made because Mach-O subsections are all or nothing, so this decision must be made before any symbols are added. `write::Object::add_subsection` no longer adds data to the subsection. This change was made because it was done with `append_section_data`, but this is often not the correct way to add data to the subsection. Usually `add_symbol_data` is a better choice.
For Mach-O,
add_symbol_data
now ensures that the symbol size is at least 1 when subsections via symbols are enabled. This change was made to support linking with ld-prime. It is also unclear how this previously managed to work with ld64.write::Object::add_subsection
no longer enables subsections via symbols for Mach-O. Useset_subsections_via_symbols
instead. This change was made because Mach-O subsections are all or nothing, so this decision must be made before any symbols are added.write::Object::add_subsection
no longer adds data to the subsection. This change was made because it was done withappend_section_data
, but this is often not the correct way to add data to the subsection. Usuallyadd_symbol_data
is a better choice.