Slashdot Mirror


How OS X Executes Applications

MacHore writes "0xFE has an excellent tutorial on Mach-O, which is the file format used by OS X executable files and libraries. It goes into great detail about how Mach-O works, and explains what OS X actually does when it loads and runs an application. Subtopics include Universal Binaries, The Dynamic Linker, Using otool, and other goodies."

13 of 315 comments (clear)

  1. How I execute applications :) by Anonymous Coward · · Score: 5, Funny

    When FORCE QUIT doesn't work, 120V A/C to the processor does the trick every time.

  2. "Using otool" by Anonymous Coward · · Score: 5, Funny

    Do you mean big "O" tool?

  3. Ooh, I know this one! by Anonymous Coward · · Score: 5, Funny

    With extreme prejudice?

  4. Re:I don't have a Mac by Haeleth · · Score: 4, Funny

    Oh dear, does Linux practice this awful act as well? I'm an opponent of capital punishment, so it's now clear to me that I can't, in all conscience, use a Mac or Linux. No application, however detestable a crime it may be accused of, should ever face what is no more than state-sanctioned murder!

    My question to Slashdot, therefore, is what operating system should I choose?

    I've heard good things about FreeBSD's jails, which are apparently very secure without being inhumane. But on the other hand, Windows also has some advantages - I understand it opposes the death penalty so strongly that that it's been known to commit suicide in protest when a user attempts to execute too many applications?

  5. Re:0xFE by MagicM · · Score: 4, Funny

    Bastards.

  6. Re:What this means by Zwets · · Score: 5, Funny
    Expect an increase of the number of Mac virii

    And wormii! Don't forget wormii.

    --
    One of the lessons of history is that nothing is often a good thing to do and always a clever thing to say. - Will Duran
  7. Re:What this means by andreMA · · Score: 5, Insightful
    Expect an increase of the number of Mac virii out there in a now to 3 month timeframe.
    Yes, because this information was a closely held secret before this meddlesome blogger came along. I bet Steve Jobs is really pissed and is taking out a contract on his life.
  8. Re:Kinda OT.. yet relevant to this thread by Raffaello · · Score: 4, Insightful

    When I try and install something on OS X that doesn't have the required dependencies, it simply fails to work and gives no user-friendly clues why.

    We're talking about applications here. On Mac OS X, a properly packaged application lives in a .app directory which contains all dependencies with the sole exception of frameworks that are present on any version of Mac OS X that the app is capable of running on. In other words, a properly packaged Mac OS X app has no external dependencies - everything it needs to run is either in the .app directory, or comes standard with Mac OS X.

    Any application packaging that assumes that users will not relocate an application is broken on Mac OS X. This means that any having dependencies not contained inside the .app directory (aka the app bundle) is broken, since users can and will relocate apps to removable media for use on other machines.

    Now, some misguided *nix hackers will cobble together an application to run on Mac OS X that scatters little *nix file turds all over various directories, or will hard code installation directories so the application is not relocatable. These are both wrong on Mac OS X (though common practice on *nix) because Mac users have been relocating applications since the mid 1980s, and will continue to do so.

  9. Re:Obligitory... by moosesocks · · Score: 4, Interesting

    A lot of that has to do not only with Mach, but simply with the fact that up until recently, a lot of OSX applications (specifically, those built on Carbon) were not multithreaded. In other words, if one bit of the application hangs or times out, the application and everything that depends on it goes to hell.

    This is why BeOS appeared to be lightning fast on even slow machines. Even the smallest tasks were executed independently, and bottlenecks were hardly noticiable.

    Apple's doing a good job making everything work, and Cocoa is definitely a step in the right direction, but apple really needs to kill all of the single-threaded applications they've got now. The Finder is the most prolific and outrageous example of this, and anybody who's ever lost a network connection while a network share was mounted knows what I'm talking about (the system virtually hangs for 45 seconds until the connection times out. awful. simply awful)

    Otherwise, I love OSX.

    --
    -- If you try to fail and succeed, which have you done? - Uli's moose
  10. Re:Interesting, but why? by Fahrvergnuugen · · Score: 4, Informative
    --
    Kiteboarding Gear Mention slashdot and get 10% off!
  11. Re:Kinda OT.. yet relevant to this thread by GlassHeart · · Score: 4, Informative
    So - you install a version of the gimp - you get a copy of gtk, install eog - you get a copy of gtk, install.... well I think you get my point.

    No, the post you were responding to phrased it poorly.

    What is inherent in a MacOS X version (say, 10.4.5) already covers most of what an application might need, including Apple's "equivalent" of gtk. Go browse the Apple Developer docs sometime, and you'll see a much richer set of libraries that come with the OS by default. Thus, if an application wants an "obscure" library and decides to bundle it, the cost to the system is minimal even if another app has the same one. The MacOS bundle is not at all the equivalent of statically linking against gtk and other "fundamental" libraries in Linux.

    On the Mac you have scour the web deciding Free or Paid, [...] Once you've downloaded it, things are pretty sweet, but finding the download can be a PITA.

    Have you ever heard of versiontracker?

    On the linux box (I am going to choose Debian as I'm familiar with it). Fire up synaptic from the gnome menu. Search for barcode. Two results returned. Both of these programs I know to be free of trojans, compatable with my system & configured for it. To install, I double click.

    Which can bring in new versions of a library, which in turn brings in new versions of another application, which may be broken in some way (like any app can be). In other words, installing one app in Linux can effectively break another one. You pay for the isolation available to MacOS X apps in the form of disk space and RAM, both of which can be relatively cheap depending on what you're doing with your computer.

  12. Re:are osx binaries cross-architecture? by geoffspear · · Score: 4, Informative
    The answer is "sort of".

    The architecture does support Universal Binaries, which have code for both PPC and intel processors. This isn't really anything new or magical, the OS is just smart enough to know which code to execute. The same thing existed in the classic MacOS to support both PPC and 680x0 systems with FAT binaries.

    As with the classic MacOS, there's also an emulator involved, so the newer architecture can run (most) binaries compiled on the older architecture.

    However, compile something just for the Intel processors, and it won't run on your PPC hardware. If I understand your question correctly, if things worked the way you were assuming, Mach-O itself would guarantee any Mach-O binary would run on either system.

    --
    Don't blame me; I'm never given mod points.
  13. Re:Kinda OT.. yet relevant to this thread by Macka · · Score: 4, Insightful
    Have you ever heard of versiontracker?

    *puts small business owner hat on*

    No.
    So you're telling us that a "small business owner" doesn't know how to Google for an app and stumble onto VersionTracker (which he/she should suspect exists anyway as similar sites exist for Windows) but the same "small business owner" knows what a Terminal app is; knows how to drive a command line, and knows that he/she needs to use a command called "apt-get".

    I don't believe you!