flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > Linux > Installing FASM on a modern 64-bit Linux

Author
Thread Post new topic Reply to topic
stacksmith



Joined: 15 Jun 2016
Posts: 8
Installing FASM on a modern 64-bit Linux
Most lini today are running in 64-bit mode. I've done it before somehow and have a ton of fasm code...

I cannot link the object file:

Code:

/usr/bin/ldi386 architecture of input file `fasm.o' is incompatible with i386:x86-64 output
collect2errorld returned 1 exit status




How is this done? Searching yields ridiculous advice about using qemu and bochs, installing a 32-bit linux in virtualbox etc. I know that 32-bit executables run on 64-bit linux, and that there is a way to link it somehow...

Help![/code]
Post 15 Jun 2016, 03:29
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 15160
Location: GW170817
Set your linker to output a 32-bit executable.
Post 15 Jun 2016, 03:46
View user's profile Send private message Visit poster's website Reply with quote
stacksmith



Joined: 15 Jun 2016
Posts: 8
tried:

Quote:
gcc -m32 fasm.o -o fasm
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/5/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/5/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
collect2: error: ld returned 1 exit status

Post 15 Jun 2016, 03:55
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 15160
Location: GW170817
You need to install the 32-bit libraries. Check with your OS documentation for how to do that. It's probably something like glibc-devel.i386
Post 15 Jun 2016, 04:16
View user's profile Send private message Visit poster's website Reply with quote
stacksmith



Joined: 15 Jun 2016
Posts: 8
I've been trying. I am using Xubuntu 14.04. ia32-libs used to do it, I think, but it was phased out. libc6-i386 has been installed, also multilib support for gcc and g++ (I have 5.3).

lnterestingly,

Code:
gcc -m32 -L/usr/lib32fasm.o  -o fasm
/usr/bin/ldskipping incompatible /usr/lib/gcc/x86_64-linux-gnu/5/libgcc.a when searching for -lgcc
/usr/bin/ldcannot find -lgcc
/usr/bin/ldskipping incompatible /usr/lib/gcc/x86_64-linux-gnu/5/libgcc_s.so when searching for -lgcc_s
/usr/bin/ldcannot find -lgcc_s
collect2errorld returned 1 exit status




Still searches the 64-bit libs, in spite of -L/usr/lib32/

It must be something really dumb...
Post 15 Jun 2016, 04:35
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 15160
Location: GW170817
Perhaps using LD directly (without going through GCC) will help?
Post 15 Jun 2016, 04:39
View user's profile Send private message Visit poster's website Reply with quote
stacksmith



Joined: 15 Jun 2016
Posts: 8
Another failed attempt:

Code:

ld -m elf_i386 fasm.o /usr/lib32/libgcc_s.so.1 -o fasm 
ldfasm.oundefined reference to symbol 'exit@@GLIBC_2.0'
//lib/i386-linux-gnu/libc.so.6error adding symbolsDSO missing from command line
.


Do you know what libraries I should link against - it appears I have to manually list them (similar discussion found elsewhere here in Unix messages.
Post 15 Jun 2016, 04:42
View user's profile Send private message Reply with quote
stacksmith



Joined: 15 Jun 2016
Posts: 8

Code:
ld -m elf_i386 fasm.o /usr/lib32/libgcc_s.so.1 /usr/lib32/crtn.o /usr/lib32/crt1.o /usr/lib32/crti.o /usr/lib32/libc.so  -L/usr/lib32  -o fasm



This actually links, but the executable is wacky:

Code:
./fasm 
bash./fasmNo such file or directory




even though the file is there...

[/quote][/code]
Post 15 Jun 2016, 05:14
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 15160
Location: GW170817
Have you marked it as executable? I'm not sure if LD does this automatically or not.
Post 15 Jun 2016, 05:20
View user's profile Send private message Visit poster's website Reply with quote
stacksmith



Joined: 15 Jun 2016
Posts: 8
It's executable:

Code:
stacksmith@eli:~/src/fasm$ ls -al
total 548
drwxrwxr-x  5 stacksmith stacksmith   4096 Jun 15 00:06 .
drwxrwxr-x 29 stacksmith stacksmith   4096 Jun 14 19:26 ..
drwxrwxr-x  3 stacksmith stacksmith   4096 Jun  9 04:57 examples
-rwxrwxr-x  1 stacksmith stacksmith 109393 Jun 15 00:06 fasm
-rw-rw-r--  1 stacksmith stacksmith 134138 Jun  9 04:53 fasm.o
-rw-rw-r--  1 stacksmith stacksmith 265836 Jun  9 04:57 fasm.txt
-rw-rw-r--  1 stacksmith stacksmith   1783 Jun  9 04:57 license.txt
-rw-rw-r--  1 stacksmith stacksmith    260 Jun  9 04:57 readme.txt
drwxrwxr-x  6 stacksmith stacksmith   4096 Jun  9 02:59 source
drwxrwxr-x  5 stacksmith stacksmith   4096 Jun  9 04:57 tools
-rw-rw-r--  1 stacksmith stacksmith  19411 Jun  9 04:57 whatsnew.txt
stacksmith@eli:~/src/fasm$ ./fasm
bash./fasmNo such file or directory



Also,

Code:
stacksmith@eli:~/src/fasm$ objdump fasm -x

fasm:     file format elf32-i386
fasm
architecturei386flags 0x00000112:
EXEC_PHAS_SYMSD_PAGED
start address 0x08048560




I think I may be linking against wrong libraries, or in the wrong order or something like that... Any ideas?
Post 15 Jun 2016, 07:09
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6602
Location: Kraków, Poland

stacksmith wrote:
I think I may be linking against wrong libraries, or in the wrong order or something like that... Any ideas?

Does the plain ELF executable version of fasm (the one that does not need any libraries) run on your system? If not, you probably have the execution of 32-bit programs disabled in the kernel.
Post 15 Jun 2016, 08:23
View user's profile Send private message Visit poster's website Reply with quote
stacksmith



Joined: 15 Jun 2016
Posts: 8
I've used the same system with older versions of fasm a year ago. The new distribution of fasm does not seem to have an executable (to my surprise) and the instructions suggest just linking the fasm.o with gcc.

I vaguely remember going through a similar exercise a few years back. I should've kept notes.. Not that it would've helped - the 32-bit compatibility libraries have been changed. I've used fasm for many years without issues.

On the other hand, my system is not at all remarkable - a 64-bit ubuntu with up-to-date gcc. I can't believe others haven't come acrosss this.

Perhaps someone could statically link fasm on Ubuntu and post a binary... As a command-line tool, it does not use strange libraries, and should run on at least debian systems.

I am at a bit of a loss (will investigate deeper today).

Just when I started feeling good about the state of linux and fasm (deleting expletives and disparaging thoughts...)

Thanks for your help.
Post 15 Jun 2016, 16:02
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6602
Location: Kraków, Poland

stacksmith wrote:
The new distribution of fasm does not seem to have an executable (to my surprise) and the instructions suggest just linking the fasm.o with gcc.

These are two different packages, and both are available with every release on the Download page. You can find the Linux executable in fasm-1.71.54.tgz, while fasm-1.71.54.tar.gz contains only the object file that has to be linked with 32-bit C library (the purpose of this package is to provide a version of fasm for Unix-like systems other than Linux).
Post 15 Jun 2016, 17:02
View user's profile Send private message Visit poster's website Reply with quote
stacksmith



Joined: 15 Jun 2016
Posts: 8
Looks like I goofed somehow. Thanks.
Post 15 Jun 2016, 18:20
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


Powered by phpBB © 2001-2005 phpBB Group.

Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2016, Tomasz Grysztar.