flat assembler
Message board for the users of flat assembler.

Index > Linux > How to get the fasm listing program to build pure 64 Linux?

Author
Thread Post new topic Reply to topic
JoeCoder1



Joined: 13 Jun 2011
Posts: 62
JoeCoder1
Hi. I used fasm for a small program and I was AMAZED at the speed and small executable size. Great!

I have a few Linux boxes and they are all single lib either 32 bit or 64 bit. On my 32 bit systems I had no problems building the listing tool and it works great. On 64 bit it doesn't build. Before I paste the error messages I wanted to ask here in case anybody knows the answer already.
Post 13 Jun 2011, 08:22
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
I guess you are building with gcc? Try using "gcc -m32...". Perhaps it will fail as well, in that case you may need to install the i386 dev libc package of your distro (in Debian and Ubuntu it is this one), and if it still fails then yes please, paste the error here.
Post 13 Jun 2011, 17:53
View user's profile Send private message Reply with quote
mindcooler



Joined: 01 Dec 2009
Posts: 423
Location: Västerås, Sweden
mindcooler
You can't compile 32-bit code for 64-bit or vice versa directly. Either use multilib or write it for both architectures.
Post 13 Jun 2011, 21:49
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
JoeCoder1



Joined: 13 Jun 2011
Posts: 62
JoeCoder1
Uh guys, I am asking about the *listing tool* not my own code. Does anybody know how to get it to build on pure 64 Linux? Thanks.
Post 14 Jun 2011, 07:08
View user's profile Send private message Reply with quote
mindcooler



Joined: 01 Dec 2009
Posts: 423
Location: Västerås, Sweden
mindcooler
There is a FASM listing program? And it exists in both a 32-bit and a 64-bit version?
Post 14 Jun 2011, 12:41
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Quote:

Does anybody know how to get it to build on pure 64 Linux? Thanks.

If it is pure enough to not even support 32-bit executables then forget it, you can't. In case it is not, then do what I've said but also use "-static" (never tried this myself, though).

Alternatively you could do the "-static" thing from a 32-bit box or from a non-pure 64-bit distro and then copy the executable to your pure 64-bit box (but again, it must at least being capable of running 32-bit programs).
Post 14 Jun 2011, 15:28
View user's profile Send private message Reply with quote
TmX



Joined: 02 Mar 2006
Posts: 821
Location: Jakarta, Indonesia
TmX
mindcooler wrote:
There is a FASM listing program? And it exists in both a 32-bit and a 64-bit version?


If you're using Linux, check TOOLS\LIBC.
AFAIK it's a 32-bit asm, and not 64-bit.
Post 14 Jun 2011, 16:34
View user's profile Send private message Reply with quote
JoeCoder1



Joined: 13 Jun 2011
Posts: 62
JoeCoder1
LocoDelAssembly wrote:
Quote:

Does anybody know how to get it to build on pure 64 Linux? Thanks.

If it is pure enough to not even support 32-bit executables then forget it, you can't. In case it is not, then do what I've said but also use "-static" (never tried this myself, though).

Alternatively you could do the "-static" thing from a 32-bit box or from a non-pure 64-bit distro and then copy the executable to your pure 64-bit box (but again, it must at least being capable of running 32-bit programs).


Sorry man I have no idea what you are talking about. I didn't use gcc to build it on my 32 bit linux, I just used fasm. I don't understand what I should do to make it work with fasm on my 64 bit linux because other programs I write work fine in fasm on the 64 bit system.

I don't think 32 bit code will run on my pure 64 bit linux.
Post 15 Jun 2011, 10:54
View user's profile Send private message Reply with quote
JoeCoder1



Joined: 13 Jun 2011
Posts: 62
JoeCoder1
TmX wrote:
mindcooler wrote:
There is a FASM listing program? And it exists in both a 32-bit and a 64-bit version?


If you're using Linux, check TOOLS\LIBC.
AFAIK it's a 32-bit asm, and not 64-bit.


