Open argium opened 3 years ago
Tagging subscribers to this area: @dotnet/area-system-console See info in area-owners.md if you want to be subscribed.
Author: | requilium |
---|---|
Assignees: | - |
Labels: | `area-System.Console`, `untriaged` |
Milestone: | - |
@jkotas followup from email.
Tagging subscribers to this area: @agocke, @vitek-karas, @vsadov See info in area-owners.md if you want to be subscribed.
Author: | requilium |
---|---|
Assignees: | - |
Labels: | `area-Single-File`, `area-System.Console`, `untriaged` |
Milestone: | - |
This is unfortunately expected right now. On Linux (and on Windows) the single-file is created by simply appending to existing executable. We don't modify the headers in any way in this case. That means that the file is technically not valid per the file format specification, but OS loaders don't care. Some other tools do care though.
@VSadov to comment on possible ideas on how complex it would be to fixup the ELF and PE headers (similar to what we do on macOS), but I don't think this will be possible in .NET 6.
It should be possible to put single-file payload into a file section in both ELF and PE case and could be more straightforward than in the case of Mach-O. The difficulties will be in carefully patching the existing file structure for the presence of another section.
Right now HostModel has very little support for parsing/writing these formats, especially for ELF, this is basically all of it. Some additional support will need to be built up. This does not look like something we would try to fit in 6.0
Ideally, you would want it arrange it such that the OS maps the payload in exactly as we need it, with the right executable permissions and relocs.
Description
We use .NET5 to create self-contained linux binaries. Our linux service engineers have asked us to stamp ELF metadata on all files that run in production. .NET5 produces binaries that are non-standard and cannot be modified using tools like objcopy.
<PublishSingleFile>true</PublishSingleFile>
to the csprojdotnet publish -r linux-x64
objcopy ConsoleApp1 ConsoleApp2
Expected: ConsoleApp2 should run
Actual:
Configuration
.net version = 5.0.301
Regression?
Unsure.
Other information
N/A