dnl $NetBSD: elfdefinitions.m4,v 1.7 2025/02/10 15:54:16 jkoshy Exp $
/*-
* Copyright (c) 2010,2021,2024 Joseph Koshy
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
divert(-1)
define(`VCSID_ELFDEFINITIONS_M4',
`Id: elfdefinitions.m4 4162 2025-02-04 18:52:12Z jkoshy')
include(`elfconstants.m4')dnl
# Compute the whitespace between a symbol and its definition.
#
# - If the symbol is 7 characters or shorter in width, use two tabs.
# - Otherwise, if the symbol is 15 characters or less in width, use one tab.
# - Otherwise, use a single space.
#
# This makes the generated definitions easier to read.
define(`_WHITESPACE',
`ifelse(eval(len($1) <= 7),1,` ',
eval(len($1) <= 15),1,` ',
` ')')
# Format symbol descriptions as C-style comment.
define(`_DESCRIPTION',
`ifelse(eval(len(`$*') > 0),1,` /* $* */',
`')')
# Expand the `_' macro to a C preprocessor definition that is suitably
# vertically aligned. If a symbol description is present, add it as a
# C-style comment.
define(`_',``#'define $1`'_WHITESPACE($1)`'$2`'_DESCRIPTION(`$3')')
# Expand the `__' macro to a C-style comment.
#
# - An empty invocation __()) is ignored.
# - An invocation with a single argument __(COMMENT) is expanded as an inline
# C-style comment.
# - An invocation with two or more arguments __(PREFIX, COMMENT) expands to
# `PREFIX/* COMMENT */'. This form would be used to visually indent the
# comment in the generated output.
undefine(`__')
define(`__',
`ifelse($#, 0, `',
$#, 1, `/* $1 */',
`$1/* shift($*) */')')
divert(0)dnl
/*
* WARNING: GENERATED FILE. DO NOT MODIFY.
*
* GENERATED FROM: VCSID_ELFDEFINITIONS_M4
* GENERATED FROM: VCSID_ELFCONSTANTS_M4
*/
/* Aliases for dynamic linking entry symbols. */
DEFINE_DYN_TYPE_ALIASES()
/*
* Flags used in the executable header (field: e_flags).
*/
DEFINE_EHDR_FLAGS()
/*
* Offsets in the `ei_ident[]' field of an ELF executable header.
*/
DEFINE_EI_OFFSETS()
/*
* The ELF class of an object.
*/
DEFINE_ELF_CLASSES()
/*
* Endianness of data in an ELF object.
*/
DEFINE_ELF_DATA_ENDIANNESSES()
/*
* The magic numbers used in the initial four bytes of an ELF object.
*
* These numbers are: 0x7F, 'E', 'L' and 'F'.
*/
DEFINE_ELF_MAGIC_VALUES()
/* Additional magic-related constants. */
DEFINE_ELF_MAGIC_ADDITIONAL_CONSTANTS()
/* 32 bit SHDR */
typedef struct {
Elf32_Word sh_name; /* index of section name */
Elf32_Word sh_type; /* section type */
Elf32_Word sh_flags; /* section flags */
Elf32_Addr sh_addr; /* in-memory address of section */
Elf32_Off sh_offset; /* file offset of section */
Elf32_Word sh_size; /* section size in bytes */
Elf32_Word sh_link; /* section header table link */
Elf32_Word sh_info; /* extra information */
Elf32_Word sh_addralign; /* alignment constraint */
Elf32_Word sh_entsize; /* size for fixed-size entries */
} Elf32_Shdr;
/* 64 bit SHDR */
typedef struct {
Elf64_Word sh_name; /* index of section name */
Elf64_Word sh_type; /* section type */
Elf64_Xword sh_flags; /* section flags */
Elf64_Addr sh_addr; /* in-memory address of section */
Elf64_Off sh_offset; /* file offset of section */
Elf64_Xword sh_size; /* section size in bytes */
Elf64_Word sh_link; /* section header table link */
Elf64_Word sh_info; /* extra information */
Elf64_Xword sh_addralign; /* alignment constraint */
Elf64_Xword sh_entsize; /* size for fixed-size entries */
} Elf64_Shdr;
/*
* Symbol table entries.
*/
typedef struct {
Elf32_Word st_name; /* index of symbol's name */
Elf32_Addr st_value; /* value for the symbol */
Elf32_Word st_size; /* size of associated data */
unsigned char st_info; /* type and binding attributes */
unsigned char st_other; /* visibility */
Elf32_Half st_shndx; /* index of related section */
} Elf32_Sym;
typedef struct {
Elf64_Word st_name; /* index of symbol's name */
unsigned char st_info; /* type and binding attributes */
unsigned char st_other; /* visibility */
Elf64_Half st_shndx; /* index of related section */
Elf64_Addr st_value; /* value for the symbol */
Elf64_Xword st_size; /* size of associated data */
} Elf64_Sym;
/* 32-bit structures. */
typedef struct
{
Elf32_Word vda_name; /* Index to name. */
Elf32_Word vda_next; /* Offset to next entry. */
} Elf32_Verdaux;
typedef struct
{
Elf32_Word vna_hash; /* Hash value of dependency name. */
Elf32_Half vna_flags; /* Flags. */
Elf32_Half vna_other; /* Unused. */
Elf32_Word vna_name; /* Offset to dependency name. */
Elf32_Word vna_next; /* Offset to next vernaux entry. */
} Elf32_Vernaux;
typedef struct
{
Elf32_Half vd_version; /* Version information. */
Elf32_Half vd_flags; /* Flags. */
Elf32_Half vd_ndx; /* Index into the versym section. */
Elf32_Half vd_cnt; /* Number of aux entries. */
Elf32_Word vd_hash; /* Hash value of name. */
Elf32_Word vd_aux; /* Offset to aux entries. */
Elf32_Word vd_next; /* Offset to next version definition. */
} Elf32_Verdef;
typedef struct
{
Elf32_Half vn_version; /* Version number. */
Elf32_Half vn_cnt; /* Number of aux entries. */
Elf32_Word vn_file; /* Offset of associated file name. */
Elf32_Word vn_aux; /* Offset of vernaux array. */
Elf32_Word vn_next; /* Offset of next verneed entry. */
} Elf32_Verneed;
typedef Elf32_Half Elf32_Versym;
/* 64-bit structures. */
typedef struct {
Elf64_Word vda_name; /* Index to name. */
Elf64_Word vda_next; /* Offset to next entry. */
} Elf64_Verdaux;
typedef struct {
Elf64_Word vna_hash; /* Hash value of dependency name. */
Elf64_Half vna_flags; /* Flags. */
Elf64_Half vna_other; /* Unused. */
Elf64_Word vna_name; /* Offset to dependency name. */
Elf64_Word vna_next; /* Offset to next vernaux entry. */
} Elf64_Vernaux;
typedef struct {
Elf64_Half vd_version; /* Version information. */
Elf64_Half vd_flags; /* Flags. */
Elf64_Half vd_ndx; /* Index into the versym section. */
Elf64_Half vd_cnt; /* Number of aux entries. */
Elf64_Word vd_hash; /* Hash value of name. */
Elf64_Word vd_aux; /* Offset to aux entries. */
Elf64_Word vd_next; /* Offset to next version definition. */
} Elf64_Verdef;
typedef struct {
Elf64_Half vn_version; /* Version number. */
Elf64_Half vn_cnt; /* Number of aux entries. */
Elf64_Word vn_file; /* Offset of associated file name. */
Elf64_Word vn_aux; /* Offset of vernaux array. */
Elf64_Word vn_next; /* Offset of next verneed entry. */
} Elf64_Verneed;
typedef Elf64_Half Elf64_Versym;
/*
* The header for GNU-style hash sections.
*/
typedef struct {
uint32_t gh_nbuckets; /* Number of hash buckets. */
uint32_t gh_symndx; /* First visible symbol in .dynsym. */
uint32_t gh_maskwords; /* #maskwords used in bloom filter. */
uint32_t gh_shift2; /* Bloom filter `shift' count. */
} Elf_GNU_Hash_Header;