carlokok opened PR #1836 from feature/object_file_section
to master
:
This fixes #1640.
What it does is two things:
- Expose a new api on the data context type to set the section of the current data item
- Emit it in the Object backend
I have no idea how to write a testcase for this or if it's meaningful at all.
I don't know who can review this.
bjorn3 submitted PR Review.
bjorn3 created PR Review Comment:
Can you add an assertion that it isn't a tls data object? Those only work for
StandardSection::Tls
.
carlokok updated PR #1836 from feature/object_file_section
to master
:
This fixes #1640.
What it does is two things:
- Expose a new api on the data context type to set the section of the current data item
- Emit it in the Object backend
I have no idea how to write a testcase for this or if it's meaningful at all.
I don't know who can review this.
carlokok updated PR #1836 from feature/object_file_section
to master
:
This fixes #1640.
What it does is two things:
- Expose a new api on the data context type to set the section of the current data item
- Emit it in the Object backend
I have no idea how to write a testcase for this or if it's meaningful at all.
I don't know who can review this.
carlokok updated PR #1836 from feature/object_file_section
to master
:
This fixes #1640.
What it does is two things:
- Expose a new api on the data context type to set the section of the current data item
- Emit it in the Object backend
I have no idea how to write a testcase for this or if it's meaningful at all.
I don't know who can review this.
pchickey requested pchickey for a review on PR #1836.
pchickey submitted PR Review.
pchickey submitted PR Review.
pchickey created PR Review Comment:
idiomatic would be to just say
seg.to_owned()
rather than useString::from
. Also, maybe this method should be namedset_segment_section
?
pchickey created PR Review Comment:
In Rust, we don't use assertions to indicate that the user provided bad input to a library function, instead we use the error type of the function's
Result
. In this case, we want to do something like:if let Some((segment, section)) = datasection { return Err(cranelift_module::ModuleError::Backend(anyhow::anyhow!("Custom section not supported by cranelift-faerie: `{}:{}`", segment, section))); } ~~~
pchickey created PR Review Comment:
same as before, return an Err(ModuleError::Backend(anyhow!(...))) rather than assert here please.
pchickey created PR Review Comment:
std::string::String
is always in scope asString
so style would be to just sayString
here. Also, we should note in the comment what each member of the pair is for - I think they are for segment and section, right? should we make the field namedcustom_segment_section
to reflect that? Is there ever a use case where you'd want to specify a section but not a segment (maybe you're letting a linker script determine segments from section names?)
pchickey created PR Review Comment:
I think for the simplejit backend we'd be better off just ignoring the custom segment/section than throwing an error here.
bjorn3 submitted PR Review.
bjorn3 created PR Review Comment:
For mach-O files the linker is always responsible for picking the right segment. In fact the object files should only contain a single segment.
pchickey submitted PR Review.
pchickey created PR Review Comment:
Thanks @bjorn3. So it sounds like we should be specifying a custom section and a custom segment in two different fields.
carlokok submitted PR Review.
carlokok created PR Review Comment:
@bjorn3 maybe i misunderstand but this:
seg: __OBJC
sec: __image_infobesides
seg: __DATA
sec __dataisn't unusual on mach-o. (that said, segments are ignored on non mach-o afaik)
philipc created PR Review Comment:
For mach-O files the linker is always responsible for picking the right segment. In fact the object files should only contain a single segment.
My understanding is that the linker uses the segment name specified in the object file. Note that segment names appear in two places: in the segment and in the section. The linker ignores the first of these, but still uses the segment name in the section. It has to do this, because
__const
can appear in both__TEXT
and__DATA
.
philipc submitted PR Review.
carlokok updated PR #1836 from feature/object_file_section
to master
:
This fixes #1640.
What it does is two things:
- Expose a new api on the data context type to set the section of the current data item
- Emit it in the Object backend
I have no idea how to write a testcase for this or if it's meaningful at all.
I don't know who can review this.
carlokok updated PR #1836 from feature/object_file_section
to master
:
This fixes #1640.
What it does is two things:
- Expose a new api on the data context type to set the section of the current data item
- Emit it in the Object backend
I have no idea how to write a testcase for this or if it's meaningful at all.
I don't know who can review this.
carlokok requested pchickey for a review on PR #1836.
pchickey merged PR #1836.
Last updated: Dec 23 2024 at 13:07 UTC