Skip to content

Commit

Permalink
small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
StanHash committed Feb 19, 2018
1 parent 88fcb2d commit 81cc5c2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
project(lyn)
cmake_minimum_required(VERSION 3.8)
cmake_minimum_required(VERSION 3.1)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static")

set(SOURCE_LIST
main.cpp

Expand Down Expand Up @@ -36,4 +34,6 @@ set(SOURCE_LIST
core/arm_relocator.cpp
)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static")

add_executable(${PROJECT_NAME} ${SOURCE_LIST})
16 changes: 8 additions & 8 deletions core/arm_relocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
namespace lyn {

struct arm_data_abs32_reloc : public arm_relocator::relocatelet {
event_code make_event_code(const section_data&, unsigned int, const std::string &sym, int addend) const {
event_code make_event_code(const section_data& data, unsigned int offset, const std::string& sym, int addend) const {
return lyn::event_code(
lyn::event_code::CODE_POIN,
arm_relocator::abs_reloc_string(sym, addend)
arm_relocator::abs_reloc_string(sym, data.at<std::uint32_t>(offset) + addend)
);
}

Expand All @@ -19,10 +19,10 @@ struct arm_data_abs32_reloc : public arm_relocator::relocatelet {
};

struct arm_data_rel32_reloc : public arm_relocator::relocatelet {
event_code make_event_code(const section_data&, unsigned int, const std::string &sym, int addend) const {
event_code make_event_code(const section_data& data, unsigned int offset, const std::string &sym, int addend) const {
return lyn::event_code(
lyn::event_code::CODE_WORD,
arm_relocator::rel_reloc_string(sym, addend)
arm_relocator::rel_reloc_string(sym, data.at<std::uint32_t>(offset) + addend)
);
}

Expand All @@ -32,10 +32,10 @@ struct arm_data_rel32_reloc : public arm_relocator::relocatelet {
};

struct arm_data_abs16_reloc : public arm_relocator::relocatelet {
event_code make_event_code(const section_data&, unsigned int, const std::string& sym, int addend) const {
event_code make_event_code(const section_data& data, unsigned int offset, const std::string& sym, int addend) const {
return lyn::event_code(
lyn::event_code::CODE_SHORT,
arm_relocator::abs_reloc_string(sym, addend)
arm_relocator::abs_reloc_string(sym, data.at<std::uint16_t>(offset) + addend)
);
}

Expand All @@ -45,10 +45,10 @@ struct arm_data_abs16_reloc : public arm_relocator::relocatelet {
};

struct arm_data_abs8_reloc : public arm_relocator::relocatelet {
event_code make_event_code(const section_data&, unsigned int, const std::string& sym, int addend) const {
event_code make_event_code(const section_data& data, unsigned int offset, const std::string& sym, int addend) const {
return lyn::event_code(
lyn::event_code::CODE_BYTE,
arm_relocator::abs_reloc_string(sym, addend)
arm_relocator::abs_reloc_string(sym, data.byte_at(offset) + addend)
);
}

Expand Down
4 changes: 2 additions & 2 deletions core/binary_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class binary_file {
std::vector<byte_t> mData;
};

template<typename T, int byte_count = sizeof(T)>
template<typename T, int byte_count>
T binary_file::read(int& pos) const {
T result = 0;

Expand All @@ -57,7 +57,7 @@ T binary_file::read(int& pos) const {
return result;
}

template<typename T, int byte_count = sizeof(T)>
template<typename T, int byte_count>
void binary_file::write(int pos, T value) {
for (int i=0; i<byte_count; ++i)
write_byte(pos + i, (value >> (i*8)) & 0xFF);
Expand Down

0 comments on commit 81cc5c2

Please sign in to comment.