-
-
Notifications
You must be signed in to change notification settings - Fork 621
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for
GNU_PROPERTY_AARCH64_FEATURE_PAUTH
- Loading branch information
1 parent
086c49f
commit 27be4e6
Showing
19 changed files
with
250 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
api/python/src/ELF/objects/NoteDetails/properties/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
api/python/src/ELF/objects/NoteDetails/properties/pyAArch64PAuth.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* Copyright 2017 - 2024 R. Thomas | ||
* Copyright 2017 - 2024 Quarkslab | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
#include <string> | ||
#include <sstream> | ||
|
||
#include "ELF/pyELF.hpp" | ||
|
||
#include "LIEF/ELF/NoteDetails/properties/AArch64PAuth.hpp" | ||
|
||
namespace LIEF::ELF::py { | ||
|
||
template<> | ||
void create<AArch64PAuth>(nb::module_& m) { | ||
nb::class_<AArch64PAuth, NoteGnuProperty::Property> | ||
Class(m, "AArch64PAuth", | ||
R"doc( | ||
This class represents the ``GNU_PROPERTY_AARCH64_FEATURE_PAUTH`` note. | ||
.. note:: | ||
If both: :attr:`.AArch64PAuth.platform` and :attr:`.AArch64PAuth.version` are set to | ||
0, this means that the binary is incompatible with PAuth ABI extension. | ||
)doc"_doc); | ||
|
||
Class | ||
.def_prop_ro("platform", &AArch64PAuth::platform, | ||
R"doc( | ||
64-bit value that specifies the platform vendor. | ||
A ``0`` value is associated with an *invalid* platform while the value ``1`` | ||
is associated with a baremetal platform. | ||
)doc"_doc) | ||
|
||
.def_prop_ro("version", &AArch64PAuth::version, | ||
R"doc( | ||
64-bit value that identifies the signing schema used by the ELF file. | ||
)doc"_doc) | ||
; | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* Copyright 2017 - 2024 R. Thomas | ||
* Copyright 2017 - 2024 Quarkslab | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
#ifndef LIEF_ELF_NOTE_DETAILS_PROPERTIES_AARCH64_PAUTH_H | ||
#define LIEF_ELF_NOTE_DETAILS_PROPERTIES_AARCH64_PAUTH_H | ||
|
||
#include "LIEF/visibility.h" | ||
#include "LIEF/ELF/NoteDetails/NoteGnuProperty.hpp" | ||
|
||
namespace LIEF { | ||
class BinaryStream; | ||
|
||
namespace ELF { | ||
|
||
|
||
/// This class represents the `GNU_PROPERTY_AARCH64_FEATURE_PAUTH` property. | ||
/// | ||
/// \note If both: AArch64PAuth::platform and AArch64PAuth::version are set to | ||
/// 0, this means that the binary is incompatible with PAuth ABI extension. | ||
class LIEF_API AArch64PAuth : public NoteGnuProperty::Property { | ||
public: | ||
/// 64-bit value that specifies the platform vendor. | ||
/// | ||
/// A `0` value is associated with an *invalid* platform while the value `1` | ||
/// is associated with a baremetal platform. | ||
uint64_t platform() const { | ||
return platform_; | ||
} | ||
|
||
/// 64-bit value that identifies the signing schema used by the ELF file. | ||
uint64_t version() const { | ||
return version_; | ||
} | ||
|
||
static bool classof(const NoteGnuProperty::Property* prop) { | ||
return prop->type() == NoteGnuProperty::Property::TYPE::AARCH64_PAUTH; | ||
} | ||
|
||
static std::unique_ptr<AArch64PAuth> create(BinaryStream& stream); | ||
|
||
void dump(std::ostream &os) const override; | ||
|
||
~AArch64PAuth() override = default; | ||
|
||
protected: | ||
AArch64PAuth() : | ||
NoteGnuProperty::Property(NoteGnuProperty::Property::TYPE::AARCH64_PAUTH) | ||
{} | ||
|
||
AArch64PAuth(uint64_t platform, uint64_t version) : | ||
NoteGnuProperty::Property(NoteGnuProperty::Property::TYPE::AARCH64_PAUTH), | ||
platform_(platform), | ||
version_(version) | ||
{} | ||
|
||
uint64_t platform_ = 0; | ||
uint64_t version_ = 0; | ||
}; | ||
|
||
} | ||
} | ||
|
||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* Copyright 2017 - 2024 R. Thomas | ||
* Copyright 2017 - 2024 Quarkslab | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
#include "LIEF/ELF/NoteDetails/properties/AArch64PAuth.hpp" | ||
#include "LIEF/BinaryStream/BinaryStream.hpp" | ||
|
||
#include "frozen.hpp" | ||
#include "fmt_formatter.hpp" | ||
|
||
namespace LIEF { | ||
namespace ELF { | ||
|
||
std::unique_ptr<AArch64PAuth> AArch64PAuth::create(BinaryStream& stream) { | ||
uint64_t platform = stream.read<uint64_t>().value_or(0); | ||
uint64_t version = stream.read<uint64_t>().value_or(0); | ||
|
||
return std::unique_ptr<AArch64PAuth>(new AArch64PAuth(platform, version)); | ||
} | ||
|
||
void AArch64PAuth::dump(std::ostream &os) const { | ||
os << fmt::format("Platform: 0x{:04x}, Version: 0x{:04x}", | ||
platform(), version()); | ||
} | ||
|
||
|
||
} | ||
} |
Oops, something went wrong.