Low level programming assembly/machine code question!

Discussion of programming on Linux, including shell scripting, perl, python, c/c++, mono, java. Whatever tickles your fancy.
Post Reply
s7r1k3r
Battalion Quarter Master Havaldaar
Posts: 221
Joined: Wed Aug 07, 2002 3:02 pm
Location: Rawalpindi

Low level programming assembly/machine code question!

Post by s7r1k3r »

Assalam-O-Alaekum!

Assembly language is processor dependant not assembler dependent, right? Although, the difference between assemblers in linux and windows make the assembly code quite different but would the machine code also differ? Shouldn't machine code be the same because the OS is running on the same architecture?
a10n3 s7r1k3r
farhanksa
Subedar
Posts: 359
Joined: Sun Nov 03, 2002 6:40 am
Location: Lahore
Contact:

Post by farhanksa »

yes assembly laguage is processor dependant..not the assembler...but the point is assebmler gives us the way to write different syntax .
the assemlby code do differ in the syntax and other matters..but the machine code is the same.. for specific processor architecture
s7r1k3r
Battalion Quarter Master Havaldaar
Posts: 221
Joined: Wed Aug 07, 2002 3:02 pm
Location: Rawalpindi

COM file equivalent in Linux?

Post by s7r1k3r »

Assalam-O-Alaekum!

Thanks for the reply. I have another question on the same topic. Is there a COM file equivalent for linux? Meaning, just like COM files don't have big headers with them, is there any such format for linux?

Also, what are ELF binaries and how do they differ from the older binaries?
a10n3 s7r1k3r
slick
Naik
Posts: 56
Joined: Fri Sep 05, 2003 1:29 am
Location: CA

Post by slick »

I dont know what youre asking about the COM file stuff. For ELF, you can search google or intels website. or take a look at this

http://www.muppetlabs.com/~breadbox/software/ELF.txt
I only run as fast as my angels can fly
s7r1k3r
Battalion Quarter Master Havaldaar
Posts: 221
Joined: Wed Aug 07, 2002 3:02 pm
Location: Rawalpindi

COM related

Post by s7r1k3r »

By COM issue I meant that in DOS/Windows, COM files contain no extra header info except the PSF while EXEs contain a lot of extra assembly code not written by the programmer. I wanted to know if there was an equivivalent of this in Linux.
a10n3 s7r1k3r
slick
Naik
Posts: 56
Joined: Fri Sep 05, 2003 1:29 am
Location: CA

Post by slick »

hmm....i cant really think of anything that would do that...:)
I only run as fast as my angels can fly
s7r1k3r
Battalion Quarter Master Havaldaar
Posts: 221
Joined: Wed Aug 07, 2002 3:02 pm
Location: Rawalpindi

got it.

Post by s7r1k3r »

Assalam-O-Alaekum!

Well, I found something. If we don't use the libc wrapper calls in assembly (meaning calling the syscalls directly) this reduces the size of elf binaries quite dramatically. I got a hello world program binary only in 488 bytes.
a10n3 s7r1k3r
lambda
Major General
Posts: 3452
Joined: Tue May 27, 2003 7:04 pm
Location: Lahore
Contact:

Re: COM file equivalent in Linux?

Post by lambda »

s7r1k3r wrote:Thanks for the reply. I have another question on the same topic. Is there a COM file equivalent for linux? Meaning, just like COM files don't have big headers with them, is there any such format for linux?
pretty much all binaries you execute on linux are elf binaries. if you write your entire app in assembly and never call out to any libraries, you can use the a.out format instead. you might have to load a kernel module or recompile your kernel to make it support a.out, though.
Also, what are ELF binaries and how do they differ from the older binaries?
elf binaries can have multiple sections of data, code (called "text"), and comments. a.out just has text, data, bss (unless hacked for more sections, which pretty much everyone did before switching to elf). a binary built with debugging info can have another section just for debugging foo; the advantage is that this section doesn't have to be paged in when the binary is run. also, a.out has to be hacked to support shared libraries; elf supports it natively.

elf is also cross-platform, and most x86 (for example) operating systems use the same binary format for their executables.
s7r1k3r
Battalion Quarter Master Havaldaar
Posts: 221
Joined: Wed Aug 07, 2002 3:02 pm
Location: Rawalpindi

Thanks

Post by s7r1k3r »

Thanks for the informative reply. Does the PE (Portable Executable) file format used in Windows OS a variation of the ELF standard or is it something different?
a10n3 s7r1k3r
lambda
Major General
Posts: 3452
Joined: Tue May 27, 2003 7:04 pm
Location: Lahore
Contact:

Re: Thanks

Post by lambda »

Post Reply