binreloc.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767
  1. /*
  2. * BinReloc - a library for creating relocatable executables
  3. * Written by: Hongli Lai <h.lai@chello.nl>
  4. * http://autopackage.org/
  5. *
  6. * This source code is public domain. You can relicense this code
  7. * under whatever license you want.
  8. *
  9. * See http://autopackage.org/docs/binreloc/ for
  10. * more information and how to use this.
  11. */
  12. #ifndef __BINRELOC_C__
  13. #define __BINRELOC_C__
  14. #ifdef ENABLE_BINRELOC
  15. #include <sys/types.h>
  16. #include <sys/stat.h>
  17. #include <unistd.h>
  18. #endif /* ENABLE_BINRELOC */
  19. #include <stdio.h>
  20. #include <stdlib.h>
  21. #include <limits.h>
  22. #include <string.h>
  23. #include "binreloc.h"
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif /* __cplusplus */
  27. /** @internal
  28. * Find the canonical filename of the executable. Returns the filename
  29. * (which must be freed) or NULL on error. If the parameter 'error' is
  30. * not NULL, the error code will be stored there, if an error occured.
  31. */
  32. static char *
  33. _br_find_exe (BrInitError *error)
  34. {
  35. #ifndef ENABLE_BINRELOC
  36. if (error)
  37. *error = BR_INIT_ERROR_DISABLED;
  38. return NULL;
  39. #else
  40. char *path, *path2, *line, *result;
  41. size_t buf_size;
  42. ssize_t size;
  43. struct stat stat_buf;
  44. FILE *f;
  45. /* Read from /proc/self/exe (symlink) */
  46. if (sizeof (path) > SSIZE_MAX)
  47. buf_size = SSIZE_MAX - 1;
  48. else
  49. buf_size = PATH_MAX - 1;
  50. path = (char *) malloc (buf_size);
  51. if (path == NULL) {
  52. /* Cannot allocate memory. */
  53. if (error)
  54. *error = BR_INIT_ERROR_NOMEM;
  55. return NULL;
  56. }
  57. path2 = (char *) malloc (buf_size);
  58. if (path2 == NULL) {
  59. /* Cannot allocate memory. */
  60. if (error)
  61. *error = BR_INIT_ERROR_NOMEM;
  62. free (path);
  63. return NULL;
  64. }
  65. strncpy (path2, "/proc/self/exe", buf_size - 1);
  66. while (1) {
  67. int i;
  68. size = readlink (path2, path, buf_size - 1);
  69. if (size == -1) {
  70. /* Error. */
  71. free (path2);
  72. break;
  73. }
  74. /* readlink() success. */
  75. path[size] = '\0';
  76. /* Check whether the symlink's target is also a symlink.
  77. * We want to get the final target. */
  78. i = stat (path, &stat_buf);
  79. if (i == -1) {
  80. /* Error. */
  81. free (path2);
  82. break;
  83. }
  84. /* stat() success. */
  85. if (!S_ISLNK (stat_buf.st_mode)) {
  86. /* path is not a symlink. Done. */
  87. free (path2);
  88. return path;
  89. }
  90. /* path is a symlink. Continue loop and resolve this. */
  91. strncpy (path, path2, buf_size - 1);
  92. }
  93. /* readlink() or stat() failed; this can happen when the program is
  94. * running in Valgrind 2.2. Read from /proc/self/maps as fallback. */
  95. buf_size = PATH_MAX + 128;
  96. line = (char *) realloc (path, buf_size);
  97. if (line == NULL) {
  98. /* Cannot allocate memory. */
  99. free (path);
  100. if (error)
  101. *error = BR_INIT_ERROR_NOMEM;
  102. return NULL;
  103. }
  104. f = fopen ("/proc/self/maps", "r");
  105. if (f == NULL) {
  106. free (line);
  107. if (error)
  108. *error = BR_INIT_ERROR_OPEN_MAPS;
  109. return NULL;
  110. }
  111. /* The first entry should be the executable name. */
  112. result = fgets (line, (int) buf_size, f);
  113. if (result == NULL) {
  114. fclose (f);
  115. free (line);
  116. if (error)
  117. *error = BR_INIT_ERROR_READ_MAPS;
  118. return NULL;
  119. }
  120. /* Get rid of newline character. */
  121. buf_size = strlen (line);
  122. if (buf_size <= 0) {
  123. /* Huh? An empty string? */
  124. fclose (f);
  125. free (line);
  126. if (error)
  127. *error = BR_INIT_ERROR_INVALID_MAPS;
  128. return NULL;
  129. }
  130. if (line[buf_size - 1] == 10)
  131. line[buf_size - 1] = 0;
  132. /* Extract the filename; it is always an absolute path. */
  133. path = strchr (line, '/');
  134. /* Sanity check. */
  135. if (strstr (line, " r-xp ") == NULL || path == NULL) {
  136. fclose (f);
  137. free (line);
  138. if (error)
  139. *error = BR_INIT_ERROR_INVALID_MAPS;
  140. return NULL;
  141. }
  142. path = strdup (path);
  143. free (line);
  144. fclose (f);
  145. return path;
  146. #endif /* ENABLE_BINRELOC */
  147. }
  148. /** @internal
  149. * Find the canonical filename of the executable which owns symbol.
  150. * Returns a filename which must be freed, or NULL on error.
  151. */
  152. static char *
  153. _br_find_exe_for_symbol (const void *symbol, BrInitError *error)
  154. {
  155. #ifndef ENABLE_BINRELOC
  156. if (error)
  157. *error = BR_INIT_ERROR_DISABLED;
  158. return (char *) NULL;
  159. #else
  160. #define SIZE PATH_MAX + 100
  161. FILE *f;
  162. size_t address_string_len;
  163. char *address_string, line[SIZE], *found;
  164. if (symbol == NULL)
  165. return (char *) NULL;
  166. f = fopen ("/proc/self/maps", "r");
  167. if (f == NULL)
  168. return (char *) NULL;
  169. address_string_len = 4;
  170. address_string = (char *) malloc (address_string_len);
  171. found = (char *) NULL;
  172. while (!feof (f)) {
  173. char *start_addr, *end_addr, *end_addr_end, *file;
  174. void *start_addr_p, *end_addr_p;
  175. size_t len;
  176. if (fgets (line, SIZE, f) == NULL)
  177. break;
  178. /* Sanity check. */
  179. if (strstr (line, " r-xp ") == NULL || strchr (line, '/') == NULL)
  180. continue;
  181. /* Parse line. */
  182. start_addr = line;
  183. end_addr = strchr (line, '-');
  184. file = strchr (line, '/');
  185. /* More sanity check. */
  186. if (!(file > end_addr && end_addr != NULL && end_addr[0] == '-'))
  187. continue;
  188. end_addr[0] = '\0';
  189. end_addr++;
  190. end_addr_end = strchr (end_addr, ' ');
  191. if (end_addr_end == NULL)
  192. continue;
  193. end_addr_end[0] = '\0';
  194. len = strlen (file);
  195. if (len == 0)
  196. continue;
  197. if (file[len - 1] == '\n')
  198. file[len - 1] = '\0';
  199. /* Get rid of "(deleted)" from the filename. */
  200. len = strlen (file);
  201. if (len > 10 && strcmp (file + len - 10, " (deleted)") == 0)
  202. file[len - 10] = '\0';
  203. /* I don't know whether this can happen but better safe than sorry. */
  204. len = strlen (start_addr);
  205. if (len != strlen (end_addr))
  206. continue;
  207. /* Transform the addresses into a string in the form of 0xdeadbeef,
  208. * then transform that into a pointer. */
  209. if (address_string_len < len + 3) {
  210. address_string_len = len + 3;
  211. address_string = (char *) realloc (address_string, address_string_len);
  212. }
  213. memcpy (address_string, "0x", 2);
  214. memcpy (address_string + 2, start_addr, len);
  215. address_string[2 + len] = '\0';
  216. sscanf (address_string, "%p", &start_addr_p);
  217. memcpy (address_string, "0x", 2);
  218. memcpy (address_string + 2, end_addr, len);
  219. address_string[2 + len] = '\0';
  220. sscanf (address_string, "%p", &end_addr_p);
  221. if (symbol >= start_addr_p && symbol < end_addr_p) {
  222. found = file;
  223. break;
  224. }
  225. }
  226. free (address_string);
  227. fclose (f);
  228. if (found == NULL)
  229. return (char *) NULL;
  230. else
  231. return strdup (found);
  232. #endif /* ENABLE_BINRELOC */
  233. }
  234. #ifndef BINRELOC_RUNNING_DOXYGEN
  235. #undef NULL
  236. #define NULL ((void *) 0) /* typecasted as char* for C++ type safeness */
  237. #endif
  238. static char *exe = (char *) NULL;
  239. /** Initialize the BinReloc library (for applications).
  240. *
  241. * This function must be called before using any other BinReloc functions.
  242. * It attempts to locate the application's canonical filename.
  243. *
  244. * @note If you want to use BinReloc for a library, then you should call
  245. * br_init_lib() instead.
  246. *
  247. * @param error If BinReloc failed to initialize, then the error code will
  248. * be stored in this variable. Set to NULL if you want to
  249. * ignore this. See #BrInitError for a list of error codes.
  250. *
  251. * @returns 1 on success, 0 if BinReloc failed to initialize.
  252. */
  253. int
  254. br_init (BrInitError *error)
  255. {
  256. exe = _br_find_exe (error);
  257. return exe != NULL;
  258. }
  259. /** Initialize the BinReloc library (for libraries).
  260. *
  261. * This function must be called before using any other BinReloc functions.
  262. * It attempts to locate the calling library's canonical filename.
  263. *
  264. * @note The BinReloc source code MUST be included in your library, or this
  265. * function won't work correctly.
  266. *
  267. * @param error If BinReloc failed to initialize, then the error code will
  268. * be stored in this variable. Set to NULL if you want to
  269. * ignore this. See #BrInitError for a list of error codes.
  270. *
  271. * @returns 1 on success, 0 if a filename cannot be found.
  272. */
  273. int
  274. br_init_lib (BrInitError *error)
  275. {
  276. exe = _br_find_exe_for_symbol ((const void *) "", error);
  277. return exe != NULL;
  278. }
  279. /** Find the canonical filename of the current application.
  280. *
  281. * @param default_exe A default filename which will be used as fallback.
  282. * @returns A string containing the application's canonical filename,
  283. * which must be freed when no longer necessary. If BinReloc is
  284. * not initialized, or if br_init() failed, then a copy of
  285. * default_exe will be returned. If default_exe is NULL, then
  286. * NULL will be returned.
  287. */
  288. char *
  289. br_find_exe (const char *default_exe)
  290. {
  291. if (exe == (char *) NULL) {
  292. /* BinReloc is not initialized. */
  293. if (default_exe != (const char *) NULL)
  294. return strdup (default_exe);
  295. else
  296. return (char *) NULL;
  297. }
  298. return strdup (exe);
  299. }
  300. /** Locate the directory in which the current application is installed.
  301. *
  302. * The prefix is generated by the following pseudo-code evaluation:
  303. * \code
  304. * dirname(exename)
  305. * \endcode
  306. *
  307. * @param default_dir A default directory which will used as fallback.
  308. * @return A string containing the directory, which must be freed when no
  309. * longer necessary. If BinReloc is not initialized, or if the
  310. * initialization function failed, then a copy of default_dir
  311. * will be returned. If default_dir is NULL, then NULL will be
  312. * returned.
  313. */
  314. char *
  315. br_find_exe_dir (const char *default_dir)
  316. {
  317. if (exe == NULL) {
  318. /* BinReloc not initialized. */
  319. if (default_dir != NULL)
  320. return strdup (default_dir);
  321. else
  322. return NULL;
  323. }
  324. return br_dirname (exe);
  325. }
  326. /** Locate the prefix in which the current application is installed.
  327. *
  328. * The prefix is generated by the following pseudo-code evaluation:
  329. * \code
  330. * dirname(dirname(exename))
  331. * \endcode
  332. *
  333. * @param default_prefix A default prefix which will used as fallback.
  334. * @return A string containing the prefix, which must be freed when no
  335. * longer necessary. If BinReloc is not initialized, or if
  336. * the initialization function failed, then a copy of default_prefix
  337. * will be returned. If default_prefix is NULL, then NULL will be returned.
  338. */
  339. char *
  340. br_find_prefix (const char *default_prefix)
  341. {
  342. char *dir1, *dir2;
  343. if (exe == (char *) NULL) {
  344. /* BinReloc not initialized. */
  345. if (default_prefix != (const char *) NULL)
  346. return strdup (default_prefix);
  347. else
  348. return (char *) NULL;
  349. }
  350. dir1 = br_dirname (exe);
  351. dir2 = br_dirname (dir1);
  352. free (dir1);
  353. return dir2;
  354. }
  355. /** Locate the application's binary folder.
  356. *
  357. * The path is generated by the following pseudo-code evaluation:
  358. * \code
  359. * prefix + "/bin"
  360. * \endcode
  361. *
  362. * @param default_bin_dir A default path which will used as fallback.
  363. * @return A string containing the bin folder's path, which must be freed when
  364. * no longer necessary. If BinReloc is not initialized, or if
  365. * the initialization function failed, then a copy of default_bin_dir will
  366. * be returned. If default_bin_dir is NULL, then NULL will be returned.
  367. */
  368. char *
  369. br_find_bin_dir (const char *default_bin_dir)
  370. {
  371. char *prefix, *dir;
  372. prefix = br_find_prefix ((const char *) NULL);
  373. if (prefix == (char *) NULL) {
  374. /* BinReloc not initialized. */
  375. if (default_bin_dir != (const char *) NULL)
  376. return strdup (default_bin_dir);
  377. else
  378. return (char *) NULL;
  379. }
  380. dir = br_build_path (prefix, "bin");
  381. free (prefix);
  382. return dir;
  383. }
  384. /** Locate the application's superuser binary folder.
  385. *
  386. * The path is generated by the following pseudo-code evaluation:
  387. * \code
  388. * prefix + "/sbin"
  389. * \endcode
  390. *
  391. * @param default_sbin_dir A default path which will used as fallback.
  392. * @return A string containing the sbin folder's path, which must be freed when
  393. * no longer necessary. If BinReloc is not initialized, or if the
  394. * initialization function failed, then a copy of default_sbin_dir will
  395. * be returned. If default_bin_dir is NULL, then NULL will be returned.
  396. */
  397. char *
  398. br_find_sbin_dir (const char *default_sbin_dir)
  399. {
  400. char *prefix, *dir;
  401. prefix = br_find_prefix ((const char *) NULL);
  402. if (prefix == (char *) NULL) {
  403. /* BinReloc not initialized. */
  404. if (default_sbin_dir != (const char *) NULL)
  405. return strdup (default_sbin_dir);
  406. else
  407. return (char *) NULL;
  408. }
  409. dir = br_build_path (prefix, "sbin");
  410. free (prefix);
  411. return dir;
  412. }
  413. /** Locate the application's data folder.
  414. *
  415. * The path is generated by the following pseudo-code evaluation:
  416. * \code
  417. * prefix + "/share"
  418. * \endcode
  419. *
  420. * @param default_data_dir A default path which will used as fallback.
  421. * @return A string containing the data folder's path, which must be freed when
  422. * no longer necessary. If BinReloc is not initialized, or if the
  423. * initialization function failed, then a copy of default_data_dir
  424. * will be returned. If default_data_dir is NULL, then NULL will be
  425. * returned.
  426. */
  427. char *
  428. br_find_data_dir (const char *default_data_dir)
  429. {
  430. char *prefix, *dir;
  431. prefix = br_find_prefix ((const char *) NULL);
  432. if (prefix == (char *) NULL) {
  433. /* BinReloc not initialized. */
  434. if (default_data_dir != (const char *) NULL)
  435. return strdup (default_data_dir);
  436. else
  437. return (char *) NULL;
  438. }
  439. dir = br_build_path (prefix, "share");
  440. free (prefix);
  441. return dir;
  442. }
  443. /** Locate the application's localization folder.
  444. *
  445. * The path is generated by the following pseudo-code evaluation:
  446. * \code
  447. * prefix + "/share/locale"
  448. * \endcode
  449. *
  450. * @param default_locale_dir A default path which will used as fallback.
  451. * @return A string containing the localization folder's path, which must be freed when
  452. * no longer necessary. If BinReloc is not initialized, or if the
  453. * initialization function failed, then a copy of default_locale_dir will be returned.
  454. * If default_locale_dir is NULL, then NULL will be returned.
  455. */
  456. char *
  457. br_find_locale_dir (const char *default_locale_dir)
  458. {
  459. char *data_dir, *dir;
  460. data_dir = br_find_data_dir ((const char *) NULL);
  461. if (data_dir == (char *) NULL) {
  462. /* BinReloc not initialized. */
  463. if (default_locale_dir != (const char *) NULL)
  464. return strdup (default_locale_dir);
  465. else
  466. return (char *) NULL;
  467. }
  468. dir = br_build_path (data_dir, "locale");
  469. free (data_dir);
  470. return dir;
  471. }
  472. /** Locate the application's library folder.
  473. *
  474. * The path is generated by the following pseudo-code evaluation:
  475. * \code
  476. * prefix + "/lib"
  477. * \endcode
  478. *
  479. * @param default_lib_dir A default path which will used as fallback.
  480. * @return A string containing the library folder's path, which must be freed when
  481. * no longer necessary. If BinReloc is not initialized, or if the initialization
  482. * function failed, then a copy of default_lib_dir will be returned.
  483. * If default_lib_dir is NULL, then NULL will be returned.
  484. */
  485. char *
  486. br_find_lib_dir (const char *default_lib_dir)
  487. {
  488. char *prefix, *dir;
  489. prefix = br_find_prefix ((const char *) NULL);
  490. if (prefix == (char *) NULL) {
  491. /* BinReloc not initialized. */
  492. if (default_lib_dir != (const char *) NULL)
  493. return strdup (default_lib_dir);
  494. else
  495. return (char *) NULL;
  496. }
  497. dir = br_build_path (prefix, "lib");
  498. free (prefix);
  499. return dir;
  500. }
  501. /** Locate the application's libexec folder.
  502. *
  503. * The path is generated by the following pseudo-code evaluation:
  504. * \code
  505. * prefix + "/libexec"
  506. * \endcode
  507. *
  508. * @param default_libexec_dir A default path which will used as fallback.
  509. * @return A string containing the libexec folder's path, which must be freed when
  510. * no longer necessary. If BinReloc is not initialized, or if the initialization
  511. * function failed, then a copy of default_libexec_dir will be returned.
  512. * If default_libexec_dir is NULL, then NULL will be returned.
  513. */
  514. char *
  515. br_find_libexec_dir (const char *default_libexec_dir)
  516. {
  517. char *prefix, *dir;
  518. prefix = br_find_prefix ((const char *) NULL);
  519. if (prefix == (char *) NULL) {
  520. /* BinReloc not initialized. */
  521. if (default_libexec_dir != (const char *) NULL)
  522. return strdup (default_libexec_dir);
  523. else
  524. return (char *) NULL;
  525. }
  526. dir = br_build_path (prefix, "libexec");
  527. free (prefix);
  528. return dir;
  529. }
  530. /** Locate the application's configuration files folder.
  531. *
  532. * The path is generated by the following pseudo-code evaluation:
  533. * \code
  534. * prefix + "/etc"
  535. * \endcode
  536. *
  537. * @param default_etc_dir A default path which will used as fallback.
  538. * @return A string containing the etc folder's path, which must be freed when
  539. * no longer necessary. If BinReloc is not initialized, or if the initialization
  540. * function failed, then a copy of default_etc_dir will be returned.
  541. * If default_etc_dir is NULL, then NULL will be returned.
  542. */
  543. char *
  544. br_find_etc_dir (const char *default_etc_dir)
  545. {
  546. char *prefix, *dir;
  547. prefix = br_find_prefix ((const char *) NULL);
  548. if (prefix == (char *) NULL) {
  549. /* BinReloc not initialized. */
  550. if (default_etc_dir != (const char *) NULL)
  551. return strdup (default_etc_dir);
  552. else
  553. return (char *) NULL;
  554. }
  555. dir = br_build_path (prefix, "etc");
  556. free (prefix);
  557. return dir;
  558. }
  559. /***********************
  560. * Utility functions
  561. ***********************/
  562. /** Concatenate str1 and str2 to a newly allocated string.
  563. *
  564. * @param str1 A string.
  565. * @param str2 Another string.
  566. * @returns A newly-allocated string. This string should be freed when no longer needed.
  567. */
  568. char *
  569. br_strcat (const char *str1, const char *str2)
  570. {
  571. char *result;
  572. size_t len1, len2;
  573. if (str1 == NULL)
  574. str1 = "";
  575. if (str2 == NULL)
  576. str2 = "";
  577. len1 = strlen (str1);
  578. len2 = strlen (str2);
  579. result = (char *) malloc (len1 + len2 + 1);
  580. memcpy (result, str1, len1);
  581. memcpy (result + len1, str2, len2);
  582. result[len1 + len2] = '\0';
  583. return result;
  584. }
  585. char *
  586. br_build_path (const char *dir, const char *file)
  587. {
  588. char *dir2, *result;
  589. size_t len;
  590. int must_free = 0;
  591. len = strlen (dir);
  592. if (len > 0 && dir[len - 1] != '/') {
  593. dir2 = br_strcat (dir, "/");
  594. must_free = 1;
  595. } else
  596. dir2 = (char *) dir;
  597. result = br_strcat (dir2, file);
  598. if (must_free)
  599. free (dir2);
  600. return result;
  601. }
  602. /* Emulates glibc's strndup() */
  603. static char *
  604. br_strndup (const char *str, size_t size)
  605. {
  606. char *result = (char *) NULL;
  607. size_t len;
  608. if (str == (const char *) NULL)
  609. return (char *) NULL;
  610. len = strlen (str);
  611. if (len == 0)
  612. return strdup ("");
  613. if (size > len)
  614. size = len;
  615. result = (char *) malloc (len + 1);
  616. memcpy (result, str, size);
  617. result[size] = '\0';
  618. return result;
  619. }
  620. /** Extracts the directory component of a path.
  621. *
  622. * Similar to g_dirname() or the dirname commandline application.
  623. *
  624. * Example:
  625. * \code
  626. * br_dirname ("/usr/local/foobar"); --> Returns: "/usr/local"
  627. * \endcode
  628. *
  629. * @param path A path.
  630. * @returns A directory name. This string should be freed when no longer needed.
  631. */
  632. char *
  633. br_dirname (const char *path)
  634. {
  635. char *end, *result;
  636. if (path == (const char *) NULL)
  637. return (char *) NULL;
  638. end = strrchr (path, '/');
  639. if (end == (const char *) NULL)
  640. return strdup (".");
  641. while (end > path && *end == '/')
  642. end--;
  643. result = br_strndup (path, end - path + 1);
  644. if (result[0] == 0) {
  645. free (result);
  646. return strdup ("/");
  647. } else
  648. return result;
  649. }
  650. #ifdef __cplusplus
  651. }
  652. #endif /* __cplusplus */
  653. #endif /* __BINRELOC_C__ */