Skip to content

Commit

Permalink
fixup for 5054ff8
Browse files Browse the repository at this point in the history
  • Loading branch information
stikonas authored and ekaitz-zarraga committed Oct 29, 2023
1 parent c3b3d42 commit 233146f
Showing 1 changed file with 48 additions and 5 deletions.
53 changes: 48 additions & 5 deletions elf.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,17 @@
typedef signed char int8_t;
typedef short int int16_t;
typedef int int32_t;
#if HAVE_LONG_LONG
typedef long long int int64_t;
#endif
typedef unsigned char uint8_t;
typedef unsigned short int uint16_t;
typedef unsigned int uint32_t;
#if HAVE_LONG_LONG
typedef unsigned long long int uint64_t;
#endif
#endif
#endif

/* Standard ELF types. */

Expand All @@ -48,27 +52,35 @@ typedef int32_t Elf32_Sword;
typedef uint32_t Elf64_Word;
typedef int32_t Elf64_Sword;

#if HAVE_LONG_LONG
/* Types for signed and unsigned 64-bit quantities. */
typedef uint64_t Elf32_Xword;
typedef int64_t Elf32_Sxword;
typedef uint64_t Elf64_Xword;
typedef int64_t Elf64_Sxword;
#endif

/* Type of addresses. */
typedef uint32_t Elf32_Addr;
#if HAVE_LONG_LONG
typedef uint64_t Elf64_Addr;
#endif

/* Type of file offsets. */
typedef uint32_t Elf32_Off;
#if HAVE_LONG_LONG
typedef uint64_t Elf64_Off;
#endif

/* Type for section indices, which are 16-bit quantities. */
typedef uint16_t Elf32_Section;
typedef uint16_t Elf64_Section;

/* Type for version symbol information. */
typedef Elf32_Half Elf32_Versym;
#if HAVE_LONG_LONG
typedef Elf64_Half Elf64_Versym;
#endif


/* The ELF file header. This appears at the start of every ELF file. */
Expand All @@ -93,6 +105,7 @@ typedef struct
Elf32_Half e_shstrndx; /* Section header string table index */
} Elf32_Ehdr;

#if HAVE_LONG_LONG
typedef struct
{
unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */
Expand All @@ -110,6 +123,7 @@ typedef struct
Elf64_Half e_shnum; /* Section header table entry count */
Elf64_Half e_shstrndx; /* Section header string table index */
} Elf64_Ehdr;
#endif

/* Fields in the e_ident array. The EI_* macros are indices into the
array. The macros under each EI_* macro are the values the byte
Expand Down Expand Up @@ -295,6 +309,7 @@ typedef struct
Elf32_Word sh_entsize; /* Entry size if section holds table */
} Elf32_Shdr;

#if HAVE_LONG_LONG
typedef struct
{
Elf64_Word sh_name; /* Section name (string tbl index) */
Expand All @@ -308,6 +323,7 @@ typedef struct
Elf64_Xword sh_addralign; /* Section alignment */
Elf64_Xword sh_entsize; /* Entry size if section holds table */
} Elf64_Shdr;
#endif

/* Special section indices. */

Expand Down Expand Up @@ -401,6 +417,7 @@ typedef struct
Elf32_Section st_shndx; /* Section index */
} Elf32_Sym;

#if HAVE_LONG_LONG
typedef struct
{
Elf64_Word st_name; /* Symbol name (string tbl index) */
Expand All @@ -410,6 +427,7 @@ typedef struct
Elf64_Addr st_value; /* Symbol value */
Elf64_Xword st_size; /* Symbol size */
} Elf64_Sym;
#endif

/* The syminfo section if available contains additional information about
every dynamic symbol. */
Expand All @@ -420,11 +438,13 @@ typedef struct
Elf32_Half si_flags; /* Per symbol flags */
} Elf32_Syminfo;

#if HAVE_LONG_LONG
typedef struct
{
Elf64_Half si_boundto; /* Direct bindings, symbol bound to */
Elf64_Half si_flags; /* Per symbol flags */
} Elf64_Syminfo;
#endif

/* Possible values for si_boundto. */
#define SYMINFO_BT_SELF 0xffff /* Symbol bound to self */
Expand Down Expand Up @@ -512,6 +532,7 @@ typedef struct
Elf32_Word r_info; /* Relocation type and symbol index */
} Elf32_Rel;

#if HAVE_LONG_LONG
/* I have seen two different definitions of the Elf64_Rel and
Elf64_Rela structures, so we'll leave them out until Novell (or
whoever) gets their act together. */
Expand All @@ -522,6 +543,7 @@ typedef struct
Elf64_Addr r_offset; /* Address */
Elf64_Xword r_info; /* Relocation type and symbol index */
} Elf64_Rel;
#endif

/* Relocation table entry with addend (in section of type SHT_RELA). */

Expand All @@ -532,12 +554,14 @@ typedef struct
Elf32_Sword r_addend; /* Addend */
} Elf32_Rela;

#if HAVE_LONG_LONG
typedef struct
{
Elf64_Addr r_offset; /* Address */
Elf64_Xword r_info; /* Relocation type and symbol index */
Elf64_Sxword r_addend; /* Addend */
} Elf64_Rela;
#endif

/* How to extract and insert information held in the r_info field. */

