-
-
Notifications
You must be signed in to change notification settings - Fork 634
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 ELF
NT_GNU_PROPERTY_TYPE_0
(read-only)
See: `tests/elf/test_notes.py` for API usage Resolve: #975
- Loading branch information
1 parent
e6503fe
commit fac0e78
Showing
44 changed files
with
2,271 additions
and
74 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
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 |
---|---|---|
@@ -1,7 +1,9 @@ | ||
target_sources(pyLIEF PRIVATE | ||
pyAndroidIdent.cpp | ||
pyNoteAbi.cpp | ||
pyNoteGnuProperty.cpp | ||
) | ||
|
||
add_subdirectory(core) | ||
add_subdirectory(properties) | ||
|
8 changes: 8 additions & 0 deletions
8
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
target_sources(pyLIEF PRIVATE | ||
pyAArch64Feature.cpp | ||
pyGeneric.cpp | ||
pyNoteNoCopyOnProtected.cpp | ||
pyX86Features.cpp | ||
pyX86ISA.cpp | ||
pyStackSize.cpp | ||
) |
51 changes: 51 additions & 0 deletions
51
api/python/src/ELF/objects/NoteDetails/properties/pyAArch64Feature.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,51 @@ | ||
/* Copyright 2017 - 2023 R. Thomas | ||
* Copyright 2017 - 2023 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 <nanobind/stl/vector.h> | ||
|
||
#include "enums_wrapper.hpp" | ||
#include "ELF/pyELF.hpp" | ||
|
||
#include "LIEF/ELF/NoteDetails/properties/AArch64Feature.hpp" | ||
|
||
namespace LIEF::ELF::py { | ||
|
||
template<> | ||
void create<AArch64Feature>(nb::module_& m) { | ||
nb::class_<AArch64Feature, NoteGnuProperty::Property> | ||
Class(m, "AArch64Feature", | ||
R"doc( | ||
This class represents the `GNU_PROPERTY_AARCH64_FEATURE_1_AND` note. | ||
)doc"_doc); | ||
|
||
Class | ||
.def_prop_ro("features", &AArch64Feature::features, | ||
R"doc( | ||
Return the list of the supported features. | ||
)doc"_doc); | ||
|
||
# define ENTRY(X, D) .value(to_string(AArch64Feature::FEATURE::X), AArch64Feature::FEATURE::X, D) | ||
enum_<AArch64Feature::FEATURE>(Class, "FEATURE") | ||
ENTRY(UNKNOWN, "") | ||
ENTRY(BTI, "Support Branch Target Identification (BTI)") | ||
ENTRY(PAC, "Support Pointer authentication (PAC)") | ||
; | ||
# undef ENTRY | ||
} | ||
|
||
} |
36 changes: 36 additions & 0 deletions
36
api/python/src/ELF/objects/NoteDetails/properties/pyGeneric.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,36 @@ | ||
/* Copyright 2017 - 2023 R. Thomas | ||
* Copyright 2017 - 2023 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 "ELF/pyELF.hpp" | ||
|
||
#include "LIEF/ELF/NoteDetails/properties/Generic.hpp" | ||
|
||
namespace LIEF::ELF::py { | ||
|
||
template<> | ||
void create<Generic>(nb::module_& m) { | ||
nb::class_<Generic, NoteGnuProperty::Property>(m, "Generic", | ||
R"doc( | ||
This class represents a property which doesn't have a concrete LIEF implementation. | ||
)doc") | ||
.def_prop_ro("raw_type", &Generic::type, | ||
R"doc( | ||
The original raw type as an integer. This value might depends | ||
on the architecture and/or the file type. | ||
)doc"); | ||
|
||
} | ||
|
||
} |
35 changes: 35 additions & 0 deletions
35
api/python/src/ELF/objects/NoteDetails/properties/pyNoteNoCopyOnProtected.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,35 @@ | ||
/* Copyright 2017 - 2023 R. Thomas | ||
* Copyright 2017 - 2023 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 "ELF/pyELF.hpp" | ||
|
||
#include "LIEF/ELF/NoteDetails/properties/NoteNoCopyOnProtected.hpp" | ||
|
||
namespace LIEF::ELF::py { | ||
|
||
template<> | ||
void create<NoteNoCopyOnProtected>(nb::module_& m) { | ||
nb::class_<NoteNoCopyOnProtected, NoteGnuProperty::Property> Class( | ||
m, "NoteNoCopyOnProtected", | ||
R"doc( | ||
This class provides an interface over the `GNU_PROPERTY_NO_COPY_ON_PROTECTED` | ||
property. This property indicates that the linker shouldn't copy relocations | ||
against protected symbols. | ||
)doc"_doc | ||
); | ||
|
||
} | ||
|
||
} |
33 changes: 33 additions & 0 deletions
33
api/python/src/ELF/objects/NoteDetails/properties/pyStackSize.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,33 @@ | ||
/* Copyright 2017 - 2023 R. Thomas | ||
* Copyright 2017 - 2023 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 "ELF/pyELF.hpp" | ||
|
||
#include "LIEF/ELF/NoteDetails/properties/StackSize.hpp" | ||
|
||
namespace LIEF::ELF::py { | ||
|
||
template<> | ||
void create<StackSize>(nb::module_& m) { | ||
nb::class_<StackSize, NoteGnuProperty::Property>(m, "StackSize", | ||
R"doc( | ||
This class provides an interface over the `GNU_PROPERTY_STACK_SIZE` property | ||
This property can be used by the loader to raise the stack limit. | ||
)doc") | ||
.def_prop_ro("stack_size", &StackSize::stack_size); | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.