[haiku-development] Is it possible to determine if an application was compiled on BeOS or Haiku from its team_id?

  • From: John Scipione <jscipione@xxxxxxxxx>
  • To: "haiku-development@xxxxxxxxxxxxx" <haiku-development@xxxxxxxxxxxxx>
  • Date: Tue, 10 Mar 2020 08:02:00 -0400

Is it possible to determine whether an application was compiled on
BeOS or Haiku from its team_id?

I tried the following code:

uint32 cookie = 0;
image_info info;
if (get_next_image_info(team_id, (int32*)&cookie, &info) == B_OK
    && info.type == B_APP_IMAGE) {
    if (get_image_symbol(info.id, "__gHaikuStartupCode",
            B_SYMBOL_TYPE_DATA, NULL) == B_OK) {
        // we were linked on/for Haiku
    } else {
        // we were linked on/for BeOS
    }
}

based on this:
https://git.haiku-os.org/haiku/tree/src/system/libnetwork/init.cpp#n47

but the above code didn't work.

Is there a way to determine this?

I'm pretty sure that runtime_loader determines this information by
parsing the executable file's elf header, but I don't know if there's
a way to get at that data from app_server.

Other related posts: