154N/A/*
154N/A * CDDL HEADER START
154N/A *
154N/A * The contents of this file are subject to the terms of the
154N/A * Common Development and Distribution License (the "License").
154N/A * You may not use this file except in compliance with the License.
154N/A *
154N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
154N/A * or http://www.opensolaris.org/os/licensing.
154N/A * See the License for the specific language governing permissions
154N/A * and limitations under the License.
154N/A *
154N/A * When distributing Covered Code, include this CDDL HEADER in each
154N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
154N/A * If applicable, add the following below this CDDL HEADER, with the
154N/A * fields enclosed by brackets "[]" replaced with your own identifying
154N/A * information: Portions Copyright [yyyy] [name of copyright owner]
154N/A *
154N/A * CDDL HEADER END
154N/A */
533N/A
154N/A/*
3402N/A * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
154N/A */
154N/A
155N/A#ifndef _ELFEXTRACT_H
155N/A#define _ELFEXTRACT_H
61N/A
61N/A#include <sys/types.h>
155N/A#include <liblist.h>
533N/A#include <Python.h>
155N/A
155N/A#ifdef __cplusplus
155N/Aextern "C" {
155N/A#endif
61N/A
61N/A#ifndef MIN
155N/A#define MIN(a, b) ((a) < (b) ? (a) : (b))
61N/A#endif
61N/A
61N/Atypedef struct dyninfo {
155N/A off_t runpath; /* offset in table of the runpath */
155N/A off_t def; /* offset in table of the vdefname */
155N/A off_t dynstr; /* string table */
155N/A liblist_t *deps; /* dependency list (also contains */
155N/A /* offsets) */
155N/A liblist_t *vers; /* version provided list (also */
155N/A /* contains offsets) */
3236N/A Elf *elf; /* elf data -- must be freed */
3236N/A} dyninfo_t;
3236N/A
3236N/Atypedef struct hashinfo {
3402N/A /* Legacy SHA1 hash of subset of sections */
3402N/A char elfhash[41];
3402N/A
3402N/A /*
3402N/A * SHA-256 hash of data extracted via
3402N/A * gelf_sign_range(ELF_SR_SIGNED_INTERPRET)
3402N/A */
3402N/A char hash_sha256[77];
3402N/A
3402N/A /*
3402N/A * SHA-256 hash of data extracted via
3402N/A * gelf_sign_range(ELF_SR_INTERPRET)
3402N/A */
3402N/A char uhash_sha256[86];
3402N/A
3402N/A /*
3402N/A * SHA-512/256 hash of data extracted via
3402N/A * gelf_sign_range(ELF_SR_SIGNED_INTERPRET)
3402N/A */
3402N/A char hash_sha512t_256[82];
3402N/A
3402N/A /*
3402N/A * SHA-512/256 hash of data extracted via
3402N/A * gelf_sign_range(ELF_SR_INTERPRET)
3402N/A */
3402N/A char uhash_sha512t_256[91];
3236N/A} hashinfo_t;
61N/A
62N/Atypedef struct hdrinfo {
62N/A int type; /* e_type */
62N/A int bits; /* 32/64 */
62N/A int arch; /* e_machine */
62N/A int data; /* e_ident[EI_DATA] */
62N/A int osabi; /* e_ident[EI_OSABI] */
62N/A} hdrinfo_t;
62N/A
154N/Aextern int iself(int fd);
154N/Aextern int iself32(int fd);
3236N/Aextern dyninfo_t *getdynamic(int fd);
3402N/Aextern hashinfo_t *gethashes(int fd, int elfhash, int sha2_256, int sha2_512);
154N/Aextern void dyninfo_free(dyninfo_t *dyn);
154N/Aextern hdrinfo_t *getheaderinfo(int fd);
62N/A
154N/Aextern char *pkg_string_from_type(int type);
154N/Aextern char *pkg_string_from_arch(int arch);
154N/Aextern char *pkg_string_from_data(int data);
154N/Aextern char *pkg_string_from_osabi(int osabi);
61N/A
533N/APyObject *ElfError;
533N/A
155N/A#ifdef __cplusplus
155N/A}
61N/A#endif
155N/A
155N/A#endif /* _ELFEXTRACT_H */