/thirdparty/breakpad/common/mac/macho_utilities.h

http://github.com/tomahawk-player/tomahawk · C++ Header · 92 lines · 39 code · 15 blank · 38 comment · 0 complexity · 62dcb9a7858714ca59a6d89188f95499 MD5 · raw file

  1. // Copyright (c) 2006, Google Inc.
  2. // All rights reserved.
  3. //
  4. // Redistribution and use in source and binary forms, with or without
  5. // modification, are permitted provided that the following conditions are
  6. // met:
  7. //
  8. // * Redistributions of source code must retain the above copyright
  9. // notice, this list of conditions and the following disclaimer.
  10. // * Redistributions in binary form must reproduce the above
  11. // copyright notice, this list of conditions and the following disclaimer
  12. // in the documentation and/or other materials provided with the
  13. // distribution.
  14. // * Neither the name of Google Inc. nor the names of its
  15. // contributors may be used to endorse or promote products derived from
  16. // this software without specific prior written permission.
  17. //
  18. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  19. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  20. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  21. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  22. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  23. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  24. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  25. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  26. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  28. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. // macho_utilities.h: Utilities for dealing with mach-o files
  30. //
  31. // Author: Dave Camp
  32. #ifndef COMMON_MAC_MACHO_UTILITIES_H__
  33. #define COMMON_MAC_MACHO_UTILITIES_H__
  34. #include <mach-o/loader.h>
  35. #include <mach/thread_status.h>
  36. /* Some #defines and structs that aren't defined in older SDKs */
  37. #ifndef CPU_ARCH_ABI64
  38. # define CPU_ARCH_ABI64 0x01000000
  39. #endif
  40. #ifndef CPU_TYPE_X86
  41. # define CPU_TYPE_X86 CPU_TYPE_I386
  42. #endif
  43. #ifndef CPU_TYPE_POWERPC64
  44. # define CPU_TYPE_POWERPC64 (CPU_TYPE_POWERPC | CPU_ARCH_ABI64)
  45. #endif
  46. #ifndef LC_UUID
  47. # define LC_UUID 0x1b /* the uuid */
  48. #endif
  49. #if TARGET_CPU_X86
  50. # define BREAKPAD_MACHINE_THREAD_STATE i386_THREAD_STATE
  51. #elif TARGET_CPU_X86_64
  52. # define BREAKPAD_MACHINE_THREAD_STATE x86_THREAD_STATE64
  53. #else
  54. # define BREAKPAD_MACHINE_THREAD_STATE MACHINE_THREAD_STATE
  55. #endif
  56. // The uuid_command struct/swap routines were added during the 10.4 series.
  57. // Their presence isn't guaranteed.
  58. struct breakpad_uuid_command {
  59. uint32_t cmd; /* LC_UUID */
  60. uint32_t cmdsize; /* sizeof(struct uuid_command) */
  61. uint8_t uuid[16]; /* the 128-bit uuid */
  62. };
  63. void breakpad_swap_uuid_command(struct breakpad_uuid_command *uc,
  64. enum NXByteOrder target_byte_order);
  65. // Older SDKs defines thread_state_data_t as an int[] instead
  66. // of the natural_t[] it should be.
  67. typedef natural_t breakpad_thread_state_data_t[THREAD_STATE_MAX];
  68. // The 64-bit swap routines were added during the 10.4 series, their
  69. // presence isn't guaranteed.
  70. void breakpad_swap_segment_command_64(struct segment_command_64 *sg,
  71. enum NXByteOrder target_byte_order);
  72. void breakpad_swap_mach_header_64(struct mach_header_64 *mh,
  73. enum NXByteOrder target_byte_order);
  74. void breakpad_swap_section_64(struct section_64 *s,
  75. uint32_t nsects,
  76. enum NXByteOrder target_byte_order);
  77. #endif