Expand All @@ -563,6 +587,7 @@ typedef struct
Elf32_Word p_align; /* Segment alignment */
} Elf32_Phdr;

#if HAVE_LONG_LONG
typedef struct
{
Elf64_Word p_type; /* Segment type */
Expand All @@ -574,6 +599,7 @@ typedef struct
Elf64_Xword p_memsz; /* Segment size in memory */
Elf64_Xword p_align; /* Segment alignment */
} Elf64_Phdr;
#endif

/* Special value for e_phnum. This indicates that the real number of
program headers is too large to fit into e_phnum. Instead the real
Expand Down Expand Up @@ -667,6 +693,7 @@ typedef struct
} d_un;
} Elf32_Dyn;

#if HAVE_LONG_LONG
typedef struct
{
Elf64_Sxword d_tag; /* Dynamic entry type */
Expand All @@ -676,6 +703,7 @@ typedef struct
Elf64_Addr d_ptr; /* Address value */
} d_un;
} Elf64_Dyn;
#endif

/* Legal values for d_tag (dynamic entry type). */

Expand Down Expand Up @@ -845,6 +873,7 @@ typedef struct
entry */
} Elf32_Verdef;

#if HAVE_LONG_LONG
typedef struct
{
Elf64_Half vd_version; /* Version revision */
Expand All @@ -856,7 +885,7 @@ typedef struct
Elf64_Word vd_next; /* Offset in bytes to next verdef
entry */
} Elf64_Verdef;

#endif

/* Legal values for vd_version (version revision). */
#define VER_DEF_NONE 0 /* No version */
Expand All @@ -882,13 +911,14 @@ typedef struct
entry */
} Elf32_Verdaux;

#if HAVE_LONG_LONG
typedef struct
{
Elf64_Word vda_name; /* Version or dependency names */
Elf64_Word vda_next; /* Offset in bytes to next verdaux
entry */
} Elf64_Verdaux;

#endif

/* Version dependency section. */

Expand All @@ -903,6 +933,7 @@ typedef struct
entry */
} Elf32_Verneed;

#if HAVE_LONG_LONG
typedef struct
{
Elf64_Half vn_version; /* Version of structure */
Expand All @@ -913,7 +944,7 @@ typedef struct
Elf64_Word vn_next; /* Offset in bytes to next verneed
entry */
} Elf64_Verneed;

#endif

/* Legal values for vn_version (version revision). */
#define VER_NEED_NONE 0 /* No version */
Expand All @@ -932,6 +963,7 @@ typedef struct
entry */
} Elf32_Vernaux;

#if HAVE_LONG_LONG
typedef struct
{
Elf64_Word vna_hash; /* Hash value of dependency name */
Expand All @@ -941,7 +973,7 @@ typedef struct
Elf64_Word vna_next; /* Offset in bytes to next vernaux
entry */
} Elf64_Vernaux;

#endif

/* Legal values for vna_flags. */
#define VER_FLG_WEAK 0x2 /* Weak version identifier */
Expand All @@ -968,6 +1000,7 @@ typedef struct
} a_un;
} Elf32_auxv_t;

#if HAVE_LONG_LONG
typedef struct
{
uint64_t a_type; /* Entry type */
Expand All @@ -979,6 +1012,7 @@ typedef struct
on 64-bit platforms and vice versa. */
} a_un;
} Elf64_auxv_t;
#endif

/* Legal values for a_type (entry type). */

Expand Down Expand Up @@ -1047,12 +1081,14 @@ typedef struct
Elf32_Word n_type; /* Type of the note. */
} Elf32_Nhdr;

#if HAVE_LONG_LONG
typedef struct
{
Elf64_Word n_namesz; /* Length of the note's name. */
Elf64_Word n_descsz; /* Length of the note's descriptor. */
Elf64_Word n_type; /* Type of the note. */
} Elf64_Nhdr;
#endif

/* Known names of notes. */

Expand Down Expand Up @@ -1106,13 +1142,18 @@ typedef struct
/* Move records. */
typedef struct
{
#if HAVE_LONG_LONG
Elf32_Xword m_value; /* Symbol value. */
#else
Elf32_Word m_info; /* Size and index. */
Elf32_Word m_info_padding;
#endif
Elf32_Word m_poffset; /* Symbol offset. */
Elf32_Half m_repeat; /* Repeat count. */
Elf32_Half m_stride; /* Stride info. */
} Elf32_Move;

#if HAVE_LONG_LONG
typedef struct
{
Elf64_Xword m_value; /* Symbol value. */
Expand All @@ -1121,6 +1162,7 @@ typedef struct
Elf64_Half m_repeat; /* Repeat count. */
Elf64_Half m_stride; /* Stride info. */
} Elf64_Move;
#endif

/* Macro to construct move records. */
#define ELF32_M_SYM(info) ((info) >> 8)
Expand Down Expand Up @@ -1734,6 +1776,7 @@ typedef struct
Elf32_Word l_flags; /* Flags */
} Elf32_Lib;

#if HAVE_LONG_LONG
typedef struct
{
Elf64_Word l_name; /* Name (string table index) */
Expand All @@ -1742,7 +1785,7 @@ typedef struct
Elf64_Word l_version; /* Interface version */
Elf64_Word l_flags; /* Flags */
} Elf64_Lib;

#endif

/* Legal values for l_flags. */

Expand Down

0 comments on commit 233146f

Please sign in to comment.