Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

write: Create symbols for sections #503

Closed
wants to merge 1 commit into from

Conversation

afonso360
Copy link
Contributor

馃憢 Hey,

It looks like we don't automatically create a symbol when adding a section, this PR changes that.

See rust-lang/rustc_codegen_cranelift#1249 (comment) for some context.

@philipc
Copy link
Contributor

philipc commented Jan 15, 2023

Section symbols aren't required for every section. Is there a reason the caller can't do this for the sections that it knows need the symbols?

@afonso360
Copy link
Contributor Author

Not really, but I thought it would make sense to have that as a default and perhaps add an opt out version of add_symbol. But it might be better to do that as a user of the crate.

@philipc
Copy link
Contributor

philipc commented Jan 15, 2023

I prefer not to have it as the default because generally they aren't required (at least for ELF). If there's something special about COFF that requires it, then maybe we can add something to detect those cases. Have you tested whether this change fixes anything in the linked issue, or did you only check that section symbols were added? It's not clear to me that this will actually fix anything.

@afonso360
Copy link
Contributor Author

afonso360 commented Jan 15, 2023

This is not a full fix for the issue above. I've only tested with both the section symbols and the read only initializer sections, and that does fix it although I was planning on doing that as a separate PR.

Although testing it again it seems that just marking the sections as readonly seems sufficient to fix the issue. Given that I think we can probably close this.

Do you think marking the .CRT$XC* subsections as read only would make sense to include as part of this crate, or would it be better to fix as a user of the crate?

@afonso360 afonso360 closed this Jan 15, 2023
@philipc
Copy link
Contributor

philipc commented Jan 15, 2023

Do you think marking the .CRT$XC* subsections as read only would make sense to include as part of this crate

No, the user determines that by specifying the SectionKind for add_section. This crate shouldn't be second guessing what the user requested.

@bjorn3
Copy link
Contributor

bjorn3 commented Jan 15, 2023

I think the .CRT$XC* issue is that https://github.com/bytecodealliance/wasmtime/blob/e4dc9c79443259e40f3e93b9c7815b0645ebd5c4/cranelift/object/src/backend.rs#L460 needs to be ReadOnlyDataWithRel rather than Data.

@afonso360 afonso360 deleted the section-symbols branch January 15, 2023 13:08
@philipc
Copy link
Contributor

philipc commented Jan 15, 2023

Yes that looks like the issue. However, currently there isn't a SectionKind::ReadOnlyDataWithRel. Maybe we need to add one, since the current behaviour for StandardSection::ReadOnlyDataWithRel varies between formats. That is, SectionKind::Data might be correct for ELF so it shouldn't be changed.

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

Successfully merging this pull request may close these issues.

None yet

3 participants