diff options
author | René Bertin <rjvbertin@gmail.com> | 2024-05-04 17:59:27 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2024-06-04 12:37:47 (GMT) |
commit | 598bc704741ccb21c8c382ae4809e5fbfbdc2715 (patch) | |
tree | 1c85e9de716b4f33b48b3fecbc517a0b328afeb6 /Source/cmMachO.h | |
parent | 1df18d5e54023af6d7802a7219d2d4ef6e88bdb2 (diff) | |
download | CMake-598bc704741ccb21c8c382ae4809e5fbfbdc2715.zip CMake-598bc704741ccb21c8c382ae4809e5fbfbdc2715.tar.gz CMake-598bc704741ccb21c8c382ae4809e5fbfbdc2715.tar.bz2 |
file: Add undocumented READ_MACHO subcommand on macOS
Provide a way to parse the architectures of a Mach-O binary.
Issue: #25952
Diffstat (limited to 'Source/cmMachO.h')
-rw-r--r-- | Source/cmMachO.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/Source/cmMachO.h b/Source/cmMachO.h index ec7d54c..ddbfc28 100644 --- a/Source/cmMachO.h +++ b/Source/cmMachO.h @@ -7,6 +7,9 @@ #include <iosfwd> #include <memory> #include <string> +#include <vector> + +#include <mach/machine.h> #if !defined(CMake_USE_MACH_PARSER) # error "This file may be included only if CMake_USE_MACH_PARSER is enabled." @@ -20,6 +23,16 @@ class cmMachOInternal; class cmMachO { public: + struct MachHeader + { + cpu_type_t CpuType; + cpu_subtype_t CpuSubType; + uint32_t FileType; + }; + class StringList : public std::vector<std::string> + { + }; + /** Construct with the name of the Mach-O input file to parse. */ cmMachO(const char* fname); @@ -38,8 +51,17 @@ public: /** Print human-readable information about the Mach-O file. */ void PrintInfo(std::ostream& os) const; + /** Get the architectural header(s) from the Mach-O file. */ + std::vector<struct MachHeader> GetHeaders() const { return this->Headers; } + + /** Get a list of the recognized architectures present in the Mach-O file + * in the order in which they are found. + */ + StringList GetArchitectures() const; + private: friend class cmMachOInternal; bool Valid() const; std::unique_ptr<cmMachOInternal> Internal; + std::vector<struct MachHeader> Headers; }; |