Skip to content
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 support #5

Open
AnErrupTion opened this issue Dec 30, 2022 · 4 comments
Open

Linux support #5

AnErrupTion opened this issue Dec 30, 2022 · 4 comments

Comments

@AnErrupTion
Copy link

Hi!

First of all, thanks for your amazing work! It's really nice to be able to run an assembler directly in C# code! :D

Second, I'd like to know if Linux support is planned. That is, detecting the OS having a FASM binary for that instead of just assuming the OS being Windows. It'd be a really nice touch in my opinion.

@Sewer56
Copy link
Member

Sewer56 commented Dec 30, 2022

There are fasmDLL options for Linux, yeah, it's something I can certainly do down the road. Maybe also make it so it doesn't drop the other platforms' DLLs when not necessary.

Just a matter of testing it; I'd ever need to rely on CI/CD to test the code or pull up a virtual machine. A project I might be working on soon (no guarantees though) might make use of Linux/OSX support so it's not our of question.

@sanny-io
Copy link

@Sewer56 any updates? I am interested in working on this if not. Would a PR be welcome?

@Sewer56
Copy link
Member

Sewer56 commented Sep 15, 2023

It's not possible (without a rewrite of FASM itself) to my knowledge, I actually tried a few months ago. Here's what I remember:

First of all, you have to port fasmDLL itself to Linux. It turns out that while fasm has actual Linux binaries, there is not a dynamically linked .so file that you can create.

So I wrote some assembly to get exports working on Linux, however; it's still not possible to use. Problem is, the code is not relocatable, and there's no mechanism (that I'm aware of) that's equivalent to Windows' .reloc section, which can be used to relocate offsets within the binary at load time. So even as library, it has to be loaded at fixed memory address which is problematic.

@Sewer56
Copy link
Member

Sewer56 commented Sep 15, 2023

Here's the code from my aforementioned experiment:

FasmDLL.zip

I lifted out all the DLL stuff back then, cleanly.
So you should be able to build DLL against the latest FASM sources.

I have no idea how I could get it to relocate with a .so file.

I don't remember the exact build steps for this, but I believe you extract the SOURCE folder to FASM's source code, then assemble FASM.ASM/FASMX64.ASM (in the DLL folder) for your desired target platform.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants