Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How is linux simultaneously 32bit and 64bit? Or is that something handled in glibc?

How is Linux simultaneously 32bit and 64bit? Or is that something handled in glibc?

I run CentOS 5.3 and it is a "64 bit" version; although I build things for 64 bit and 32 bit. From what I think I know, Windows supposedly has a 32bit emulator. Does Linux do the same thing? Is it in userspace or kernel space?

If libc handles it, is it kind of like a emulator that says, I'll link with 32 bit apps, but speak 64 bit to the kernel?

like image 224
Crazy Chenz Avatar asked Oct 01 '09 14:10

Crazy Chenz


People also ask

How do I connect my 32-bit Linux to a 64-bit library?

You can't directly link to 32bit code inside of a 64bit program. The best option is to compile a 32bit (standalone) program that can run on your 64bit platform (using ia32), and then use a form of inter-process communication to communicate to it from your 64bit program.

Does Linux have 32bit and 64bit?

Find out if your Linux installation is 32 bit or 64 bit Uname -i gives you the hardware-platform. If you are possibly getting unknown, you can use uname -a to get all the information to find if it is 32-Bit or 64-Bit. Anything that is x86_64 is 64 bit and anything that i386, i686 or similar is 32 bit.


3 Answers

The cpu can execute both 64 and 32bit instructions and the kernel can switch between modes. The only limitation is that you cannot link 32bit programs against 64bit libraries so you must have both 32 and 64bit versions of libc, etc. installed.

like image 195
akosch Avatar answered Oct 31 '22 21:10

akosch


Nothing is stopping the cpu from switching from 64bit to 32bit. It just switches.

You can have a 64 bit kernel, and run 32bit apps. You can even have a 32bit kernel and run 64bit apps(Mac os x).

However you need the libaries they use to also be 32bit or or 64bit, which is why you might see files called lib64 or lib32 on linux for the 64bit or 32bit libaries.

like image 45
UK-AL Avatar answered Oct 31 '22 22:10

UK-AL


Because x86_64 processors are designed over x86 technology, they are still able to support 32-bit programs without any hardware emulation, like what you would need to run x86 programs in a PowerPC or Sparc environment. In Linux, all you need to do is install the necessary software libraries to run the 32-bit software.

like image 23
Aaron M Avatar answered Oct 31 '22 22:10

Aaron M