Skip to content

Commit

Permalink
Make sure we have a correct visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
romainthomas committed Oct 5, 2024
1 parent b11bc1e commit ba294bd
Show file tree
Hide file tree
Showing 17 changed files with 71 additions and 34 deletions.
6 changes: 5 additions & 1 deletion api/python/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
find_package(Python REQUIRED COMPONENTS Interpreter Development.Module)

if (LIEF_PY_LIEF_EXT)
find_package(LIEF REQUIRED COMPONENTS STATIC)
if (LIEF_PY_LIEF_EXT_SHARED)
find_package(LIEF REQUIRED COMPONENTS SHARED)
else()
find_package(LIEF REQUIRED COMPONENTS STATIC)
endif()
message(STATUS "Using pre-installed version of LIEF")
set(LIEF_TARGET LIEF::LIEF)
set_target_properties(LIB_LIEF PROPERTIES EXCLUDE_FROM_ALL ON)
Expand Down
4 changes: 4 additions & 0 deletions cmake/LIEFOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ option(LIEF_OBJC "Build LIEF with ObjC metadata support" OFF)
cmake_dependent_option(LIEF_PYTHON_EDITABLE "Make an editable build " OFF
"LIEF_PYTHON_API" OFF)

cmake_dependent_option(LIEF_PY_LIEF_EXT_SHARED
"Use a 'SHARED' version of LIEF instead of a static one" OFF
"LIEF_PY_LIEF_EXT" OFF)

cmake_dependent_option(LIEF_PYTHON_STATIC "Internal usage" OFF
"LIEF_PYTHON_API" OFF)

