-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Linux strip command breaks single-file, native assemblies in 3.1 #37334
Comments
Tagging subscribers to this area: @swaroop-sridhar |
Here's an even more minimal way of reproducing the error: # create a new HelloWorld project
mkdir HelloWorld
cd HelloWorld
dotnet new console Update the HelloWorld.csproj file: <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<PublishTrimmed>true</PublishTrimmed>
<PublishReadyToRunShowWarnings>true</PublishReadyToRunShowWarnings>
<PublishReadyToRun>true</PublishReadyToRun>
<PublishSingleFile>true</PublishSingleFile>
</PropertyGroup>
</Project> And then the last bit: # natively compile our binary
dotnet publish -r linux-x64 -c Release /p:DebugType=None
# check that it works
bin/Release/netcoreapp3.1/linux-x64/publish/HelloWorld
# verify that the following strip command destroys the binary
strip bin/Release/netcoreapp3.1/linux-x64/publish/HelloWorld
bin/Release/netcoreapp3.1/linux-x64/publish/HelloWorld |
@MichaelStromberg thanks for reporting the issue. The single-file bundler writes meta-data with absolute offsets, which is consumed by the host components at run-time. The post-processing with Solving this problem may require generating single-file bundles in coopeartion with the native linker, so that the bundle header (and embedded files) can be located without relying on absolute offsets. (CC: @janvorli) In a way, both single-file apps, and rpm are packaging solutions. So, I'm curious why you'd use both technologies in conjunction. Thanks. |
Due to lack of recent activity, this issue has been marked as a candidate for backlog cleanup. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will undo this process. This process is part of our issue cleanup automation. |
Description
When including single-file, native binaries in an rpm package, the strip command is also typically run. For example, on a CentOS 7 system, rpmbuild runs the following script: /usr/lib/rpm/redhat/brp-strip-comment-note
brp-strip-comment-note executes "strip -R .comment -R .note " on each binary and library that's being added to an RPM package. This strips the .comment and the .note sections from the binary. When this happens on a .NET Core 3.1.300 single-file, native binary; the file gets truncated and corrupted.
Running the original binary works well:
Comparing this file with the original yields:
$ ls -la Nirvana -rwxr-xr-x 1 user 504 74861535 Jun 2 18:47 Nirvana $ strip -R .comment -R .note Nirvana $ ls -la Nirvana -rwxr-xr-x 1 user 504 90552 Jun 2 18:48 Nirvana $ ./Nirvana Failure processing application bundle; possible file corruption. I/O failure reading contents of the bundle. A fatal error was encountered. Could not extract contents of the bundle
Configuration
Other information
The text was updated successfully, but these errors were encountered: