dotnet / runtimelab

This repo is for experimentation and exploring new ideas that may or may not make it into the main dotnet/runtime repo.
MIT License
1.4k stars 196 forks source link

[NativeAOT] Convert file to ELF file for Syslinux #1438

Open AnErrupTion opened 3 years ago

AnErrupTion commented 3 years ago

I've been trying out NativeAOT (because it's cool) and I have a slight problem: I cannot use the generated file directly with Syslinux. It complains that it's not an ELF file, so I tried to convert the file to an ELF one (or at least an ELF-compatible one). However, I can't find a lot about that online, the only program that I saw could do that was the GNU tool (so a Unix tool, not Windows tool) objcopy, and there doesn't seem to be a direct equivalent of it for Windows.

Maybe I'm doing this all wrong and this is not the approach to take, I kind of need help on this.

By the way, here's the exact error: Invalid Multiboot image: neither ELF header nor a.out kludge found

Also, here's my mkisofs command that I use to create the ISO, if that helps: mkisofs -relaxed-filenames -J -R -o output.iso -b isolinux.bin -no-emul-boot -boot-load-size 4 -boot-info-table boot/

boot is the directory that contains all required files to make the ISO bootable, it includes the Syslinux files and the file generated by NativeAOT.

MichalStrehovsky commented 3 years ago

How are you building the thing you're trying. We should be producing ELF files when targeting Linux, but it's possible the Syslinux loader has some specific requirements. I don't know much about Syslinux.

AnErrupTion commented 3 years ago

I'm building on Windows, I have a Windows version of mkisofs. I'm building with dotnet publish, with the win-x64 platform.

MichalStrehovsky commented 3 years ago

Publishing as win-x64 creates an executable that calls into Win32 APIs. Unless there's a Win32 API emulator, this is not going to work even if you manage to convert the EXE to an ELF file.

What are you trying to achieve? Is there a Linux kernel available in your setup or is Syslinux trying to load this before the OS is loaded?