From 25cd854413fe7172bc1def8f7501833ff1cc90f6 Mon Sep 17 00:00:00 2001 From: jdp Date: Mon, 14 Sep 1998 20:30:13 +0000 Subject: [PATCH] Add generic defines ELF_ARCH, ELF_CLASS, and ELF_DATA. These give the relevant characteristics of the native machine, for building and checking Elf_Ehdr structures. Add structures to represent ELF "note" headers. Add defines for the note types used in ELF core files. --- sys/alpha/include/elf.h | 4 +++- sys/amd64/include/elf.h | 4 +++- sys/i386/include/elf.h | 4 +++- sys/sys/elf32.h | 17 ++++++++++++++++- sys/sys/elf64.h | 17 ++++++++++++++++- sys/sys/elf_common.h | 7 ++++++- sys/sys/elf_generic.h | 13 ++++++++++++- 7 files changed, 59 insertions(+), 7 deletions(-) diff --git a/sys/alpha/include/elf.h b/sys/alpha/include/elf.h index 216bead11269..3972adb4825a 100644 --- a/sys/alpha/include/elf.h +++ b/sys/alpha/include/elf.h @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: elf.h,v 1.3 1998/06/28 00:50:35 dfr Exp $ + * $Id: elf.h,v 1.4 1998/08/17 08:05:55 dfr Exp $ */ #ifndef _MACHINE_ELF_H_ @@ -38,6 +38,8 @@ #define __ELF_WORD_SIZE 64 /* Used by */ #include +#define ELF_ARCH EM_ALPHA + #define ELF_MACHINE_OK(x) ((x) == EM_ALPHA) /* diff --git a/sys/amd64/include/elf.h b/sys/amd64/include/elf.h index 2c13a1f7e5dd..5605b6fb3f84 100644 --- a/sys/amd64/include/elf.h +++ b/sys/amd64/include/elf.h @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: elf.h,v 1.2 1997/08/30 18:59:48 peter Exp $ + * $Id: elf.h,v 1.3 1998/08/16 03:03:31 jdp Exp $ */ #ifndef _MACHINE_ELF_H_ @@ -38,6 +38,8 @@ #define __ELF_WORD_SIZE 32 /* Used by */ #include +#define ELF_ARCH EM_386 + /* * Auxiliary vector entries for passing information to the interpreter. * diff --git a/sys/i386/include/elf.h b/sys/i386/include/elf.h index 2c13a1f7e5dd..5605b6fb3f84 100644 --- a/sys/i386/include/elf.h +++ b/sys/i386/include/elf.h @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: elf.h,v 1.2 1997/08/30 18:59:48 peter Exp $ + * $Id: elf.h,v 1.3 1998/08/16 03:03:31 jdp Exp $ */ #ifndef _MACHINE_ELF_H_ @@ -38,6 +38,8 @@ #define __ELF_WORD_SIZE 32 /* Used by */ #include +#define ELF_ARCH EM_386 + /* * Auxiliary vector entries for passing information to the interpreter. * diff --git a/sys/sys/elf32.h b/sys/sys/elf32.h index a37fb9526608..092a4c4126dd 100644 --- a/sys/sys/elf32.h +++ b/sys/sys/elf32.h @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: elf32.h,v 1.3 1998/07/07 23:32:55 jdp Exp $ + * $Id: elf32.h,v 1.4 1998/08/16 03:03:38 jdp Exp $ */ #ifndef _SYS_ELF32_H_ @@ -108,6 +108,21 @@ typedef struct { } d_un; } Elf32_Dyn; +/* + * Note header. The ".note" section contains an array of notes. Each + * begins with this header, aligned to a word boundary. Immediately + * following the note header is n_namesz bytes of name, padded to the + * next word boundary. Then comes n_descsz bytes of contents, again + * padded to a word boundary. The values of n_namesz and n_descsz do + * not include the padding. + */ + +typedef struct { + Elf32_Size n_namesz; /* Length of name. */ + Elf32_Size n_descsz; /* Length of descriptor. */ + Elf32_Word n_type; /* Type of this note. */ +} Elf32_Note; + /* * Relocation entries. */ diff --git a/sys/sys/elf64.h b/sys/sys/elf64.h index 888488bb0385..35f227537080 100644 --- a/sys/sys/elf64.h +++ b/sys/sys/elf64.h @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: elf64.h,v 1.5 1998/09/05 23:07:59 jb Exp $ + * $Id: elf64.h,v 1.6 1998/09/12 08:36:09 dfr Exp $ */ #ifndef _SYS_ELF64_H_ @@ -109,6 +109,21 @@ typedef struct { } d_un; } Elf64_Dyn; +/* + * Note header. The ".note" section contains an array of notes. Each + * begins with this header, aligned to a word boundary. Immediately + * following the note header is n_namesz bytes of name, padded to the + * next word boundary. Then comes n_descsz bytes of descriptor, again + * padded to a word boundary. The values of n_namesz and n_descsz do + * not include the padding. + */ + +typedef struct { + Elf64_Size n_namesz; /* Length of name. */ + Elf64_Size n_descsz; /* Length of descriptor. */ + Elf64_Word n_type; /* Type of this note. */ +} Elf64_Note; + /* * Relocation entries. */ diff --git a/sys/sys/elf_common.h b/sys/sys/elf_common.h index e9f846a11108..79cf5970d877 100644 --- a/sys/sys/elf_common.h +++ b/sys/sys/elf_common.h @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: elf_common.h,v 1.1 1998/08/16 03:03:38 jdp Exp $ + * $Id: elf_common.h,v 1.2 1998/09/08 20:38:06 jdp Exp $ */ #ifndef _SYS_ELF_COMMON_H_ @@ -179,6 +179,11 @@ #define DT_COUNT 24 /* Number of defined d_tag values. */ +/* Values for n_type. Used in core files. */ +#define NT_PRSTATUS 1 /* Process status. */ +#define NT_FPREGSET 2 /* Floating point registers. */ +#define NT_PRPSINFO 3 /* Process state info. */ + /* Symbol Binding - ELFNN_ST_BIND - st_info */ #define STB_LOCAL 0 /* Local symbol */ #define STB_GLOBAL 1 /* Global symbol */ diff --git a/sys/sys/elf_generic.h b/sys/sys/elf_generic.h index ca5092454bd1..7ab479e23b2a 100644 --- a/sys/sys/elf_generic.h +++ b/sys/sys/elf_generic.h @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id$ + * $Id: elf_generic.h,v 1.1 1998/08/16 03:03:38 jdp Exp $ */ #ifndef _SYS_ELF_GENERIC_H_ @@ -40,6 +40,16 @@ #error "__ELF_WORD_SIZE must be defined as 32 or 64" #endif +#define ELF_CLASS __CONCAT(ELFCLASS,__ELF_WORD_SIZE) + +#if BYTE_ORDER == LITTLE_ENDIAN +#define ELF_DATA ELFDATA2LSB +#elif BYTE_ORDER == BIG_ENDIAN +#define ELF_DATA ELFDATA2MSB +#else +#error "Unknown byte order" +#endif + #define __ElfN(x) __CONCAT(__CONCAT(__CONCAT(Elf,__ELF_WORD_SIZE),_),x) #define __ELFN(x) __CONCAT(__CONCAT(__CONCAT(ELF,__ELF_WORD_SIZE),_),x) #define __ElfType(x) typedef __ElfN(x) __CONCAT(Elf_,x) @@ -54,6 +64,7 @@ __ElfType(Ehdr); __ElfType(Shdr); __ElfType(Phdr); __ElfType(Dyn); +__ElfType(Note); __ElfType(Rel); __ElfType(Rela); __ElfType(Sym);