I guess you are right so we are back to my original question. How do we get this to work on 64 bit. and you must be aware, if i knew anything about fasm or assembly on x86 i wouldn't be asking this question so if somebody can't tell me how to fix it, i will not understand what you are suggesting.
Post 15 Jun 2011, 10:56
View user's profile Send private message Reply with quote
JoeCoder1



Joined: 13 Jun 2011
Posts: 62
JoeCoder1
mindcooler wrote:
There is a FASM listing program? And it exists in both a 32-bit and a 64-bit version?


Apparently it only exists in a 32 bit version but I don't know what has to be done to make it work in 64 bit which is why I asked in this thread.

If you look in the tools/libc directory of your fasm install on linux you will see the listing tool.
Post 15 Jun 2011, 10:57
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
JoeCoder1, did you successfully compile the tools in a 32-bit box? Please show how you did it.

This is how I just got it made in Ubuntu:
Code:
loco@ubuntu:~/fasm$ lsb_release -a
No LSB modules are available.
Distributor ID:        Ubuntu
Description:      Ubuntu 10.04.2 LTS
Release:      10.04
Codename:  lucid
loco@ubuntu:~/fasm$ uname -a
Linux ubuntu 2.6.32-32-server #62-Ubuntu SMP Wed Apr 20 22:07:43 UTC 2011 x86_64 GNU/Linux
loco@ubuntu:~/fasm$ sudo apt-get install libc6-dev-i386
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  gcc-4.4-multilib gcc-multilib lib32gcc1 lib32gomp1 libc6-i386
Suggested packages:
  lib32mudflap0
The following NEW packages will be installed:
  gcc-4.4-multilib gcc-multilib lib32gcc1 lib32gomp1 libc6-dev-i386 libc6-i386
0 upgraded, 6 newly installed, 0 to remove and 56 not upgraded.
Need to get 7,674kB of archives.
After this operation, 18.8MB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://archive.ubuntu.com/ubuntu/ lucid-updates/main libc6-i386 2.11.1-0ubuntu7.8 [3,710kB]
Get:2 http://archive.ubuntu.com/ubuntu/ lucid-updates/main libc6-dev-i386 2.11.1-0ubuntu7.8 [1,553kB]
Get:3 http://archive.ubuntu.com/ubuntu/ lucid/main lib32gcc1 1:4.4.3-4ubuntu5 [55.3kB]
Get:4 http://archive.ubuntu.com/ubuntu/ lucid/main lib32gomp1 4.4.3-4ubuntu5 [24.9kB]
Get:5 http://archive.ubuntu.com/ubuntu/ lucid/main gcc-4.4-multilib 4.4.3-4ubuntu5 [2,329kB]
Get:6 http://archive.ubuntu.com/ubuntu/ lucid/main gcc-multilib 4:4.4.3-1ubuntu1 [862B]                                     
Fetched 7,674kB in 32s (234kB/s)                                                                                            
Selecting previously deselected package libc6-i386.
(Reading database ... 145594 files and directories currently installed.)
Unpacking libc6-i386 (from .../libc6-i386_2.11.1-0ubuntu7.8_amd64.deb) ...
Selecting previously deselected package libc6-dev-i386.
Unpacking libc6-dev-i386 (from .../libc6-dev-i386_2.11.1-0ubuntu7.8_amd64.deb) ...
Selecting previously deselected package lib32gcc1.
Unpacking lib32gcc1 (from .../lib32gcc1_1%3a4.4.3-4ubuntu5_amd64.deb) ...
Selecting previously deselected package lib32gomp1.
Unpacking lib32gomp1 (from .../lib32gomp1_4.4.3-4ubuntu5_amd64.deb) ...
Selecting previously deselected package gcc-4.4-multilib.
Unpacking gcc-4.4-multilib (from .../gcc-4.4-multilib_4.4.3-4ubuntu5_amd64.deb) ...
Selecting previously deselected package gcc-multilib.
Unpacking gcc-multilib (from .../gcc-multilib_4%3a4.4.3-1ubuntu1_amd64.deb) ...
Setting up libc6-i386 (2.11.1-0ubuntu7.8) ...

