Projects STRLCPY LIEF Commits 9d28a065
🤬
  • ■ ■ ■ ■ ■ ■
    src/ELF/Binary.cpp
    skipped 61 lines
    62 62   
    63 63  #include "Binary.tcc"
    64 64  #include "Object.tcc"
     65 +#include "internal_utils.hpp"
    65 66   
    66 67  namespace LIEF {
    67 68  namespace ELF {
    skipped 95 lines
    163 164   });
    164 165   
    165 166   if (it_entry == std::end(dynamic_entries_)) {
    166  - LIEF_WARN("Can't find {} in the dynamic table. This entry can't be removed", entry);
     167 + LIEF_WARN("Can't find {} in the dynamic table. This entry can't be removed", to_string(entry));
    167 168   return;
    168 169   }
    169 170   dynamic_entries_.erase(it_entry);
    skipped 1650 lines
    1820 1821   continue;
    1821 1822   }
    1822 1823   if (section->file_offset() >= from) {
    1823  - LIEF_DEBUG("[BEFORE] {}", *section);
     1824 + LIEF_DEBUG("[BEFORE] {}", to_string(*section));
    1824 1825   section->file_offset(section->file_offset() + shift);
    1825 1826   if (section->virtual_address() > 0) {
    1826 1827   section->virtual_address(section->virtual_address() + shift);
    1827 1828   }
    1828  - LIEF_DEBUG("[AFTER ] {}", *section);
     1829 + LIEF_DEBUG("[AFTER ] {}", to_string(*section));
    1829 1830   }
    1830 1831   }
    1831 1832  }
    skipped 4 lines
    1836 1837   
    1837 1838   for (std::unique_ptr<Segment>& segment : segments_) {
    1838 1839   if (segment->file_offset() >= from) {
    1839  - LIEF_DEBUG("[BEFORE] {}", *segment);
     1840 + LIEF_DEBUG("[BEFORE] {}", to_string(*segment));
    1840 1841   segment->file_offset(segment->file_offset() + shift);
    1841 1842   segment->virtual_address(segment->virtual_address() + shift);
    1842 1843   segment->physical_address(segment->physical_address() + shift);
    1843  - LIEF_DEBUG("[AFTER ] {}", *segment);
     1844 + LIEF_DEBUG("[AFTER ] {}", to_string(*segment));
    1844 1845   }
    1845 1846   }
    1846 1847  }
    skipped 2 lines
    1849 1850   LIEF_DEBUG("Shift dynamic entries by 0x{:x} from 0x{:x}", shift, from);
    1850 1851   
    1851 1852   for (std::unique_ptr<DynamicEntry>& entry : dynamic_entries_) {
    1852  - LIEF_DEBUG("[BEFORE] {}", *entry);
     1853 + LIEF_DEBUG("[BEFORE] {}", to_string(*entry));
    1853 1854   switch (entry->tag()) {
    1854 1855   case DynamicEntry::TAG::PLTGOT:
    1855 1856   case DynamicEntry::TAG::HASH:
    skipped 42 lines
    1898 1899   //LIEF_DEBUG("{} not supported", to_string(entry->tag()));
    1899 1900   }
    1900 1901   }
    1901  - LIEF_DEBUG("[AFTER ] {}", *entry);
     1902 + LIEF_DEBUG("[AFTER ] {}", to_string(*entry));
    1902 1903   }
    1903 1904  }
    1904 1905   
    skipped 2 lines
    1907 1908   LIEF_DEBUG("Shift symbols by 0x{:x} from 0x{:x}", shift, from);
    1908 1909   for (Symbol& symbol : symbols()) {
    1909 1910   if (symbol.value() >= from) {
    1910  - LIEF_DEBUG("[BEFORE] {}", symbol);
     1911 + LIEF_DEBUG("[BEFORE] {}", to_string(symbol));
    1911 1912   symbol.value(symbol.value() + shift);
    1912  - LIEF_DEBUG("[AFTER ] {}", symbol);
     1913 + LIEF_DEBUG("[AFTER ] {}", to_string(symbol));
    1913 1914   }
    1914 1915   }
    1915 1916  }
    skipped 1065 lines
    2981 2982   continue;
    2982 2983   }
    2983 2984   if (section->file_offset() >= from && section->type() != Section::TYPE::NOBITS) {
    2984  - LIEF_DEBUG("[BEFORE] {}", *section);
     2985 + LIEF_DEBUG("[BEFORE] {}", to_string(*section));
    2985 2986   section->file_offset(section->file_offset() + shift);
    2986 2987   if (section->virtual_address() > 0) {
    2987 2988   section->virtual_address(section->virtual_address() + shift);
    2988 2989   }
    2989  - LIEF_DEBUG("[AFTER ] {}", *section);
     2990 + LIEF_DEBUG("[AFTER ] {}", to_string(*section));
    2990 2991   }
    2991 2992   }
    2992 2993   return phdr_reloc_info_.new_offset;
    skipped 280 lines
  • ■ ■ ■ ■ ■ ■
    src/ELF/Binary.tcc
    skipped 25 lines
    26 26  #include "ELF/DataHandler/Node.hpp"
    27 27  #include "ELF/DataHandler/Handler.hpp"
    28 28   
     29 +#include "internal_utils.hpp"
     30 + 
    29 31  #include <numeric>
    30 32   
    31 33  #if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
    skipped 25 lines
    57 59   case Relocation::TYPE::ARM_GLOB_DAT:
    58 60   case Relocation::TYPE::ARM_IRELATIVE:
    59 61   {
    60  - LIEF_DEBUG("Patch addend of {}", relocation);
     62 + LIEF_DEBUG("Patch addend of {}", to_string(relocation));
    61 63   patch_addend<uint32_t>(relocation, from, shift);
    62 64   break;
    63 65   }
    skipped 28 lines
    92 94   case Relocation::TYPE::AARCH64_IRELATIVE:
    93 95   case Relocation::TYPE::AARCH64_ABS64:
    94 96   {
    95  - LIEF_DEBUG("Patch addend of {}", relocation);
     97 + LIEF_DEBUG("Patch addend of {}", to_string(relocation));
    96 98   patch_addend<uint64_t>(relocation, from, shift);
    97 99   break;
    98 100   }
    99 101   
    100 102   case Relocation::TYPE::AARCH64_ABS32:
    101 103   {
    102  - LIEF_DEBUG("Patch addend of {}", relocation);
     104 + LIEF_DEBUG("Patch addend of {}", to_string(relocation));
    103 105   patch_addend<uint32_t>(relocation, from, shift);
    104 106   break;
    105 107   }
    106 108   
    107 109   case Relocation::TYPE::AARCH64_ABS16:
    108 110   {
    109  - LIEF_DEBUG("Patch addend of {}", relocation);
     111 + LIEF_DEBUG("Patch addend of {}", to_string(relocation));
    110 112   patch_addend<uint16_t>(relocation, from, shift);
    111 113   break;
    112 114   }
    113 115   
    114 116   case Relocation::TYPE::AARCH64_PREL64:
    115 117   {
    116  - LIEF_DEBUG("Patch addend of {}", relocation);
     118 + LIEF_DEBUG("Patch addend of {}", to_string(relocation));
    117 119   patch_addend<uint64_t>(relocation, from, shift);
    118 120   break;
    119 121   }
    120 122   
    121 123   case Relocation::TYPE::AARCH64_PREL32:
    122 124   {
    123  - LIEF_DEBUG("Patch addend of {}", relocation);
     125 + LIEF_DEBUG("Patch addend of {}", to_string(relocation));
    124 126   patch_addend<uint32_t>(relocation, from, shift);
    125 127   break;
    126 128   }
    127 129   
    128 130   case Relocation::TYPE::AARCH64_PREL16:
    129 131   {
    130  - LIEF_DEBUG("Patch addend of {}", relocation);
     132 + LIEF_DEBUG("Patch addend of {}", to_string(relocation));
    131 133   patch_addend<uint16_t>(relocation, from, shift);
    132 134   break;
    133 135   }
    skipped 26 lines
    160 162   case Relocation::TYPE::X86_GLOB_DAT:
    161 163   case Relocation::TYPE::X86_32:
    162 164   {
    163  - LIEF_DEBUG("Patch addend of {}", relocation);
     165 + LIEF_DEBUG("Patch addend of {}", to_string(relocation));
    164 166   patch_addend<uint32_t>(relocation, from, shift);
    165 167   break;
    166 168   }
    skipped 32 lines
    199 201   case Relocation::TYPE::X86_64_GLOB_DAT:
    200 202   case Relocation::TYPE::X86_64_64:
    201 203   {
    202  - LIEF_DEBUG("Patch addend of {}", relocation);
     204 + LIEF_DEBUG("Patch addend of {}", to_string(relocation));
    203 205   patch_addend<uint64_t>(relocation, from, shift);
    204 206   break;
    205 207   }
    206 208   
    207 209   case Relocation::TYPE::X86_64_32:
    208 210   {
    209  - LIEF_DEBUG("Patch addend of {}", relocation);
     211 + LIEF_DEBUG("Patch addend of {}", to_string(relocation));
    210 212   patch_addend<uint32_t>(relocation, from, shift);
    211 213   break;
    212 214   }
    skipped 22 lines
    235 237   switch (type) {
    236 238   case Relocation::TYPE::PPC_RELATIVE:
    237 239   {
    238  - LIEF_DEBUG("Patch addend of {}", relocation);
     240 + LIEF_DEBUG("Patch addend of {}", to_string(relocation));
    239 241   patch_addend<uint32_t>(relocation, from, shift);
    240 242   break;
    241 243   }
    skipped 36 lines
    278 280   }
    279 281   
    280 282   if (relative_offset >= segment_size || (relative_offset + sizeof(T)) > segment_size) {
    281  - LIEF_DEBUG("Offset out of bound for relocation: {}", relocation);
     283 + LIEF_DEBUG("Offset out of bound for relocation: {}", to_string(relocation));
    282 284   return;
    283 285   }
    284 286   
    skipped 369 lines
  • ■ ■ ■ ■
    src/ELF/ExeLayout.hpp
    skipped 356 lines
    357 357   std::vector<uint32_t> hash_values(dynamic_symbols.size() - symndx, 0);
    358 358   
    359 359   for (size_t i = symndx; i < dynamic_symbols.size(); ++i) {
    360  - LIEF_DEBUG("Dealing with symbol {}", dynamic_symbols[i]);
     360 + LIEF_DEBUG("Dealing with symbol {}", to_string(dynamic_symbols[i]));
    361 361   const uint32_t hash = dl_new_hash(dynamic_symbols[i].name().c_str());
    362 362   int bucket = hash % nb_buckets;
    363 363   
    skipped 1022 lines
  • ■ ■ ■ ■ ■
    src/ELF/Parser.tcc
    skipped 46 lines
    47 47  #include "ELF/SizingInfo.hpp"
    48 48   
    49 49  #include "Object.tcc"
     50 +#include "internal_utils.hpp"
    50 51   
    51 52  namespace LIEF {
    52 53  namespace ELF {
    skipped 911 lines
    964 965   if (idx < binary_->dynamic_symbols_.size()) {
    965 966   reloc->symbol_ = binary_->dynamic_symbols_[idx].get();
    966 967   } else {
    967  - LIEF_WARN("Unable to find the symbol associated with the relocation (idx: {}) {}", idx, *reloc);
     968 + LIEF_WARN("Unable to find the symbol associated with the relocation "
     969 + "(idx: {}) {}", idx, to_string(*reloc));
    968 970   }
    969 971   }
    970 972   
    skipped 724 lines
  • ■ ■ ■ ■ ■ ■
    src/MachO/Binary.cpp
    skipped 62 lines
    63 63  #include "LIEF/MachO/VersionMin.hpp"
    64 64  #include "MachO/Structures.hpp"
    65 65   
     66 +#include "internal_utils.hpp"
     67 + 
    66 68  namespace LIEF {
    67 69  namespace MachO {
    68 70   
    skipped 1079 lines
    1148 1150   });
    1149 1151   
    1150 1152   if (it == std::end(commands_)) {
    1151  - LIEF_ERR("Unable to find command: {}", command);
     1153 + LIEF_ERR("Unable to find command: {}", to_string(command));
    1152 1154   return false;
    1153 1155   }
    1154 1156   
    skipped 94 lines
    1249 1251   });
    1250 1252   
    1251 1253   if (it == std::end(commands_)) {
    1252  - LIEF_ERR("Unable to find command: {}", command);
     1254 + LIEF_ERR("Unable to find command: {}", to_string(command));
    1253 1255   return false;
    1254 1256   }
    1255 1257   
    skipped 1364 lines
  • ■ ■ ■ ■ ■
    src/MachO/Binary.tcc
    skipped 18 lines
    19 19  #include "LIEF/MachO/SegmentCommand.hpp"
    20 20  #include "LIEF/MachO/Relocation.hpp"
    21 21  #include "LIEF/errors.hpp"
     22 +#include "internal_utils.hpp"
    22 23   
    23 24  namespace LIEF {
    24 25  namespace MachO {
    skipped 79 lines
    104 105   }
    105 106   
    106 107   if (relative_offset >= segment_size || (relative_offset + sizeof(T)) >= segment_size) {
    107  - LIEF_DEBUG("Offset out of bound for relocation: {}", relocation);
     108 + LIEF_DEBUG("Offset out of bound for relocation: {}", to_string(relocation));
    108 109   return make_error_code(lief_errors::read_out_of_bound);
    109 110   }
    110 111   
    skipped 11 lines
  • ■ ■ ■ ■
    src/MachO/Builder.tcc
    skipped 172 lines
    173 173   const Section& section = sections[i];
    174 174   const std::string& sec_name = section.name();
    175 175   const std::string& segment_name = segment.name();
    176  - LIEF_DEBUG("{}", section);
     176 + LIEF_DEBUG("{}", to_string(section));
    177 177   section_t header;
    178 178   std::memset(&header, 0, sizeof(header));
    179 179   
    skipped 1314 lines
  • ■ ■ ■ ■ ■
    src/PE/ResourceNode.cpp
    skipped 25 lines
    26 26  #include "LIEF/PE/ResourceDirectory.hpp"
    27 27  #include "LIEF/PE/ResourceData.hpp"
    28 28   
     29 +#include "internal_utils.hpp"
     30 + 
    29 31  namespace LIEF {
    30 32  namespace PE {
    31 33   
    skipped 141 lines
    173 175   });
    174 176   
    175 177   if (it_node == std::end(childs_)) {
    176  - LIEF_ERR("Unable to find the node {}", node);
     178 + LIEF_ERR("Unable to find the node {}", to_string(node));
    177 179   return;
    178 180   }
    179 181   
    skipped 79 lines
  • ■ ■ ■ ■ ■ ■
    src/PE/ResourcesManager.cpp
    skipped 654 lines
    655 655   }
    656 656   
    657 657   if (auto version = rsrc.version()) {
    658  - os << fmt::format("Version:\n{}\n", *version);
     658 + os << fmt::format("Version:\n{}\n", to_string(*version));
    659 659   }
    660 660   
    661 661   const auto& icons = rsrc.icons();
    662 662   for (size_t i = 0; i < icons.size(); ++i) {
    663  - os << fmt::format("Icon #{:02d}:\n{}\n", i, icons[i]);
     663 + os << fmt::format("Icon #{:02d}:\n{}\n", i, to_string(icons[i]));
    664 664   }
    665 665   
    666 666   const auto& dialogs = rsrc.dialogs();
    667 667   for (size_t i = 0; i < dialogs.size(); ++i) {
    668  - os << fmt::format("Dialog #{:02d}:\n{}\n", i, dialogs[i]);
     668 + os << fmt::format("Dialog #{:02d}:\n{}\n", i, to_string(dialogs[i]));
    669 669   }
    670 670   
    671 671   const auto& str_table = rsrc.string_table();
    672 672   for (size_t i = 0; i < str_table.size(); ++i) {
    673  - os << fmt::format("StringTable[{}]: {}", i, str_table[i]);
     673 + os << fmt::format("StringTable[{}]: {}", i, to_string(str_table[i]));
    674 674   }
    675 675   return os;
    676 676  }
    skipped 39 lines
  • ■ ■ ■ ■ ■
    src/PE/utils.cpp
    skipped 34 lines
    35 35  #include "utils/ordinals_lookup_tables_std/libraries_table.hpp"
    36 36   
    37 37  #include "hash_stream.hpp"
     38 +#include "internal_utils.hpp"
    38 39   
    39 40  namespace LIEF {
    40 41  namespace PE {
    skipped 298 lines
    339 340   Import resolved_import = import;
    340 341   for (ImportEntry& entry : resolved_import.entries()) {
    341 342   if (entry.is_ordinal()) {
    342  - LIEF_DEBUG("Dealing with: {}", entry);
     343 + LIEF_DEBUG("Dealing with: {}", to_string(entry));
    343 344   const char* entry_name = ordinal_resolver(static_cast<uint32_t>(entry.ordinal()));
    344 345   if (entry_name == nullptr) {
    345 346   if (strict) {
    skipped 50 lines
  • ■ ■ ■ ■ ■
    src/fmt_formatter.hpp
    skipped 16 lines
    17 17  #define LIEF_FMT_FORMATTER
    18 18  #include <spdlog/fmt/fmt.h>
    19 19  #include <spdlog/fmt/ranges.h>
    20  -#include <spdlog/fmt/ostr.h>
    21 20   
    22 21  #define FMT_FORMATTER(T, F) \
    23 22  template <typename Char> struct fmt::formatter<T, Char> { \
    skipped 16 lines
  • ■ ■ ■ ■ ■ ■
    src/internal_utils.hpp
    skipped 19 lines
    20 20  #include <set>
    21 21  #include <algorithm>
    22 22  #include <unordered_map>
     23 +#include <sstream>
    23 24  #include "spdlog/fmt/fmt.h"
    24 25   
    25 26  #include "LIEF/span.hpp"
    skipped 17 lines
    43 44  inline const char* to_string_or(result<T> res, const char* defval = "???") {
    44 45   return res ? to_string(*res) : defval;
    45 46  }
     47 + 
     48 +template<class T>
     49 +inline std::string to_string(const T& obj) {
     50 + std::stringstream oss;
     51 + oss << obj;
     52 + return oss.str();
     53 +}
     54 + 
    46 55   
    47 56  template<class T>
    48 57  inline std::string to_hex(const T& container, size_t maxsize = 0) {
    skipped 112 lines
  • ■ ■ ■ ■ ■
    src/logging.hpp
    skipped 20 lines
    21 21  #include "LIEF/config.h"
    22 22   
    23 23  #include <spdlog/spdlog.h>
    24  -#include <spdlog/fmt/ostr.h>
    25 24  #include <spdlog/fmt/fmt.h>
    26 25   
    27 26  #define LIEF_TRACE(...) LIEF::logging::Logger::trace(__VA_ARGS__)
    skipped 98 lines
Please wait...
Page is in error, reload to recover