2017-03-30 16:56:49 +02:00
|
|
|
/* Copyright 2017 R. Thomas
|
|
|
|
* Copyright 2017 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 PY_LIEF_ELF_H_
|
|
|
|
#define PY_LIEF_ELF_H_
|
|
|
|
|
2019-04-18 07:15:31 +02:00
|
|
|
#include <pybind11/pybind11.h>
|
|
|
|
#include <pybind11/stl_bind.h>
|
|
|
|
|
2017-03-30 16:56:49 +02:00
|
|
|
#include "LIEF/ELF/Parser.hpp"
|
|
|
|
#include "LIEF/ELF/Binary.hpp"
|
|
|
|
#include "LIEF/ELF/Builder.hpp"
|
|
|
|
|
|
|
|
#include "pyLIEF.hpp"
|
2018-06-08 10:48:29 +02:00
|
|
|
|
|
|
|
|
|
|
|
#define SPECIALIZE_CREATE(X) \
|
|
|
|
template<> \
|
|
|
|
void create<X>(py::module&)
|
|
|
|
|
|
|
|
#define CREATE(X,Y) create<X>(Y)
|
|
|
|
|
|
|
|
|
|
|
|
namespace LIEF {
|
|
|
|
namespace ELF {
|
|
|
|
|
|
|
|
template<class T>
|
|
|
|
void create(py::module&);
|
|
|
|
|
|
|
|
void init_python_module(py::module& m);
|
|
|
|
void init_objects(py::module&);
|
|
|
|
void init_enums(py::module&);
|
2017-03-30 16:56:49 +02:00
|
|
|
|
Improve the ELF part of LIEF
Major changes (features):
* Enable adding multiple sections/segments - Executable (PIE or not), Library
* Enable adding multiple dynamic entries (DT_NEEDED, DT_INIT etc)
* Enable adding multiple relocations
* Enable adding multiple dynamic symbols
* Enable segment replacement
Major changes (API):
* Getters Binary::get_*name*() has been renamed to "name()"
* Binary::add(const DynamicEntry& entry) - To add an entry in the dynamic table
* Section& Binary::add(const Section& section, bool loaded = true) - To add a section(s)
* Segment& Binary::add(const Segment& segment, uint64_t base = 0) - To add segments
* Segment& replace(const Segment& new_segment, const Segment& original_segment, uint64_t base = 0)
* Binary's last_offset_section(), last_offset_segment(), next_virtual_address()
to have information about offset
* Binary's add_library(), get_library(), has_library() to handle
DT_NEEDED entries
Other changes:
* Binary::insert_content() - Use add(const Section&) or add(const Segment&) instead
* ELF's DataHandler has been cleaned
* Through LIEF::Section one can look for integers, strings, data
within the section (see LIEF::Section::search,
LIEF::Section::search_all)
* Through LIEF::Binary one can get *xref* of a number (or address)
see LIEF::Binary::xref function
* To access to the Abstract binary in Python, one can now use
the 'abstract' attribute. (e.g. binary.abstract.header.is_32)
Resolve: #83
Resolve: #66
Resolve: #48
2017-09-02 08:54:54 +02:00
|
|
|
void init_ELF32_sizes(py::module&);
|
|
|
|
void init_ELF64_sizes(py::module&);
|
|
|
|
|
2018-06-08 10:48:29 +02:00
|
|
|
SPECIALIZE_CREATE(Parser);
|
|
|
|
SPECIALIZE_CREATE(Binary);
|
|
|
|
SPECIALIZE_CREATE(Header);
|
|
|
|
SPECIALIZE_CREATE(Section);
|
|
|
|
SPECIALIZE_CREATE(Segment);
|
|
|
|
SPECIALIZE_CREATE(Symbol);
|
|
|
|
SPECIALIZE_CREATE(Relocation);
|
|
|
|
SPECIALIZE_CREATE(SymbolVersion);
|
|
|
|
SPECIALIZE_CREATE(SymbolVersionAux);
|
|
|
|
SPECIALIZE_CREATE(SymbolVersionRequirement);
|
|
|
|
SPECIALIZE_CREATE(SymbolVersionDefinition);
|
|
|
|
SPECIALIZE_CREATE(SymbolVersionAuxRequirement);
|
|
|
|
SPECIALIZE_CREATE(DynamicEntry);
|
|
|
|
SPECIALIZE_CREATE(DynamicEntryLibrary);
|
|
|
|
SPECIALIZE_CREATE(DynamicSharedObject);
|
|
|
|
SPECIALIZE_CREATE(DynamicEntryArray);
|
|
|
|
SPECIALIZE_CREATE(DynamicEntryRpath);
|
|
|
|
SPECIALIZE_CREATE(DynamicEntryRunPath);
|
|
|
|
SPECIALIZE_CREATE(DynamicEntryFlags);
|
|
|
|
SPECIALIZE_CREATE(GnuHash);
|
|
|
|
SPECIALIZE_CREATE(SysvHash);
|
|
|
|
SPECIALIZE_CREATE(Builder);
|
|
|
|
SPECIALIZE_CREATE(Note);
|
2019-04-18 07:15:31 +02:00
|
|
|
SPECIALIZE_CREATE(NoteDetails);
|
2018-06-08 10:48:29 +02:00
|
|
|
SPECIALIZE_CREATE(AndroidNote);
|
2019-04-18 07:15:31 +02:00
|
|
|
SPECIALIZE_CREATE(NoteAbi);
|
|
|
|
SPECIALIZE_CREATE(CorePrPsInfo);
|
|
|
|
SPECIALIZE_CREATE(CoreFile);
|
|
|
|
SPECIALIZE_CREATE(CoreFileEntry);
|
|
|
|
SPECIALIZE_CREATE(CorePrStatus);
|
|
|
|
SPECIALIZE_CREATE(CoreAuxv);
|
|
|
|
SPECIALIZE_CREATE(CoreSigInfo);
|
2018-06-08 10:48:29 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2017-03-30 16:56:49 +02:00
|
|
|
|
2019-04-18 07:15:31 +02:00
|
|
|
PYBIND11_MAKE_OPAQUE(LIEF::ELF::CoreFile::files_t);
|
2017-03-30 16:56:49 +02:00
|
|
|
|
|
|
|
#endif
|