Setting up libc6-dev-i386 (2.11.1-0ubuntu7.8) ...
Setting up lib32gcc1 (1:4.4.3-4ubuntu5) ...

Setting up lib32gomp1 (4.4.3-4ubuntu5) ...

Setting up gcc-4.4-multilib (4.4.3-4ubuntu5) ...
Setting up gcc-multilib (4:4.4.3-1ubuntu1) ...
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place
loco@ubuntu:~/fasm$ ./fasm tools/libc/prepsrc.asm 
flat assembler  version 1.69.31  (16384 kilobytes memory)
4 passes, 2229 bytes.
loco@ubuntu:~/fasm$ gcc -m32 tools/libc/prepsrc.o -o tools/libc/prepsrc
loco@ubuntu:~/fasm$ gcc -m32 -static tools/libc/prepsrc.o -o tools/libc/prepsrc-static
loco@ubuntu:~/fasm$ ls -l tools/libc/prepsrc*
-rwxr-xr-x 1 loco loco   7620 2011-06-15 15:25 tools/libc/prepsrc
-rw-rw-r-- 1 loco loco   1405 2011-02-07 07:39 tools/libc/prepsrc.asm
-rw-r--r-- 1 loco loco   2229 2011-06-15 15:21 tools/libc/prepsrc.o
-rwxr-xr-x 1 loco loco 604717 2011-06-15 15:23 tools/libc/prepsrc-static
loco@ubuntu:~/fasm$ tools/libc/prepsrc
preprocessed source dumper for flat assembler
usage: prepsrc <input> <output>
loco@ubuntu:~/fasm$ tools/libc/prepsrc-static 
preprocessed source dumper for flat assembler
usage: prepsrc <input> <output>    
In theory, using prepsrc-static on a pure 64-bit system should work (unless the kernel doesn't have support for 32-bit processes). In my case, the "purity" was only in the lack of 32-bit libc libraries, but if the kernel were compiled for 64-bit processes only (if possible at all), then it wouldn't worked.
Post 15 Jun 2011, 18:31
View user's profile Send private message Reply with quote
JoeCoder1



Joined: 13 Jun 2011
Posts: 62
JoeCoder1
LocoDelAssembly wrote:
JoeCoder1, did you successfully compile the tools in a 32-bit box? Please show how you did it.


Yes on 32 bit system I just did fasm listing.asm

and then gcc -o listing listing.o

and it works good.

But on 64 bit system fasm generates a 32 bit object module because of the ELF header in the listing.asm file. If I change that to ELF64 I break the code and get this:

fasm@slack64:~/tmp/asm/tools/libc$ fasm listing.asm
flat assembler version 1.69.31 (16384 kilobytes memory)
listing.asm [22]:
ccall exit,2
ccall.inc [4] ccall [1]:
push ebp
error: illegal instruction.

Question is how I can link 32 bit object on 64 bit system or what I should change in the listing.asm program to make it work on elf64 format. Thanks.
Post 16 Jun 2011, 09:38
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Just impossible, the program is not portable to 64-bit, your system must run the tool as 32-bit mode unconditionally. If you want to keep your system pure, then, just compile it on a 32-bit box using the "-static" specifier and then copy the 32-bit binary to your 64-bit system.

If you want to link right from the 64-bit system (but always generating a 32-bit executable and linking 32-bit objects), then my console dump above is the answer (but of course it is no longer a "pure 64-bit environment")
Post 16 Jun 2011, 17:07
View user's profile Send private message Reply with quote
JoeCoder1



Joined: 13 Jun 2011
Posts: 62
JoeCoder1
Thanks Loco, I will try the first suggestion and tell you if it works or not.
Post 16 Jun 2011, 17:20
View user's profile Send private message Reply with quote
JoeCoder1



Joined: 13 Jun 2011
Posts: 62
JoeCoder1
Hey Loco, muchas gracias...it works! So simple, great solution Smile

OMG 598K statically linked! libc is huge!

Go assembly, go fasm!
Post 16 Jun 2011, 17:25
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.