I understand that each CPU/architecture has it's own instruction set, therefore a program(binary) written for a specific CPU cannot run on another. But what i don't really understand is why an executable file (binary like .exe for instance) cannot run on Linux but can run on windows even on the very same machine.

我理解每个CPU/体系结构都有自己的指令集,因此为特定CPU编写的程序(二进制)不能在另一个CPU上运行。但我并不真正理解的是,为什么一个可执行文件(例如,例如.exe)不能在Linux上运行,而是可以在同一台机器上运行。

This is a basic question, and the answer i'm expecting is that .exe and other binary formats are probably not Raw machine instructions but they contain some data that is operating system dependent. If this is true, then what this OS dependent data is like? and as an example what is the format of an .exe file and the difference between it and Linux executables?

这是一个基本问题,我期望的答案是。exe和其他二进制格式可能不是原始机器指令,但它们包含一些操作系统依赖的数据。如果这是真的,那么这个与操作系统相关的数据是什么样的呢?作为一个例子,.exe文件的格式是什么?它和Linux可执行文件的区别是什么?

Is there a source i can get brief and detailed information about this?

关于这个问题,我能得到一个简单而详细的信息来源吗?

7 个解决方案

#1


19

In order to do something meaningful, applications will need to interface with the OS. Since system calls and user-space infrastructure look fundamentally different on Windows and Unix/Linux, having different formats for executable programs is the smallest trouble. It's the program logic that would need to be changed.

为了做一些有意义的事情,应用程序需要与操作系统交互。由于在Windows和Unix/Linux上,系统调用和用户空间基础结构看起来根本不同,所以为可执行程序设置不同的格式是最小的麻烦。需要更改的是程序逻辑。

(You might argue that this is meaningless if you have a program that solely depends on standardized components, for example the C runtime library. This is theoretically true - but irrelevant for most applications since they are forced to use OS-dependent stuff).

(您可能会认为,如果您有一个完全依赖于标准化组件的程序,例如C运行时库,那么这是没有意义的。这在理论上是正确的——但对于大多数应用程序来说是不相关的,因为它们被迫使用与操作系统相关的东西)。

The other differences between Windows PE (EXE,DLL,..) files and Linux ELF binaries are related to the different image loaders and some design characteristics of both OSs. For example on Linux a separate program is used to resolve external library imports while this functionality is built-in on Windows. Another example: Linux shared libraries function differently than DLLs on Windows. Not to mention that both formats are optimized to enable the respective OS kernels to load programs as quick as possible.

Windows PE (EXE,DLL ..)文件和Linux ELF二进制文件之间的其他差异与不同的图像加载程序和两种OSs的一些设计特性有关。例如,在Linux上,一个单独的程序用于解析外部库导入,而这个功能在Windows上是内置的。另一个例子:Linux共享库的功能与Windows上的dll不同。更不用说,这两种格式都经过了优化,以使各自的OS内核能够尽快加载程序。

Emulators like Wine try to fill the gap (and actually prove that the biggest problem is not the binary format but rather the OS interface!).

像Wine这样的模拟器试图填补这个空白(实际上证明最大的问题不是二进制格式,而是操作系统接口!)

更多相关文章

  1. linux利用CMakeLists编译cuda程序
  2. 〖Linux〗使用Qt5.2.0开发Android的NDK应用程序
  3. 用GCC编译链接程序--编译链接器GCC常用功能(菜鸟级)
  4. 【原】第一个Linux设备驱动程序hello world!
  5. linux命令行程序
  6. 【Ubuntu手记】开发多线程程序时在eclipse中添加libpthread.a库
  7. Linux环境下通过pdb调试Python程序
  8. linux c 多进程socket程序,如何实现父进程监听,子进程接受连接(注
  9. 如何使用ffmpeg将m4v和wmv视频转换为mp4格式?

随机推荐

  1. android之Unable to execute dex: Multip
  2. 15.Android(安卓)异步更新UI 技巧
  3. Android InputStreamReader 解析gbk、gb2
  4. Android——init.rc脚本
  5. 【转】升级android sdk时A folder failed
  6. 解决ArcGIS Android Could not find clas
  7. android 属性android:visibility
  8. Android 回调机制
  9. Android中SQLite数据库操作(1)——使用SQL
  10. Android(安卓)高仿 频道管理----网易、今