macdependency/MachO/machoarchitecture.h
Mike Lischke 972fcb3094 Overhaul of the application to avoid it crashing on macOS Sierra.
- Applied all recommended XCode (8) settings.
- Removed boost and replaced that code by standard functions.
- Implemented name mangling via abi::__cxa_demangle instead of running an external process to use c++filt.
- Enabled C++11. Min deployment target is now OSX 10.7.
- Some code clean up (e.g. formatting, std namespace).
2016-11-19 16:23:39 +01:00

51 lines
1.9 KiB
C++

#ifndef MACHOARCHITECTURE_H
#define MACHOARCHITECTURE_H
#include "macho_global.h"
class MachOFile;
class MachOHeader;
class LoadCommand;
class DylibCommand;
class EXPORT MachOArchitecture
{
private:
typedef std::list<LoadCommand*> LoadCommands;
typedef LoadCommands::iterator LoadCommandsIterator;
public:
typedef LoadCommands::const_iterator LoadCommandsConstIterator;
MachOArchitecture(MachOFile& file, uint32_t magic, unsigned int size);
~MachOArchitecture();
const MachOHeader* getHeader() { return header; }
LoadCommandsConstIterator getLoadCommandsBegin() const { if(!hasReadLoadCommands) { readLoadCommands(); } return loadCommands.begin(); }
LoadCommandsConstIterator getLoadCommandsEnd() const { if(!hasReadLoadCommands) { readLoadCommands(); } return loadCommands.end(); }
DylibCommand* getDynamicLibIdCommand() const { if(!hasReadLoadCommands) { readLoadCommands(); } return dynamicLibIdCommand; }
unsigned int getSize() const;
void initParentArchitecture(const MachOArchitecture* parent);
const MachOFile* getFile() const { return &file; }
std::string getDynamicLinker() const { return dylinker; }
std::vector<std::string*> getRpaths(bool recursively = true) const;
std::string getResolvedName(const std::string& name, const std::string& workingPath) const;
const uint8_t* getUuid() const;
private:
MachOHeader* header;
MachOFile& file;
const unsigned int size;
mutable bool hasReadLoadCommands;
void readLoadCommands() const;
const MachOArchitecture* parent; // architecture from which this architecture was loaded
// all those are mutable, because they are initialized not in the constructor, but in the readLoadCommands method
mutable LoadCommands loadCommands;
mutable DylibCommand* dynamicLibIdCommand;
mutable std::vector<std::string*> rpaths;
mutable const uint8_t* uuid;
mutable std::string dylinker;
};
#endif // MACHOARCHITECTURE_H