2 * Copyright 2006-2010, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
6 * Axel Dörfler, axeld@pinc-software.de
7 * Oliver Tappe, zooey@hirschkaefer.de
11 #include <libroot_private.h>
19 bool __gR5Compatibility
= false;
20 addr_t __gNetworkStart
;
22 addr_t __gNetAPIStart
;
31 while (get_next_image_info(B_CURRENT_TEAM
, &cookie
, &info
) == B_OK
) {
32 if (((addr_t
)info
.text
<= (addr_t
)find_own_image
33 && (addr_t
)info
.text
+ (addr_t
)info
.text_size
34 > (addr_t
)find_own_image
)) {
36 __gNetworkStart
= (addr_t
)min_c(info
.text
, info
.data
);
37 __gNetworkEnd
= min_c((addr_t
)info
.text
+ info
.text_size
,
38 (addr_t
)info
.data
+ info
.data_size
);
48 // determine if we have to run in BeOS compatibility mode
50 // get image of executable
53 if (get_next_image_info(B_CURRENT_TEAM
, (int32
*)&cookie
, &info
) != B_OK
)
56 if (get_image_symbol(info
.id
, "__gHaikuStartupCode", B_SYMBOL_TYPE_DATA
,
58 // we were linked on/for Haiku
62 // We're using the BeOS startup code, check if BONE libraries are in
63 // use, and if not, enable the BeOS R5 compatibility layer.
64 // As dependencies to network libraries may be "hidden" in libraries, we
65 // may have to scan not only the executable, but every loaded image.
71 while (__get_next_image_dependency(info
.id
, &crumble
, &name
) == B_OK
) {
72 if (!strcmp(name
, "libbind.so")
73 || !strcmp(name
, "libsocket.so")
74 || !strcmp(name
, "libbnetapi.so")
75 || !strcmp(name
, "libnetwork.so"))
77 else if (!strcmp(name
, "libnet.so")
78 || !strcmp(name
, "libnetapi.so"))
83 __gR5Compatibility
= true;
85 debug_printf("libnetwork.so running in R5 compatibility mode.\n");
89 && get_next_image_info(B_CURRENT_TEAM
, (int32
*)&cookie
, &info
) == B_OK
);