summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/cmELF.cxx15
-rw-r--r--Source/cmELF.h3
-rw-r--r--Source/cmSystemTools.cxx3
3 files changed, 19 insertions, 2 deletions
diff --git a/Source/cmELF.cxx b/Source/cmELF.cxx
index 01dc0b1..d96644b 100644
--- a/Source/cmELF.cxx
+++ b/Source/cmELF.cxx
@@ -145,6 +145,7 @@ public:
virtual std::vector<char> EncodeDynamicEntries(
const cmELF::DynamicEntryList&) = 0;
virtual StringEntry const* GetDynamicSectionString(unsigned int tag) = 0;
+ virtual bool IsMips() const = 0;
virtual void PrintInfo(std::ostream& os) const = 0;
// Lookup the SONAME in the DYNAMIC section.
@@ -256,6 +257,12 @@ public:
// Lookup a string from the dynamic section with the given tag.
StringEntry const* GetDynamicSectionString(unsigned int tag) override;
+#ifdef EM_MIPS
+ bool IsMips() const override { return this->ELFHeader.e_machine == EM_MIPS; }
+#else
+ bool IsMips() const override { false; }
+#endif
+
// Print information about the ELF file.
void PrintInfo(std::ostream& os) const override
{
@@ -830,6 +837,14 @@ cmELF::StringEntry const* cmELF::GetRunPath()
return nullptr;
}
+bool cmELF::IsMIPS() const
+{
+ if (this->Valid()) {
+ return this->Internal->IsMips();
+ }
+ return false;
+}
+
void cmELF::PrintInfo(std::ostream& os) const
{
if (this->Valid()) {
diff --git a/Source/cmELF.h b/Source/cmELF.h
index c479e2b..5700a38 100644
--- a/Source/cmELF.h
+++ b/Source/cmELF.h
@@ -98,6 +98,9 @@ public:
/** Get the RUNPATH field if any. */
StringEntry const* GetRunPath();
+ /** Returns true if the ELF file targets a MIPS CPU. */
+ bool IsMIPS() const;
+
/** Print human-readable information about the ELF file. */
void PrintInfo(std::ostream& os) const;
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 488e69c..d6b8208 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -3102,8 +3102,7 @@ static cm::optional<bool> RemoveRPathELF(std::string const& file,
entriesErased++;
continue;
}
- if (cmELF::TagMipsRldMapRel != 0 &&
- it->first == cmELF::TagMipsRldMapRel) {
+ if (it->first == cmELF::TagMipsRldMapRel && elf.IsMIPS()) {
// Background: debuggers need to know the "linker map" which contains
// the addresses each dynamic object is loaded at. Most arches use
// the DT_DEBUG tag which the dynamic linker writes to (directly) and