Merge topic 'file-rpath-elf-static'

02f3e5be6a file(RPATH_CHANGE ...): no-op for static binary
ccbbf64552 Tests/RunCMake/file-RPATH: Prepare to cover statically linked binaries

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !9623
This commit is contained in:
Brad King
2024-06-26 12:46:10 +00:00
committed by Kitware Robot
7 changed files with 35 additions and 8 deletions
+9 -1
View File
@@ -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()) {
+3
View File
@@ -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();
+4
View File
@@ -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 };