shared_flat_add_library.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Copyright (C) 2006 CodeSourcery Inc
  3. *
  4. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  5. *
  6. * This file defines __shared_flat_add_library. If a library has
  7. * initialistion and finalisation code, it should use this routine
  8. * to register itself.
  9. */
  10. #include "shared_flat_lib.h"
  11. /* The initialisation and finalisation symbols for this library. */
  12. extern void _init(void) attribute_hidden weak_function;
  13. extern void _fini(void) attribute_hidden weak_function;
  14. extern void (*__preinit_array_start[])(void) attribute_hidden;
  15. extern void (*__preinit_array_end[])(void) attribute_hidden;
  16. extern void (*__init_array_start[])(void) attribute_hidden;
  17. extern void (*__init_array_end[])(void) attribute_hidden;
  18. extern void (*__fini_array_start[])(void) attribute_hidden;
  19. extern void (*__fini_array_end[])(void) attribute_hidden;
  20. /* The shared_flat_lib structure that describes this library. */
  21. static struct shared_flat_lib this_lib = {
  22. 0,
  23. 0,
  24. __preinit_array_start,
  25. __preinit_array_end,
  26. __init_array_start,
  27. __init_array_end,
  28. __fini_array_start,
  29. __fini_array_end,
  30. _init,
  31. _fini
  32. };
  33. /* Add this_lib to the end of the global list. */
  34. void __shared_flat_add_library(void) attribute_hidden;
  35. void __shared_flat_add_library(void)
  36. {
  37. this_lib.prev = __last_shared_lib;
  38. if (this_lib.prev)
  39. this_lib.prev->next = &this_lib;
  40. else
  41. __first_shared_lib = &this_lib;
  42. __last_shared_lib = &this_lib;
  43. }