FIRCLSBinaryImage.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // Copyright 2019 Google
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #pragma once
  15. #include <stdbool.h>
  16. #include <stdint.h>
  17. #include "Crashlytics/Crashlytics/Helpers/FIRCLSFeatures.h"
  18. #include "Crashlytics/Crashlytics/Helpers/FIRCLSFile.h"
  19. #include "Crashlytics/Shared/FIRCLSMachO/FIRCLSMachO.h"
  20. __BEGIN_DECLS
  21. // Typically, apps seem to have ~300 binary images loaded
  22. #define CLS_BINARY_IMAGE_RUNTIME_NODE_COUNT (512)
  23. #define CLS_BINARY_IMAGE_RUNTIME_NODE_NAME_SIZE (32)
  24. #define CLS_BINARY_IMAGE_RUNTIME_NODE_RECORD_NAME 0
  25. #define FIRCLSUUIDStringLength (33)
  26. typedef struct {
  27. _Atomic(void*) volatile baseAddress;
  28. uint64_t size;
  29. #if CLS_DWARF_UNWINDING_SUPPORTED
  30. const void* ehFrame;
  31. #endif
  32. #if CLS_COMPACT_UNWINDING_SUPPORTED
  33. const void* unwindInfo;
  34. #endif
  35. const void* crashInfo;
  36. #if CLS_BINARY_IMAGE_RUNTIME_NODE_RECORD_NAME
  37. char name[CLS_BINARY_IMAGE_RUNTIME_NODE_NAME_SIZE];
  38. #endif
  39. } FIRCLSBinaryImageRuntimeNode;
  40. typedef struct {
  41. char uuidString[FIRCLSUUIDStringLength];
  42. bool encrypted;
  43. FIRCLSMachOVersion builtSDK;
  44. FIRCLSMachOVersion minSDK;
  45. FIRCLSBinaryImageRuntimeNode node;
  46. struct FIRCLSMachOSlice slice;
  47. intptr_t vmaddr_slide;
  48. } FIRCLSBinaryImageDetails;
  49. typedef struct {
  50. const char* path;
  51. } FIRCLSBinaryImageReadOnlyContext;
  52. typedef struct {
  53. FIRCLSFile file;
  54. FIRCLSBinaryImageRuntimeNode nodes[CLS_BINARY_IMAGE_RUNTIME_NODE_COUNT];
  55. } FIRCLSBinaryImageReadWriteContext;
  56. void FIRCLSBinaryImageInit(FIRCLSBinaryImageReadOnlyContext* roContext,
  57. FIRCLSBinaryImageReadWriteContext* rwContext);
  58. #if CLS_COMPACT_UNWINDING_SUPPORTED
  59. bool FIRCLSBinaryImageSafeFindImageForAddress(uintptr_t address,
  60. FIRCLSBinaryImageRuntimeNode* image);
  61. bool FIRCLSBinaryImageSafeHasUnwindInfo(FIRCLSBinaryImageRuntimeNode* image);
  62. #endif
  63. bool FIRCLSBinaryImageFindImageForUUID(const char* uuidString,
  64. FIRCLSBinaryImageDetails* imageDetails);
  65. bool FIRCLSBinaryImageRecordMainExecutable(FIRCLSFile* file);
  66. __END_DECLS