flat assembler
Message board for the users of flat assembler.

flat assembler > Unix > fasm under FreeBSD

Author
Thread Post new topic Reply to topic
pthien



Joined: 07 Oct 2003
Posts: 5
Is it possible to run fasm under FreeBSD? I use PureBasic, and I have found the executable programs generated on Linux run on FreeBSD (very limited testing). So I thought I'd try developing on FreeBSD (5.0), which I run one a notebook I use a lot. The pbcompiler (PureBasic compiler) runs fine, but when fasm gets called during the compile process, I get:

/usr/bin/fasm: Exec format error. Binary file not executable.

So I examined the file using "brandelf" and found it is a SVR4 (or something close to that, I'm a beginner and I'm doing this from memory, so please don't yell at me) header, which is the same as "pbcompiler." Just for kicks, I did a:

brandelf -t Linux fasm

but it didn't help.

Any ideas? I don't know which version of fasm the latest PureBasic for Linux compiler comes with, I was going to try the one from this web site tomorrow. Unless someone has another suggestion.
Post 07 Oct 2003, 00:28
View user's profile Send private message Reply with quote
scientica
Retired moderator


Joined: 16 Jun 2003
Posts: 689
Location: Linköping, Sweden
Are you sure you have execution permision? try do type something like
chmod 777 /usr/bin/fasm
(you might have to su if you installed fasm as root)

_________________
... a professor saying: "use this proprietary software to learn computer science" is the same as English professor handing you a copy of Shakespeare and saying: "use this book to learn Shakespeare without opening the book itself.
- Bradley Kuhn
Post 07 Oct 2003, 05:11
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
pthien



Joined: 07 Oct 2003
Posts: 5
Yep, I have the necessary permission.
Post 07 Oct 2003, 12:42
View user's profile Send private message Reply with quote
scientica
Retired moderator


Joined: 16 Jun 2003
Posts: 689
Location: Linköping, Sweden
pthien wrote:
I don't know which version of fasm the latest PureBasic for Linux compiler comes with, I was going to try the one from this web site tomorrow. Unless someone has another suggestion.

type:
less /usr/bin/fasm
y
[end key]

You should see something like:
Code:
    

can you see the line "flat assembler version 1.49", what version dos it say for you? (If it's not 1.49 I'd recomend that you update).

_________________
... a professor saying: "use this proprietary software to learn computer science" is the same as English professor handing you a copy of Shakespeare and saying: "use this book to learn Shakespeare without opening the book itself.
- Bradley Kuhn
Post 07 Oct 2003, 13:11
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
pthien



Joined: 07 Oct 2003
Posts: 5
% file fasm
fasm: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), statically linkedfile: corrupted section header size.

This is the output on a FreeBSD machine. I'll try a Red Hat 9 machine today. I don't know if FreeBSD isn't interpreting something correctly, or if there is indeed a problem in the header for fasm.

Feel free to jump-in any time if you have any input.

Thanks,
Phil
Post 09 Oct 2003, 12:59
View user's profile Send private message Reply with quote
scientica
Retired moderator


Joined: 16 Jun 2003
Posts: 689
Location: Linköping, Sweden
this is my output when using file:
Code:
[root@centralplexus mnt]# file /usr/local/bin/fasm-1.49/fasm
/usr/local/bin/fasm-1.49/fasm: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), statically linkedfile: corrupted section header size.    

But, Fasm works for me. (I'm using RedHAt8, and just compiled and installed hte 2.4.22 kernel, no problems. (not with the old kernel, 2.4.2-18(<-iirc)))

_________________
... a professor saying: "use this proprietary software to learn computer science" is the same as English professor handing you a copy of Shakespeare and saying: "use this book to learn Shakespeare without opening the book itself.
- Bradley Kuhn
Post 09 Oct 2003, 15:38
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6929
Location: Kraków, Poland
For "ELF executable" fasm doesn't generate any section headers (only program headers), as ELF specification says they are not needed in such case - so this is probably the reason of that message. But I don't know if it's related in any way to your problem with executing that executable in FreeBSD. But as PureBasic uses fasm's ELF object format output, this problem won't probably occur with any of your programs compiled with it.
Post 13 Oct 2003, 08:55
View user's profile Send private message Visit poster's website Reply with quote
bazik



Joined: 28 Jul 2003
Posts: 34
Location: .de
If you want to find out the version of your used fasm, run

`strings /usr/bin/fasm | grep version`

Smile
Post 23 Oct 2003, 09:28
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6929
Location: Kraków, Poland
pthien, can you check for me whether this problem is related to program headers put above the first 4 KB of file? If the "hello" example is working for you, add something like "times 4096 nop" at the end of its code, recompile it and check whether it's still working.
You may also try the latest prerelease version (it's posted in the "Main" forum) - I've redesigned the ELF executable formatter a bit, maybe that helps...
Post 29 Oct 2003, 22:32
View user's profile Send private message Visit poster's website Reply with quote
pthien



Joined: 07 Oct 2003
Posts: 5
Sorry it has taken so long to try this. I only had SuSE loaded, so I had to wait to try FreeBSD until I had another machine I could test.

Anyway, I tried the prerelease today and it still doesn't work in FreeBSD 5.1. I get:

./fasmnew: Exec format error. Binary file not executable

when I do a "file fasmnew" I get:

fasmnew: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), statically linked file: corrupted section header size.

I did a brandelf to change the type to Linux, but still it doesn't run.

I will attempt the suggestion above of adding the noop at the end of the code to see if my helloworld.pb program breaks on FreeBSD. I should be able to test faster now that I have a second PC to run FreeBSD on.

Thanks,
Phil
Post 05 Dec 2003, 19:35
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6929
Location: Kraków, Poland
That's strange, because I no longer get the "corrupted section header size" message when I do "file fasm" under Linux. Just to make sure, here's the prerelease I'm testing.

(I forgot to tell you that you need to recompile Linux version with the prerelease version first, perhaps you have compiled it using the old version?)
Post 06 Dec 2003, 02:19
View user's profile Send private message Visit poster's website Reply with quote
pthien



Joined: 07 Oct 2003
Posts: 5
Woops, sorry about that. I was trying a previous prerelease (fasm-1.49.9.5*, I believe). Anyway, I downloaded fasm-1.49.9.7.tar.gz and ran is on FreeBSD and (drum roll please...) SUCCESS!!! It runs! I haven't compiled any code with it yet, but yes, it DOES execute.

I did have to do a "brandelf -t Linux fasm" to get FreeBSD to execute it. I wonder whether that will be a problem with code it generates. Is it advisable to have it generate a header that indicates Linux instead of SYSV? Or is there a reason to have the header say SYSV instead? Otherwise I suppose those of us using it on FreeBSD will have to use a script that does a "brandelf" at the end.

Thanks for your help!

-Phil
Post 06 Dec 2003, 16:10
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-2018, Tomasz Grysztar.

Powered by rwasa.