views:

393

answers:

5

Does Linux have a shared library that exports OS functions?

msvcrt.dll -> libc.so.6

kernel32.dll -> ?

A: 

You will manually have to look up what functions of the win32 in kernel32.dll that you want to use and find replacements in linux/gnu. There are a ton of shared libraries that linux uses. Not all have a direct replacement in the same place across operating systems. There are libraries that do take care of the cross platform stuff.

Daniel A. White
Well I just want to see a general list. For example, where am I supposed to find brk and sbrk?? http://linux.die.net/man/2/sbrk
Unknown
@Unknown: in libc.
Juliano
+2  A: 

libc is the equivalent of kernel32 in Linux, the GNU extensions to the standard library handle all of the ways you can call into the kernel. (Technically, libc is the equivalent of ntdll, but neither here nor there)

Edit: Just to clarify - the kernel itself exports a number of functions called in a special manner called syscalls; these syscalls are wrapped by actual functions; on Linux this is done in libc, on Windows it's done twice, once by ntdll (i.e. NtCreateFile), then again by Kernel32 (CreateFileW/A).

Kernel32 offers a number of other functions that aren't syscalls (i.e. stay 100% in user mode) as well, just like libc.

Paul Betts
+5  A: 

'kernel32.dll' would also translate to libc.so.6. Since Windows is not POSIX on its lowest level, it needs an additional layer to translate POSIX libc calls into native Win32 calls. This is what msvcrt.dll is for. Kernel32.dll contains the lowest level calls. On Linux, those system calls are already POSIX, so no extra library needed.

Rutger Nijlunsing
This isn't entirely accurate - most of the msvcrt functions are handled *in* msvcrt itself, things like strtok definitely don't go to the kernel!
Paul Betts
If no OS support is needed, than the library can do it by itself, that's true.
Rutger Nijlunsing
that exports OS functions -- Linux VDSO + headers.
Aiden Bell
+4  A: 

msvcrt.dll is not really comparable to libc.so.6, since the first is an specific DLL for VC++ (msvcrt -> MicroSoft Visual C++ RunTime).

System calls (open, close, read, write, etc...) are also in libc. They are just simple wrappers around software interruptions written in assembly language.

Juliano
+1  A: 

I think you might be looking for:

linux-vdso.so.1 =>  (0x00000...)

Which is the 'virtual library' link for the Linux kernel.

Your kernel headers will give you the API details.

Found this with a quick google.

http://www.trilithium.com/johan/2005/08/linux-gate/

Aiden Bell
The VDSO is more like ntdll.dll than kernel32.dll.
CesarB
I don't use Windows ... stab in the dark :P
Aiden Bell