diff options
-rw-r--r-- | Source/cmELF.cxx | 10 | ||||
-rw-r--r-- | Source/cmELF.h | 3 | ||||
-rw-r--r-- | Source/cmSystemTools.cxx | 4 | ||||
-rw-r--r-- | Tests/RunCMake/file-RPATH/ELF.cmake | 3 | ||||
-rwxr-xr-x | Tests/RunCMake/file-RPATH/ELF/elf64lsb-static.bin | bin | 0 -> 4320 bytes |
5 files changed, 19 insertions, 1 deletions
diff --git a/Source/cmELF.cxx b/Source/cmELF.cxx index a71e5f1..003f47b 100644 --- a/Source/cmELF.cxx +++ b/Source/cmELF.cxx @@ -112,6 +112,9 @@ public: virtual bool IsMips() const = 0; virtual void PrintInfo(std::ostream& os) const = 0; + /** Returns true if the ELF file has a dynamic section **/ + bool HasDynamicSection() const { return this->DynamicSectionIndex >= 0; } + // Lookup the SONAME in the DYNAMIC section. StringEntry const* GetSOName() { @@ -461,7 +464,7 @@ template <class Types> bool cmELFInternalImpl<Types>::LoadDynamicSection() { // If there is no dynamic section we are done. - if (this->DynamicSectionIndex < 0) { + if (!this->HasDynamicSection()) { return false; } @@ -772,6 +775,11 @@ std::vector<char> cmELF::EncodeDynamicEntries( return std::vector<char>(); } +bool cmELF::HasDynamicSection() const +{ + return this->Valid() && this->Internal->HasDynamicSection(); +} + bool cmELF::GetSOName(std::string& soname) { if (StringEntry const* se = this->GetSOName()) { diff --git a/Source/cmELF.h b/Source/cmELF.h index ce8bd7f..dd37c65 100644 --- a/Source/cmELF.h +++ b/Source/cmELF.h @@ -88,6 +88,9 @@ public: std::vector<char> EncodeDynamicEntries( const DynamicEntryList& entries) const; + /** Returns true if the ELF file has a dynamic section **/ + bool HasDynamicSection() const; + /** Get the SONAME field if any. */ bool GetSOName(std::string& soname); StringEntry const* GetSOName(); diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 093a18b..3affef0 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -2817,6 +2817,10 @@ cm::optional<bool> AdjustRPathELF(std::string const& file, return cm::nullopt; // Not a valid ELF file. } + if (!elf.HasDynamicSection()) { + return true; // No dynamic section to update. + } + // Get the RPATH and RUNPATH entries from it. int se_count = 0; cmELF::StringEntry const* se[2] = { nullptr, nullptr }; diff --git a/Tests/RunCMake/file-RPATH/ELF.cmake b/Tests/RunCMake/file-RPATH/ELF.cmake index 0f445e8..b8919ef 100644 --- a/Tests/RunCMake/file-RPATH/ELF.cmake +++ b/Tests/RunCMake/file-RPATH/ELF.cmake @@ -4,6 +4,9 @@ set(dynamic elf64lsb.bin elf64msb.bin ) +set(static + elf64lsb-static.bin + ) set(format ELF) include(${CMAKE_CURRENT_LIST_DIR}/Common.cmake) diff --git a/Tests/RunCMake/file-RPATH/ELF/elf64lsb-static.bin b/Tests/RunCMake/file-RPATH/ELF/elf64lsb-static.bin Binary files differnew file mode 100755 index 0000000..b48c4f3 --- /dev/null +++ b/Tests/RunCMake/file-RPATH/ELF/elf64lsb-static.bin |