Skip to content

Commit

Permalink
fix. backport compilation with llvm9 and earlier
Browse files Browse the repository at this point in the history
llvm::SectionRef changed the `getName` interface since LLVM10, in
particular, in commit llvm/llvm-project@a11d302fa0.

In llvm-9 and early version, `getName` required a StringRef reference as
a parameter, and returned a std::error_code.
  • Loading branch information
pagict committed Aug 6, 2023
1 parent ddf4961 commit ed948ac
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/cc/bpf_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,17 @@ class MyMemoryManager : public SectionMemoryManager {
if (!section)
continue;

#if LLVM_MAJOR_VERSION >= 10
auto sec_name = section.get()->getName();
if (!sec_name)
continue;
#else
llvm::StringRef sec_name_obj;
if (!section.get()->getName(sec_name_obj))
continue;

auto sec_name = &sec_name_obj;
#endif
info->section_ = sec_name->str();
info->size_ = ss.second;
}
Expand Down

0 comments on commit ed948ac

Please sign in to comment.