when i used the first command, an object file (*.o) was created, no errors
then i used the ld command to make an executable file, still no errors
i made sure that the executable file was executable and then ran it
with…
$ ./[my executable file]
then it gave me a wierd error:
./hello[1]: syntax error: `(’ unexpected
(hello was the name of my executable file)
it did not run
here is my source code written in nasm and there should not be any errors in it because nasm made the object file with out returning any errors and i got the source code off of a linux nasm tutorial so the error it gave me was wierd.
if anyone could help me on this it would be greatly appreciated
thanks in advance
Is it OK (i.e. legal) to reverse engineer e.g. a hello world program to gain knowledge about how QNX writes text on the screen at the lowest level? Is it OK to use this knowledge in my QNX programming?
(In this particular case: disassamble the printf or write function to see what happens next. Do it the same way next time I want to write text to screen.)
Actually ld is involved in the process. When you generate executable binary file from C source file with the gcc happens the following:
gcc first invokes a utility called the C preprocessor, cpp. When cpp is finished, gcc takes over and generates an assembly language equivalent of the C statements in the original .c file. Next it invokes GNU assembler, gas to assemble the .s file into an object code. The final step involves the GNU linker, ld.
So when you call gcc with the following command:
gcc hello.o -o hello
The only input file called out in the command is a .o file containing object code. This fact alone tells the gcc that all it needs to do is to link the file with the C library to produce the final executable.
Don’t know how “lowest” you are talking about. The C lib source (including the fuction printf() your are looking at) is in cvs.qnx.com for public access.
Actually I wanted to write an assembler hello world without any libc calls.
Thanks, that is really a great source!
However I don’t think the code for MsgSend* calls is available as source (at least I didn’t find it), so I still need libc calls even for a hello world assmembler prog.