Author |
Thread |
 |
|
|
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/ld: i386 architecture of input file `fasm.o' is incompatible with i386:x86-64 output
collect2: error: ld 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]
|
15 Jun 2016, 03:29 |
|
revolution
When all else fails, read the source
Joined: 24 Aug 2004
Posts: 15641
Location: Thasus
|
Set your linker to output a 32-bit executable.
|
15 Jun 2016, 03:46 |
|
|
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
|
|
|
15 Jun 2016, 03:55 |
|
revolution
When all else fails, read the source
Joined: 24 Aug 2004
Posts: 15641
Location: Thasus
|
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
|
15 Jun 2016, 04:16 |
|
|
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/lib32/ 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
|
|
Still searches the 64-bit libs, in spite of -L/usr/lib32/
It must be something really dumb...
|
15 Jun 2016, 04:35 |
|
revolution
When all else fails, read the source
Joined: 24 Aug 2004
Posts: 15641
Location: Thasus
|
Perhaps using LD directly (without going through GCC) will help?
|
15 Jun 2016, 04:39 |
|
|
Another failed attempt:
Code: |
ld -m elf_i386 fasm.o /usr/lib32/libgcc_s.so.1 -o fasm
ld: fasm.o: undefined reference to symbol 'exit@@GLIBC_2.0'
//lib/i386-linux-gnu/libc.so.6: error adding symbols: DSO 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.
|
15 Jun 2016, 04:42 |
|
|
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: ./fasm: No such file or directory
|
|
even though the file is there...
[/quote][/code]
|
15 Jun 2016, 05:14 |
|
revolution
When all else fails, read the source
Joined: 24 Aug 2004
Posts: 15641
Location: Thasus
|
Have you marked it as executable? I'm not sure if LD does this automatically or not.
|
15 Jun 2016, 05:20 |
|
|
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: ./fasm: No such file or directory
|
|
Also,
Code: |
stacksmith@eli:~/src/fasm$ objdump fasm -x
fasm: file format elf32-i386
fasm
architecture: i386, flags 0x00000112:
EXEC_P, HAS_SYMS, D_PAGED
start address 0x08048560
|
|
I think I may be linking against wrong libraries, or in the wrong order or something like that... Any ideas?
|
15 Jun 2016, 07:09 |
|
Tomasz Grysztar
Assembly Artist
Joined: 16 Jun 2003
Posts: 6774
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.
|
15 Jun 2016, 08:23 |
|
|
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.
|
15 Jun 2016, 16:02 |
|
Tomasz Grysztar
Assembly Artist
Joined: 16 Jun 2003
Posts: 6774
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).
|
15 Jun 2016, 17:02 |
|
|
Looks like I goofed somehow. Thanks.
|
15 Jun 2016, 18:20 |
|
|
|