mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-10 07:40:03 -06:00
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.
This commit is contained in:
committed by
Brad King
parent
e21188df8b
commit
0da1540aaa
@@ -145,6 +145,7 @@ public:
|
|||||||
virtual std::vector<char> EncodeDynamicEntries(
|
virtual std::vector<char> EncodeDynamicEntries(
|
||||||
const cmELF::DynamicEntryList&) = 0;
|
const cmELF::DynamicEntryList&) = 0;
|
||||||
virtual StringEntry const* GetDynamicSectionString(unsigned int tag) = 0;
|
virtual StringEntry const* GetDynamicSectionString(unsigned int tag) = 0;
|
||||||
|
virtual bool IsMips() const = 0;
|
||||||
virtual void PrintInfo(std::ostream& os) const = 0;
|
virtual void PrintInfo(std::ostream& os) const = 0;
|
||||||
|
|
||||||
// Lookup the SONAME in the DYNAMIC section.
|
// Lookup the SONAME in the DYNAMIC section.
|
||||||
@@ -256,6 +257,12 @@ public:
|
|||||||
// Lookup a string from the dynamic section with the given tag.
|
// Lookup a string from the dynamic section with the given tag.
|
||||||
StringEntry const* GetDynamicSectionString(unsigned int tag) override;
|
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.
|
// Print information about the ELF file.
|
||||||
void PrintInfo(std::ostream& os) const override
|
void PrintInfo(std::ostream& os) const override
|
||||||
{
|
{
|
||||||
@@ -830,6 +837,14 @@ cmELF::StringEntry const* cmELF::GetRunPath()
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool cmELF::IsMIPS() const
|
||||||
|
{
|
||||||
|
if (this->Valid()) {
|
||||||
|
return this->Internal->IsMips();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void cmELF::PrintInfo(std::ostream& os) const
|
void cmELF::PrintInfo(std::ostream& os) const
|
||||||
{
|
{
|
||||||
if (this->Valid()) {
|
if (this->Valid()) {
|
||||||
|
|||||||
@@ -98,6 +98,9 @@ public:
|
|||||||
/** Get the RUNPATH field if any. */
|
/** Get the RUNPATH field if any. */
|
||||||
StringEntry const* GetRunPath();
|
StringEntry const* GetRunPath();
|
||||||
|
|
||||||
|
/** Returns true if the ELF file targets a MIPS CPU. */
|
||||||
|
bool IsMIPS() const;
|
||||||
|
|
||||||
/** Print human-readable information about the ELF file. */
|
/** Print human-readable information about the ELF file. */
|
||||||
void PrintInfo(std::ostream& os) const;
|
void PrintInfo(std::ostream& os) const;
|
||||||
|
|
||||||
|
|||||||
@@ -3102,8 +3102,7 @@ static cm::optional<bool> RemoveRPathELF(std::string const& file,
|
|||||||
entriesErased++;
|
entriesErased++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (cmELF::TagMipsRldMapRel != 0 &&
|
if (it->first == cmELF::TagMipsRldMapRel && elf.IsMIPS()) {
|
||||||
it->first == cmELF::TagMipsRldMapRel) {
|
|
||||||
// Background: debuggers need to know the "linker map" which contains
|
// Background: debuggers need to know the "linker map" which contains
|
||||||
// the addresses each dynamic object is loaded at. Most arches use
|
// the addresses each dynamic object is loaded at. Most arches use
|
||||||
// the DT_DEBUG tag which the dynamic linker writes to (directly) and
|
// the DT_DEBUG tag which the dynamic linker writes to (directly) and
|
||||||
|
|||||||
Reference in New Issue
Block a user