flat assembler
Message board for the users of flat assembler.
Index
> Linux > Can Fasm make .o ELF object files?[solved, thanks] |
Author |
|
Tomasz Grysztar 03 Aug 2017, 19:04
The ELF object examples are included in the "fasm for Linux" package, so you may have missed them because you work on Windows. They look like:
Code: ; MSGDEMO.ASM ; fasm demonstration of assembling object files ; compile the program using commands like: ; fasm msgdemo.asm msgdemo.o ; fasm writemsg.asm writemsg.o ; ld msgdemo.o writemsg.o -o msgdemo format ELF section '.text' executable public _start _start: extrn writemsg mov esi,msg call writemsg mov eax,1 xor ebx,ebx int 0x80 section '.data' writeable msg db "Elves are coming!",0xA,0 Code: ; WRITEMSG.ASM format ELF section '.text' executable public writemsg writemsg: mov ecx,esi find_end: lodsb or al,al jnz find_end mov edx,esi sub edx,ecx mov eax,4 mov ebx,1 int 0x80 ret |
|||
03 Aug 2017, 19:04 |
|
system error 03 Aug 2017, 19:19
As already stated by TG, you can compile ELF64 in Windows and produce the desired .o object file, exporting via public keywords. However, if you want to make it workable in windows, you should not use any of the Linux-specific services.
Code: format ELF64 ;just compile it normally public business business: ;the non linux-specific code ret That's it. You can then use them as GCC's extern in mingw via linking. Code: #include <stdio.h> extern void business(void); int main() { business(); return 0; } Linking (I used TDM-GCC-64 btw) Code: gcc -m64 yourcode.c business.o -o yourcode.exe |
|||
03 Aug 2017, 19:19 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.