Expand Down
3 changes: 2 additions & 1 deletion include/LIEF/Abstract/DebugInfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@
#ifndef LIEF_DEBUGINFO_H
#define LIEF_DEBUGINFO_H
#include <memory>
#include "LIEF/visibility.h"
namespace LIEF {

namespace details {
class DebugInfo;
}

class DebugInfo {
class LIEF_API DebugInfo {
public:
enum class FORMAT {
UNKNOWN = 0,
Expand Down
6 changes: 2 additions & 4 deletions include/LIEF/BinaryStream/BinaryStream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,19 @@

#include <cstdint>
#include <vector>
#include <memory>
#include <cstring>
#include <string>
#include <type_traits>
#include <algorithm>

#include "LIEF/endianness_support.hpp"
#include "LIEF/errors.hpp"
#include "LIEF/visibility.h"

namespace LIEF {
class ASN1Reader;

//! Class that is used to a read stream of data from different sources
class BinaryStream {
class LIEF_API BinaryStream {
public:
friend class ASN1Reader;

Expand Down Expand Up @@ -352,7 +351,6 @@ class ToggleEndianness {
};



template<class T>
result<T> BinaryStream::read() const {
result<T> tmp = this->peek<T>();
Expand Down
4 changes: 3 additions & 1 deletion include/LIEF/BinaryStream/FileStream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@

#include "LIEF/errors.hpp"
#include "LIEF/BinaryStream/BinaryStream.hpp"
#include "LIEF/visibility.h"

namespace LIEF {

//! Stream interface over a std::ifstream
class FileStream : public BinaryStream {
class LIEF_API FileStream : public BinaryStream {
public:
static result<FileStream> from_file(const std::string& file);
FileStream(std::ifstream fs, uint64_t size) :
Expand Down
3 changes: 2 additions & 1 deletion include/LIEF/BinaryStream/MemoryStream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@
#include <cstdint>

#include "LIEF/errors.hpp"
#include "LIEF/visibility.h"
#include "LIEF/BinaryStream/BinaryStream.hpp"

namespace LIEF {
class Binary;
class MemoryStream : public BinaryStream {
class LIEF_API MemoryStream : public BinaryStream {
public:
using BinaryStream::p;
using BinaryStream::end;
Expand Down
4 changes: 3 additions & 1 deletion include/LIEF/BinaryStream/SpanStream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@
#include <vector>
#include <array>
#include <cstddef>
#include <memory>

#include "LIEF/errors.hpp"
#include "LIEF/span.hpp"
#include "LIEF/visibility.h"
#include "LIEF/BinaryStream/BinaryStream.hpp"

namespace LIEF {
class VectorStream;
class SpanStream : public BinaryStream {
class LIEF_API SpanStream : public BinaryStream {
public:
using BinaryStream::p;
using BinaryStream::end;
Expand Down
4 changes: 3 additions & 1 deletion include/LIEF/BinaryStream/VectorStream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@

#include <vector>
#include <string>
#include <memory>

#include "LIEF/errors.hpp"
#include "LIEF/visibility.h"
#include "LIEF/BinaryStream/BinaryStream.hpp"

namespace LIEF {
class SpanStream;
class VectorStream : public BinaryStream {
class LIEF_API VectorStream : public BinaryStream {
public:
using BinaryStream::p;
using BinaryStream::end;
Expand Down
3 changes: 2 additions & 1 deletion include/LIEF/ELF/NoteDetails/properties/AArch64Feature.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#ifndef LIEF_ELF_NOTE_DETAILS_PROPERTIES_AARCH64_FEATURE_H
#define LIEF_ELF_NOTE_DETAILS_PROPERTIES_AARCH64_FEATURE_H

#include "LIEF/visibility.h"
#include "LIEF/ELF/NoteDetails/NoteGnuProperty.hpp"

namespace LIEF {
Expand All @@ -24,7 +25,7 @@ class BinaryStream;
namespace ELF {

/// This class represents the `GNU_PROPERTY_AARCH64_FEATURE_1_AND` property.
class AArch64Feature : public NoteGnuProperty::Property {
class LIEF_API AArch64Feature : public NoteGnuProperty::Property {
public:
enum class FEATURE {
UNKNOWN = 0,
Expand Down
3 changes: 2 additions & 1 deletion include/LIEF/ELF/NoteDetails/properties/StackSize.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@
#define LIEF_ELF_NOTE_DETAILS_PROPERTIES_STACK_SIZE_H

#include "LIEF/ELF/NoteDetails/NoteGnuProperty.hpp"
#include "LIEF/visibility.h"

namespace LIEF {
namespace ELF {
/// This class provides an interface over the `GNU_PROPERTY_STACK_SIZE` property
///
/// This property can be used by the loader to raise the stack limit.
class StackSize : public NoteGnuProperty::Property {
class LIEF_API StackSize : public NoteGnuProperty::Property {
public:
static bool classof(const NoteGnuProperty::Property* prop) {
return prop->type() == NoteGnuProperty::Property::TYPE::STACK_SIZE;
Expand Down
3 changes: 2 additions & 1 deletion include/LIEF/ELF/NoteDetails/properties/X86Feature.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <utility>

#include "LIEF/ELF/NoteDetails/NoteGnuProperty.hpp"
#include "LIEF/visibility.h"

namespace LIEF {
namespace ELF {
Expand All @@ -28,7 +29,7 @@ namespace ELF {
/// - ``GNU_PROPERTY_X86_FEATURE_1_AND``
/// - ``GNU_PROPERTY_X86_FEATURE_2_USED``
/// - ``GNU_PROPERTY_X86_FEATURE_2_NEEDED``
class X86Features : public NoteGnuProperty::Property {
class LIEF_API X86Features : public NoteGnuProperty::Property {
public:

/// Flag according to the ``_AND``, ``_USED`` or ``_NEEDED`` suffixes
Expand Down
3 changes: 2 additions & 1 deletion include/LIEF/ELF/NoteDetails/properties/X86ISA.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <utility>

#include "LIEF/ELF/NoteDetails/NoteGnuProperty.hpp"
#include "LIEF/visibility.h"

namespace LIEF {
namespace ELF {
Expand All @@ -31,7 +32,7 @@ namespace ELF {
/// - ``GNU_PROPERTY_X86_COMPAT_ISA_1_NEEDED``
/// - ``GNU_PROPERTY_X86_COMPAT_2_ISA_1_USED``
/// - ``GNU_PROPERTY_X86_COMPAT_2_ISA_1_NEEDED``
class X86ISA : public NoteGnuProperty::Property {
class LIEF_API X86ISA : public NoteGnuProperty::Property {
public:
enum class FLAG {
NONE = 0,
Expand Down
3 changes: 2 additions & 1 deletion include/LIEF/MachO/BindingInfoIterator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
#ifndef LIEF_MACHO_BINDING_INFO_IT_H
#define LIEF_MACHO_BINDING_INFO_IT_H
#include "LIEF/visibility.h"
#include "LIEF/iterators.hpp"
#include "LIEF/MachO/BindingInfo.hpp"

Expand All @@ -24,7 +25,7 @@ class Binary;
class DyldInfo;
class DyldChainedFixups;

class BindingInfoIterator :
class LIEF_API BindingInfoIterator :
public iterator_facade_base<BindingInfoIterator,
std::random_access_iterator_tag,
const BindingInfo&,
Expand Down
46 changes: 30 additions & 16 deletions include/LIEF/MachO/ChainedPointerAnalysis.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
#include <functional>

#include "LIEF/MachO/DyldChainedFormat.hpp"
#include "LIEF/config.h"
#include "LIEF/errors.hpp"
#include "LIEF/visibility.h"

namespace LIEF {
class BinaryStream;
namespace MachO {
class ChainedPointerAnalysis {
class LIEF_API ChainedPointerAnalysis {
public:
// DYLD_CHAINED_PTR_FORMAT::PTR_ARM64E
struct dyld_chained_ptr_arm64e_rebase_t
Expand All @@ -37,7 +37,8 @@ class ChainedPointerAnalysis {
bind : 1,
auth : 1;

friend std::ostream& operator<<(std::ostream& os, const dyld_chained_ptr_arm64e_rebase_t& chain);
friend LIEF_API
std::ostream& operator<<(std::ostream& os, const dyld_chained_ptr_arm64e_rebase_t& chain);

uint64_t unpack_target() const {
return uint64_t(high8) | target;
Expand All @@ -54,7 +55,8 @@ class ChainedPointerAnalysis {
bind : 1,
auth : 1;

friend std::ostream& operator<<(std::ostream& os, const dyld_chained_ptr_arm64e_bind_t& chain);
friend LIEF_API
std::ostream& operator<<(std::ostream& os, const dyld_chained_ptr_arm64e_bind_t& chain);
};

// DYLD_CHAINED_PTR_FORMAT::PTR_ARM64E
Expand All @@ -68,7 +70,8 @@ class ChainedPointerAnalysis {
bind : 1,
auth : 1;

friend std::ostream& operator<<(std::ostream& os, const dyld_chained_ptr_arm64e_auth_rebase_t& chain);
friend LIEF_API
std::ostream& operator<<(std::ostream& os, const dyld_chained_ptr_arm64e_auth_rebase_t& chain);
};

// DYLD_CHAINED_PTR_FORMAT::PTR_ARM64E
Expand All @@ -83,7 +86,8 @@ class ChainedPointerAnalysis {
bind : 1,
auth : 1;

friend std::ostream& operator<<(std::ostream& os, const dyld_chained_ptr_arm64e_auth_bind_t& chain);
friend LIEF_API
std::ostream& operator<<(std::ostream& os, const dyld_chained_ptr_arm64e_auth_bind_t& chain);
};

// DYLD_CHAINED_PTR_FORMAT::PTR_64 & DYLD_CHAINED_PTR_FORMAT::PTR_64_OFFSET
Expand All @@ -95,7 +99,8 @@ class ChainedPointerAnalysis {
next : 12,
bind : 1;

friend std::ostream& operator<<(std::ostream& os, const dyld_chained_ptr_64_rebase_t& chain);
friend LIEF_API
std::ostream& operator<<(std::ostream& os, const dyld_chained_ptr_64_rebase_t& chain);

uint64_t unpack_target() const {
return uint64_t(high8) | target;
Expand All @@ -112,7 +117,8 @@ class ChainedPointerAnalysis {
bind : 1,
auth : 1;

friend std::ostream& operator<<(std::ostream& os, const dyld_chained_ptr_arm64e_bind24_t& chain);
friend LIEF_API
std::ostream& operator<<(std::ostream& os, const dyld_chained_ptr_arm64e_bind24_t& chain);
};

// DYLD_CHAINED_PTR_FORMAT::PTR_ARM64E_USERLAND24
Expand All @@ -127,7 +133,8 @@ class ChainedPointerAnalysis {
bind : 1,
auth : 1;

friend std::ostream& operator<<(std::ostream& os, const dyld_chained_ptr_arm64e_auth_bind24_t& chain);
friend LIEF_API
std::ostream& operator<<(std::ostream& os, const dyld_chained_ptr_arm64e_auth_bind24_t& chain);
};

// DYLD_CHAINED_PTR_FORMAT::PTR_64
Expand All @@ -139,7 +146,8 @@ class ChainedPointerAnalysis {
next : 12,
bind : 1;

friend std::ostream& operator<<(std::ostream& os, const dyld_chained_ptr_64_bind_t& chain);
friend LIEF_API
std::ostream& operator<<(std::ostream& os, const dyld_chained_ptr_64_bind_t& chain);
};

// DYLD_CHAINED_PTR_FORMAT::PTR_64_KERNEL_CACHE
Expand All @@ -153,7 +161,8 @@ class ChainedPointerAnalysis {
next : 12,
is_auth : 1;

friend std::ostream& operator<<(std::ostream& os, const dyld_chained_ptr_64_kernel_cache_rebase_t& chain);
friend LIEF_API
std::ostream& operator<<(std::ostream& os, const dyld_chained_ptr_64_kernel_cache_rebase_t& chain);
};

// DYLD_CHAINED_PTR_FORMAT::PTR_32
Expand All @@ -163,7 +172,8 @@ class ChainedPointerAnalysis {
next : 5,
bind : 1;

friend std::ostream& operator<<(std::ostream& os, const dyld_chained_ptr_32_rebase_t& chain);
friend LIEF_API
std::ostream& operator<<(std::ostream& os, const dyld_chained_ptr_32_rebase_t& chain);
};

// DYLD_CHAINED_PTR_FORMAT::PTR_32
Expand All @@ -174,7 +184,8 @@ class ChainedPointerAnalysis {
next : 5,
bind : 1;

friend std::ostream& operator<<(std::ostream& os, const dyld_chained_ptr_32_bind_t& chain);
friend LIEF_API
std::ostream& operator<<(std::ostream& os, const dyld_chained_ptr_32_bind_t& chain);
};

// DYLD_CHAINED_PTR_FORMAT::PTR_32_CACHE
Expand All @@ -183,7 +194,8 @@ class ChainedPointerAnalysis {
uint32_t target : 30,
next : 2;

friend std::ostream& operator<<(std::ostream& os, const dyld_chained_ptr_32_cache_rebase_t& chain);
friend LIEF_API
std::ostream& operator<<(std::ostream& os, const dyld_chained_ptr_32_cache_rebase_t& chain);
};

// DYLD_CHAINED_PTR_FORMAT::PTR_32_FIRMWARE
Expand All @@ -192,7 +204,8 @@ class ChainedPointerAnalysis {
uint32_t target : 26,
next : 6;

friend std::ostream& operator<<(std::ostream& os, const dyld_chained_ptr_32_firmware_rebase_t& chain);
friend LIEF_API
std::ostream& operator<<(std::ostream& os, const dyld_chained_ptr_32_firmware_rebase_t& chain);
};

enum class PTR_TYPE {
Expand Down Expand Up @@ -368,7 +381,8 @@ class ChainedPointerAnalysis {
}
bool is_auth() const;

friend std::ostream& operator<<(std::ostream& os, const union_pointer_t& ptr);
friend LIEF_API
std::ostream& operator<<(std::ostream& os, const union_pointer_t& ptr);
};

static_assert(sizeof(union_pointer_t) == 16);
Expand Down
2 changes: 1 addition & 1 deletion include/LIEF/MachO/LoadCommand.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ class LIEF_API LoadCommand : public Object {
uint64_t command_offset_ = 0;
};

const char* to_string(LoadCommand::TYPE type);
LIEF_API const char* to_string(LoadCommand::TYPE type);

}
}
Expand Down
3 changes: 2 additions & 1 deletion include/LIEF/PE/signature/PKCS9TSTInfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <memory>

#include "LIEF/Visitor.hpp"
#include "LIEF/visibility.h"
#include "LIEF/PE/signature/ContentInfo.hpp"

namespace LIEF {
Expand Down Expand Up @@ -55,7 +56,7 @@ namespace PE {
//! micros [1] INTEGER (1..999) OPTIONAL
//! }
//! ```
class PKCS9TSTInfo : public ContentInfo::Content {
class LIEF_API PKCS9TSTInfo : public ContentInfo::Content {
friend class SignatureParser;

public:
Expand Down
Loading

0 comments on commit ba294bd

Please sign in to comment.