When creating the ArchSpec of a PECOFF file, if the subsystem field in the header indicates a windows subsystem, we use Win32 as the OS.
Diff Detail
Event Timeline
This doesn't seem right. PowerPC and Thumb on Windows? Greg, does OSX use any of this PECOFF code?
I know we have uses of PECOFF for EFI, but our EFI guys actually run a converter to convert their PECOFF file over into mach-o and they use those when debugging in LLDB. So I don' think this change will affect anything on our end. But just to be safe, is there anything else that you can look at inside the PECOFF file to make sure the OS should be set to windows? Any hints in the imports/exports? I can ask our EFI guys for one of their PECOFF files if needed.
Well, I just need to set the correct OS when creating the ArchSpec so that it works well in conjunction with https://reviews.llvm.org/D24283. If I get it somehow from Target, would that be good enough?
I was assuming that PECOFF was win-only and I have no idea of what else to look for in the PECOFF file to determine the OS.
coff contains a subsystem field. Take a look at llvm/Support/COFF.h then search, for example, for IMAGE_SUBSYSTEM_EFI_APPLICATION. This is part of an enum called WindowsSubsystem. This field should exist in all PE/COFF files. I don't know if LLDB parses it. If it does you can just it. If not you might have to add some logic to extract this field out yourself. I agree it probably won't affect anything since this code isn't used by much outside of Windows, but I would rather the code be correct.
omg, i feel ashamed for not noticing that when i was reading the documentation, I'll do as you say, thanks!
Go ahead and changes this for now, we'll see if we run into problems. I believe PECOFF is really only used on Windows right now, so we can worry about this when and if we run into problem.
I was able to use that field and saw the field IMAGE_SUBSYSTEM_WINDOWS_GUI in the libraries I was loading
I would pass llvm::Triple::UnknownOS instead of the constant 0, but otherwise this looks fine. I'll commit this later today.
Looks good.
source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp | ||
---|---|---|
973 | Use llvm::Triple::UnknownOS instead of 0 here and this will be good to go. |
Use llvm::Triple::UnknownOS instead of 0 here and this will be good to go.