newbie nasm 2.14.02 error

Issues related to applications and software problems
Post Reply
mikeburr
Posts: 15
Joined: 2019/09/06 11:40:11

newbie nasm 2.14.02 error

Post by mikeburr » 2019/09/06 12:59:51

Hi
I am trying to set up a 64 bit assembler Nasm 2.14.02 as I wish to transfer the maths programs i have written im Masm32 and put them on a Linux platform in 64 bit form
Firstly i seem to be having a problem with setting up Nasm .. in fact im assuming its compatible with GCC etc ??? ... and is compounded because i know very little about Linux although i did work on a Unix system for a short while using a very limited range of commands
1) I downloaded and extracted the tar.gz file [having first downloaded the xz and finding i didn't have the xz-util file]

2)Extracted this and the documentation in the Download directory [ was this not a good idea as i think it prob should go somewhere like usr/share ????? what does everyone else do .. i understand people might have different preferences ]

3)then after a bit of swearing realised that I needed to ./configure this file in the newly created
nasm-2.14.02 directory
the make
and subsequent make install seemed to work though im not sure if theres a log of this

4) nasm -f elf elftest.asm gave this
nasm: fatal: unable to open output file `elftest.o'
this turned out to be a permissions issue so i chmod -R 777 the nasm- directory [probably not a smart idea but it solved the problem but left the elftest.o with root ownership and required rm ing it later to recompile to get the offending error messages which are posted in 5)
then having got things sorted .. then next error ...

/bin/ld: i386 architecture of input file `elftest.o' is incompatible with i386:x86-64 output
collect2: error: ld returned 1 exit status

so i recompiled with
nasm -f elf64 elftest.asm [elf64 was a pure guess at the time]
and this created an output

5) ./elftest gave [ why cant you just click on elftest btw or use run from the Dolphin file manager rh click list ???]
error ....
Testing lrotate: should get 0x00400000, 0x00000001
Segmentation fault (core dumped)


ive no idea where the core dump is or whether id even be able to trace through it but the words segmentation fault didnt look promising
i the looked at the directory and noticed there is an elftest.c ??? but there is an elftest64.c
so i tried that and got the following
gcc -o elftest elftest64.c elftest.o
error....

/tmp/ccQeIYeL.o: In function `main':
elftest64.c:(.text+0x9e): undefined reference to `greet_s'
elftest64.c:(.text+0xa3): undefined reference to `greet_m'
elftest64.c:(.text+0xb2): undefined reference to `greet_s'
collect2: error: ld returned 1 exit status


CONCLUSION
Im hoping some kindly person/persons can help me Firstly get some order and sense into what im doing ... and secondly
i ultimately want to put a GUI front end on to what are basically a series of assembler routines
which i presume i can easily incorporate in a skeleton C program .. the thing is that under Windows there are a great many GUI API's, subroutines that facilitate both the construction of windows and their display though i found the latter far to constricting fot the huge amount of data being produced and eventually made something like a B-Tree [erasable ] in memory using a low level equivalent of malloc and paged it onto the screen .... are there similar facilities in Linux eg QT and is this the best way to go ????

I hope if any other Newbie coming from a Windows environment reads this it will give them a bit of a guideline into what NOT TO DO or otherwise help
regards mike b

User avatar
TrevorH
Forum Moderator
Posts: 26956
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: newbie nasm 2.14.02 error

Post by TrevorH » 2019/09/06 13:12:58

We don't recommend doing source installs except in exceptional circumstances. You can find a packaged copy of nasm in the third party EPEL repo. To get access to EPEL you can run yum --enablerepo=extras install epel-release then yum install nasm
CentOS 5 died in March 2017 - migrate NOW!
CentOS 6 goes EOL sooner rather than later, get upgrading!
Full time Geek, part time moderator. Use the FAQ Luke

mikeburr
Posts: 15
Joined: 2019/09/06 11:40:11

Re: newbie nasm 2.14.02 error

Post by mikeburr » 2019/09/06 16:59:12

Trevor
the version i first downloaded prob came from the same source just using sudo yum .. however it is version 2.10
the version i downloaded is 2.14 with some of the 32 -> 64 errors removed
thats why i tried this download route
regards mike b

mikeburr
Posts: 15
Joined: 2019/09/06 11:40:11

Re: newbie nasm 2.14.02 error

Post by mikeburr » 2019/09/09 14:39:57

ok i think i probably understand whats going on
obviously 32 bit instructions wont necessarily compile correctly as 64 bit despite extension .. the obvious ones are push and pop due to the fastcall stack alignment ... the issue is NOT with the version of Nasm etc etc
its all about the GCC compiler which effectively compiles as 64 bit unless the -m32 directive is added ..
this in turn generates an error -libcc_s [if my memory serves correctly ] whereby effectively it is not finding the libraries it requires for generating a 32 bit compilation
variants on the web suggest
yum -y install glibc-devel.i386 ... etc [elrepo : No package glibc-devel.i386 available.]
this is not looking good and in fact makes me wonder whether ANYONE is actually developing anything on Centos
if you are doing both 32 and 64 bit programming then maybe you could enlighten me .. and possibly others who might like to
GET SOMETHING TO ACTUALLY WORK
or better still have something that works in the first place [ a problem too common on Linux and very uncomfortable when compared to Windows !!! ...
no wonder Linux has a relatively small software base ]
regards mike b

mikeburr
Posts: 15
Joined: 2019/09/06 11:40:11

Re: newbie nasm 2.14.02 error

Post by mikeburr » 2019/09/09 17:01:45

The Solution
Having downloaded nasm 2.14.02 [ about 4 versions on from the current EPEL repos and containing a lot of extra instructions and corrections ]
i had problems with 32 bit compilation [64 is fine ] but most people will probably be either using 32 bit or trying to convert 32 bit so its fairly necessary to have both sorts easily available ..
the problem is that the gcc with centos 7 is 64 bit centric and wont compile 32 bit without the following 32 bit compatible extras
you need extra directories

yum -y install glibc-devel.i686 glibc-devel [ these are the equivalent of .....i386 stated previously and prob from a Ubuntu related site ]

yum install libstdc++-devel.i686

the compile for [elftest -> substitute your own program] is then

1) assemble the 32 bit test program supplied in this case in a subdirectory test with nasm 2.14.02

nasm -f elf elftest.asm -l elftest.lst -o elftest.o [ like to get a listing -l elftest.lst to have a quick browse but most probably would omit this ]

2) compile the host C program as 32 bit [default will be 64 bit and result in segmentation errors]
gcc -o elftest elftest.c -m32 elftest.o

3) run the program
./elftest

4) the output [can be readily seen to be ok from the C code ...]

Testing lrotate: should get 0x00400000, 0x00000001
lrotate(0x00040000, 4) = 0x00400000
lrotate(0x00040000, 14) = 0x00000001
This string should read `hello, world': `hello, world'
The integers here should be 1234, 1235 and 4321:
integer==1234, localint==1235, commvar=4321
These pointers should be equal: 0x8048531 and 0x8048531
So should these: 0x804a058 and 0x804a058

hope this helps someone else then i might hopefully find some programming pals ....
regards mike b

Post Reply

Return to “CentOS 7 - Software Support”