summaryrefslogtreecommitdiff
path: root/Source/cmELF.cxx
diff options
context:
space:
mode:
authorAlex Richardson <Alexander.Richardson@cl.cam.ac.uk>2021-06-17 13:18:13 +0100
committerBrad King <brad.king@kitware.com>2021-06-24 10:57:51 -0400
commit0da1540aaa8d36145329572938aeec6c86fb1ee7 (patch)
treef3831b276a19a1c870af6420065f155df0d8cc22 /Source/cmELF.cxx
parente21188df8bd08a5f306afc09bcb829d148b982d5 (diff)
downloadcmake-0da1540aaa8d36145329572938aeec6c86fb1ee7.tar.gz
cmELF: Fix check for TagMipsRldMapRel
DT_MIPS_RLD_MAP_REL is a machine-speicific dynamic tag, so other architectures could re-use the value of 0x70000035 to mean something else. Before using DT_MIPS_RLD_MAP_REL, we have to check that the ELF file is actually has a e_machine of EM_MIPS.
Diffstat (limited to 'Source/cmELF.cxx')
-rw-r--r--Source/cmELF.cxx15
1 files changed, 15 insertions, 0 deletions
diff --git a/Source/cmELF.cxx b/Source/cmELF.cxx
index 01dc0b1d6e..d96644b5b1 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()) {