dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.37k stars 4.75k forks source link

Run the ilc .sln project ILCompiler, and the object file it generates is garbled #88513

Closed tangyanzhi closed 1 year ago

tangyanzhi commented 1 year ago

Description

I ran the ILCompiler project, generated the repro.obj file, opened repro.obj with Notepad and saw garbled characters, how to solve this problem?

repro.obj path is:...\artifacts\bin\repro\x64\Debug

image

Reproduction Steps

As shown above

Expected behavior

I want to open repro.obj to see what's inside

Actual behavior

I want to open repro.obj to see what's inside, but it's garbled

Regression?

No response

Known Workarounds

No response

Configuration

E:\Visual Studio Project\ConsoleApp9\ConsoleApp3>dotnet --info
.NET SDK:
 Version:   8.0.100-preview.5.23303.2
 Commit:    3fe444af72

 OS Name:     Windows
 OS Version:  10.0.22621
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\8.0.100-preview.5.23303.2\

.NET workloads installed:

Host:
  Version:      8.0.0-preview.5.23280.8
  Architecture: x64
  Commit:       bc78804f5d

.NET SDKs installed:
  7.0.100 [C:\Program Files\dotnet\sdk]
  7.0.304 [C:\Program Files\dotnet\sdk]
  8.0.100-preview.5.23303.2 [C:\Program Files\dotnet\sdk]

Other information

No response

MichalStrehovsky commented 1 year ago

.obj file format is a binary file format, similar to .exe. One doesn't use Notepad to inspect either of those. You can e.g. use dumpbin /all repro.obj to look at the contents. Docs for dumpbin are here: https://learn.microsoft.com/en-us/cpp/build/reference/dumpbin-command-line?view=msvc-170. There are other tools that can open this too, searching the internet helps.

tangyanzhi commented 1 year ago

.obj file format is a binary file format, similar to .exe. One doesn't use Notepad to inspect either of those. You can e.g. use dumpbin /all repro.obj to look at the contents. Docs for dumpbin are here: https://learn.microsoft.com/en-us/cpp/build/reference/dumpbin-command-line?view=msvc-170. There are other tools that can open this too, searching the internet helps.

Use .Net7, i can open this repro.obj file with Notepad, why not now?

MichalStrehovsky commented 1 year ago

.obj file format is a binary file format, similar to .exe. One doesn't use Notepad to inspect either of those. You can e.g. use dumpbin /all repro.obj to look at the contents. Docs for dumpbin are here: https://learn.microsoft.com/en-us/cpp/build/reference/dumpbin-command-line?view=msvc-170. There are other tools that can open this too, searching the internet helps.

Use .Net7, i can open this repro.obj file with Notepad, why not now?

Can you post a screenshot of what you see?

tangyanzhi commented 1 year ago

.obj file format is a binary file format, similar to .exe. One doesn't use Notepad to inspect either of those. You can e.g. use dumpbin /all repro.obj to look at the contents. Docs for dumpbin are here: https://learn.microsoft.com/en-us/cpp/build/reference/dumpbin-command-line?view=msvc-170. There are other tools that can open this too, searching the internet helps.

Use .Net7, i can open this repro.obj file with Notepad, why not now?

Can you post a screenshot of what you see?

yes ,A few previous images can be found

image

image

image

MichalStrehovsky commented 1 year ago

yes ,A few previous images can be found

This is not contents of the obj file opened in Notepad. This is a disassembly. Whatever produced the disassembly for the .NET 7 object file should be able to produce it for .NET 8 as well, but I don't know what you used on 7.

tangyanzhi commented 1 year ago

yes ,A few previous images can be found

This is not contents of the obj file opened in Notepad. This is a disassembly. Whatever produced the disassembly for the .NET 7 object file should be able to produce it for .NET 8 as well, but I don't know what you used on 7.

This is Notepad

Inside obj are assembly code and other debugging symbols for linking purposes. I remember opening it with Notepad before, but now I don't know why it doesn't work.

tangyanzhi commented 1 year ago

yes ,A few previous images can be found

This is not contents of the obj file opened in Notepad. This is a disassembly. Whatever produced the disassembly for the .NET 7 object file should be able to produce it for .NET 8 as well, but I don't know what you used on 7.

Sorry, I remember, at that time I exported repro.obj to notepad via dumpbin, so the screenshot is notepad, but not obj files cannot be opened directly with notepad.

Thank you for your answer