-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Add support for emitting Mach-O R2R images #121186
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
base: main
Are you sure you want to change the base?
Changes from all commits
d42ffff
e986264
e43818f
573526b
0e87b5c
979fa8a
82c25a4
9db182f
9a08c72
3283658
c612d9b
a2d5718
986d789
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -506,19 +506,7 @@ public void EmitObject(Stream outputFileStream, IReadOnlyCollection<DependencyNo | |
|
|
||
| string rangeNodeName = GetMangledName(range); | ||
|
|
||
| if (!_definedSymbols.TryGetValue(startNodeName, out var startSymbol) | ||
| || !_definedSymbols.TryGetValue(endNodeName, out var endSymbol)) | ||
| { | ||
| throw new InvalidOperationException("The symbols defined by a symbol range must be emitted into the same object."); | ||
| } | ||
|
|
||
| if (startSymbol.SectionIndex != endSymbol.SectionIndex) | ||
| { | ||
| throw new InvalidOperationException("The symbols that define a symbol range must be in the same section."); | ||
| } | ||
|
|
||
| // Don't use SectionWriter here as it emits symbols relative to the current writing position. | ||
| EmitSymbolDefinition(startSymbol.SectionIndex, rangeNodeName, startSymbol.Value, checked((int)(endSymbol.Value - startSymbol.Value))); | ||
| EmitSymbolRangeDefinition(rangeNodeName, startNodeName, endNodeName); | ||
| } | ||
|
|
||
| foreach (BlockToRelocate blockToRelocate in blocksToRelocate) | ||
|
|
@@ -591,6 +579,22 @@ public void EmitObject(Stream outputFileStream, IReadOnlyCollection<DependencyNo | |
| } | ||
| } | ||
|
|
||
| private protected virtual void EmitSymbolRangeDefinition(string rangeNodeName, string startNodeName, string endNodeName) | ||
| { | ||
| if (!_definedSymbols.TryGetValue(startNodeName, out var startSymbol) | ||
| || !_definedSymbols.TryGetValue(endNodeName, out var endSymbol)) | ||
| { | ||
| throw new InvalidOperationException("The symbols defined by a symbol range must be emitted into the same object."); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have seen There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We use string.Format for user-facing errors. This would be a bug in ILC, so we aren't using the localized formatting as any time a user sees this would be a bug. |
||
| } | ||
|
|
||
| if (startSymbol.SectionIndex != endSymbol.SectionIndex) | ||
| { | ||
| throw new InvalidOperationException("The symbols that define a symbol range must be in the same section."); | ||
| } | ||
| // Don't use SectionWriter here as it emits symbols relative to the current writing position. | ||
| EmitSymbolDefinition(startSymbol.SectionIndex, rangeNodeName, startSymbol.Value, checked((int)(endSymbol.Value - startSymbol.Value))); | ||
| } | ||
|
|
||
| private static string GetNodeTypeName(Type nodeType) | ||
| { | ||
| string name = nodeType.ToString(); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ namespace ILCompiler.DependencyAnalysis | |
| { | ||
| public enum ReadyToRunContainerFormat | ||
| { | ||
| PE | ||
| PE, | ||
| MachO, | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For my own education - do you refer here to start and end symbols?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been told that the apple linker has issues when you define two symbols at the same address.
To emit our symbol range concept (where the begin and end of a range are both pointing at existing symbols), the common implementation would emit a start symbol definition at the same symbol as the first symbol in the range.
As a result, we have a custom implementation for MachO (which is actually really nice with the subtractor relocs so we can truly represent the symbol range within the Mach format).