[PATCH 2/6] Move common definitions in lilo.c/netbsd.c to elf.h

[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-devel Archives ]


---
 src/includes/elf.h | 116 ++++++++++++++++++++++++++++++++++++++++++++
 src/lilo.c         |  69 +-------------------------
 src/netbsd.c       | 118 +--------------------------------------------
 3 files changed, 118 insertions(+), 185 deletions(-)
 create mode 100644 src/includes/elf.h

diff --git a/src/includes/elf.h b/src/includes/elf.h
new file mode 100644
index 00000000..498b7f6d
--- /dev/null
+++ b/src/includes/elf.h
@@ -0,0 +1,116 @@
+/*--- Rip from elf.h ---*/
+
+/* Type for a 16-bit quantity.  */
+typedef uint16_t Elf32_Half;
+
+/* Types for signed and unsigned 32-bit quantities.  */
+typedef uint32_t Elf32_Word;
+typedef	int32_t  Elf32_Sword;
+
+/* Types for signed and unsigned 64-bit quantities.  */
+typedef uint64_t Elf32_Xword;
+typedef	int64_t  Elf32_Sxword;
+
+/* Type of addresses.  */
+typedef uint32_t Elf32_Addr;
+
+/* Type of file offsets.  */
+typedef uint32_t Elf32_Off;
+
+/* Type for section indices, which are 16-bit quantities.  */
+typedef uint16_t Elf32_Section;
+
+/* Type for version symbol information.  */
+typedef Elf32_Half Elf32_Versym;
+
+
+/* The ELF file header.  This appears at the start of every ELF file.  */
+
+#define EI_NIDENT (16)
+
+typedef struct
+{
+  unsigned char	e_ident[EI_NIDENT];	/* Magic number and other info */
+  Elf32_Half	e_type;			/* Object file type */
+  Elf32_Half	e_machine;		/* Architecture */
+  Elf32_Word	e_version;		/* Object file version */
+  Elf32_Addr	e_entry;		/* Entry point virtual address */
+  Elf32_Off	e_phoff;		/* Program header table file offset */
+  Elf32_Off	e_shoff;		/* Section header table file offset */
+  Elf32_Word	e_flags;		/* Processor-specific flags */
+  Elf32_Half	e_ehsize;		/* ELF header size in bytes */
+  Elf32_Half	e_phentsize;		/* Program header table entry size */
+  Elf32_Half	e_phnum;		/* Program header table entry count */
+  Elf32_Half	e_shentsize;		/* Section header table entry size */
+  Elf32_Half	e_shnum;		/* Section header table entry count */
+  Elf32_Half	e_shstrndx;		/* Section header string table index */
+} Elf32_Ehdr;
+
+/* Program segment header.  */
+
+typedef struct
+{
+  Elf32_Word	p_type;			/* Segment type */
+  Elf32_Off	p_offset;		/* Segment file offset */
+  Elf32_Addr	p_vaddr;		/* Segment virtual address */
+  Elf32_Addr	p_paddr;		/* Segment physical address */
+  Elf32_Word	p_filesz;		/* Segment size in file */
+  Elf32_Word	p_memsz;		/* Segment size in memory */
+  Elf32_Word	p_flags;		/* Segment flags */
+  Elf32_Word	p_align;		/* Segment alignment */
+} Elf32_Phdr;
+
+#define EI_MAG0		0		/* File identification byte 0 index */
+#define	ELFMAG		"\177ELF"
+#define	SELFMAG		4
+#define ET_EXEC		2		/* Executable file */
+#define EM_68K		 4		/* Motorola m68k family */
+#define EV_CURRENT	1		/* Current version */
+
+/*
+ * Section Headers
+ */
+typedef struct {
+	Elf32_Word	sh_name;	/* section name (.shstrtab index) */
+	Elf32_Word	sh_type;	/* section type */
+	Elf32_Word	sh_flags;	/* section flags */
+	Elf32_Addr	sh_addr;	/* virtual address */
+	Elf32_Off	sh_offset;	/* file offset */
+	Elf32_Word	sh_size;	/* section size */
+	Elf32_Word	sh_link;	/* link to another */
+	Elf32_Word	sh_info;	/* misc info */
+	Elf32_Word	sh_addralign;	/* memory alignment */
+	Elf32_Word	sh_entsize;	/* table entry size */
+} Elf32_Shdr;
+
+/* sh_type */
+#define	SHT_NULL	0		/* Section header table entry unused */
+#define	SHT_PROGBITS	1		/* Program information */
+#define	SHT_SYMTAB	2		/* Symbol table */
+#define	SHT_STRTAB	3		/* String table */
+#define	SHT_RELA	4		/* Relocation information w/ addend */
+#define	SHT_HASH	5		/* Symbol hash table */
+#define	SHT_DYNAMIC	6		/* Dynamic linking information */
+#define	SHT_NOTE	7		/* Auxiliary information */
+#define	SHT_NOBITS	8		/* No space allocated in file image */
+#define	SHT_REL		9		/* Relocation information w/o addend */
+#define	SHT_SHLIB	10		/* Reserved, unspecified semantics */
+#define	SHT_DYNSYM	11		/* Symbol table for dynamic linker */
+#define	SHT_NUM		12
+
+#define	SHT_LOOS	0x60000000	/* Operating system specific range */
+#define	SHT_HIOS	0x6fffffff
+#define	SHT_LOPROC	0x70000000	/* Processor-specific range */
+#define	SHT_HIPROC	0x7fffffff
+#define	SHT_LOUSER	0x80000000	/* Application-specific range */
+#define	SHT_HIUSER	0xffffffff
+
+/* sh_flags */
+#define	SHF_WRITE	0x1		/* Section contains writable data */
+#define	SHF_ALLOC	0x2		/* Section occupies memory */
+#define	SHF_EXECINSTR	0x4		/* Section contains executable insns */
+
+#define	SHF_MASKOS	0x0f000000	/* Operating system specific values */
+#define	SHF_MASKPROC	0xf0000000	/* Processor-specific values */
+
+/* end of rip from elf.h */
diff --git a/src/lilo.c b/src/lilo.c
index 01eff1ad..9a0d4186 100644
--- a/src/lilo.c
+++ b/src/lilo.c
@@ -20,6 +20,7 @@
 #include "symbols.h"
 #include <stdint.h>
 #include <SDL_endian.h>
+#include "elf.h"
 
 bool bUseLilo;
 
@@ -30,74 +31,6 @@ bool bUseLilo;
 #define Dprintf(a)
 #endif
 
-/*--- Rip from elf.h ---*/
-
-/* Type for a 16-bit quantity.  */
-typedef uint16_t Elf32_Half;
-
-/* Types for signed and unsigned 32-bit quantities.  */
-typedef uint32_t Elf32_Word;
-typedef	int32_t  Elf32_Sword;
-
-/* Types for signed and unsigned 64-bit quantities.  */
-typedef uint64_t Elf32_Xword;
-typedef	int64_t  Elf32_Sxword;
-
-/* Type of addresses.  */
-typedef uint32_t Elf32_Addr;
-
-/* Type of file offsets.  */
-typedef uint32_t Elf32_Off;
-
-/* Type for section indices, which are 16-bit quantities.  */
-typedef uint16_t Elf32_Section;
-
-/* Type for version symbol information.  */
-typedef Elf32_Half Elf32_Versym;
-
-
-/* The ELF file header.  This appears at the start of every ELF file.  */
-
-#define EI_NIDENT (16)
-
-typedef struct
-{
-  unsigned char	e_ident[EI_NIDENT];	/* Magic number and other info */
-  Elf32_Half	e_type;			/* Object file type */
-  Elf32_Half	e_machine;		/* Architecture */
-  Elf32_Word	e_version;		/* Object file version */
-  Elf32_Addr	e_entry;		/* Entry point virtual address */
-  Elf32_Off	e_phoff;		/* Program header table file offset */
-  Elf32_Off	e_shoff;		/* Section header table file offset */
-  Elf32_Word	e_flags;		/* Processor-specific flags */
-  Elf32_Half	e_ehsize;		/* ELF header size in bytes */
-  Elf32_Half	e_phentsize;		/* Program header table entry size */
-  Elf32_Half	e_phnum;		/* Program header table entry count */
-  Elf32_Half	e_shentsize;		/* Section header table entry size */
-  Elf32_Half	e_shnum;		/* Section header table entry count */
-  Elf32_Half	e_shstrndx;		/* Section header string table index */
-} Elf32_Ehdr;
-
-/* Program segment header.  */
-
-typedef struct
-{
-  Elf32_Word	p_type;			/* Segment type */
-  Elf32_Off	p_offset;		/* Segment file offset */
-  Elf32_Addr	p_vaddr;		/* Segment virtual address */
-  Elf32_Addr	p_paddr;		/* Segment physical address */
-  Elf32_Word	p_filesz;		/* Segment size in file */
-  Elf32_Word	p_memsz;		/* Segment size in memory */
-  Elf32_Word	p_flags;		/* Segment flags */
-  Elf32_Word	p_align;		/* Segment alignment */
-} Elf32_Phdr;
-
-#define EI_MAG0		0		/* File identification byte 0 index */
-#define	ELFMAG		"\177ELF"
-#define	SELFMAG		4
-#define ET_EXEC		2		/* Executable file */
-#define EM_68K		 4		/* Motorola m68k family */
-#define EV_CURRENT	1		/* Current version */
 
 /*
  * Tag Definitions
diff --git a/src/netbsd.c b/src/netbsd.c
index b0502e2b..771845b7 100644
--- a/src/netbsd.c
+++ b/src/netbsd.c
@@ -18,6 +18,7 @@
 #include <stdint.h>
 #include <SDL_endian.h>
 #include "newcpu.h"
+#include "elf.h"
 
 bool bUseNetbsd;
 
@@ -28,123 +29,6 @@ bool bUseNetbsd;
 #define Dprintf(a)
 #endif
 
-/*--- Rip from elf.h ---*/
-
-/* Type for a 16-bit quantity.  */
-typedef uint16_t Elf32_Half;
-
-/* Types for signed and unsigned 32-bit quantities.  */
-typedef uint32_t Elf32_Word;
-typedef	int32_t  Elf32_Sword;
-
-/* Types for signed and unsigned 64-bit quantities.  */
-typedef uint64_t Elf32_Xword;
-typedef	int64_t  Elf32_Sxword;
-
-/* Type of addresses.  */
-typedef uint32_t Elf32_Addr;
-
-/* Type of file offsets.  */
-typedef uint32_t Elf32_Off;
-
-/* Type for section indices, which are 16-bit quantities.  */
-typedef uint16_t Elf32_Section;
-
-/* Type for version symbol information.  */
-typedef Elf32_Half Elf32_Versym;
-
-
-/* The ELF file header.  This appears at the start of every ELF file.  */
-
-#define EI_NIDENT (16)
-
-typedef struct
-{
-  unsigned char	e_ident[EI_NIDENT];	/* Magic number and other info */
-  Elf32_Half	e_type;			/* Object file type */
-  Elf32_Half	e_machine;		/* Architecture */
-  Elf32_Word	e_version;		/* Object file version */
-  Elf32_Addr	e_entry;		/* Entry point virtual address */
-  Elf32_Off	e_phoff;		/* Program header table file offset */
-  Elf32_Off	e_shoff;		/* Section header table file offset */
-  Elf32_Word	e_flags;		/* Processor-specific flags */
-  Elf32_Half	e_ehsize;		/* ELF header size in bytes */
-  Elf32_Half	e_phentsize;		/* Program header table entry size */
-  Elf32_Half	e_phnum;		/* Program header table entry count */
-  Elf32_Half	e_shentsize;		/* Section header table entry size */
-  Elf32_Half	e_shnum;		/* Section header table entry count */
-  Elf32_Half	e_shstrndx;		/* Section header string table index */
-} Elf32_Ehdr;
-
-/* Program segment header.  */
-
-typedef struct
-{
-  Elf32_Word	p_type;			/* Segment type */
-  Elf32_Off	p_offset;		/* Segment file offset */
-  Elf32_Addr	p_vaddr;		/* Segment virtual address */
-  Elf32_Addr	p_paddr;		/* Segment physical address */
-  Elf32_Word	p_filesz;		/* Segment size in file */
-  Elf32_Word	p_memsz;		/* Segment size in memory */
-  Elf32_Word	p_flags;		/* Segment flags */
-  Elf32_Word	p_align;		/* Segment alignment */
-} Elf32_Phdr;
-
-#define EI_MAG0		0		/* File identification byte 0 index */
-#define	ELFMAG		"\177ELF"
-#define	SELFMAG		4
-#define ET_EXEC		2		/* Executable file */
-#define EM_68K		 4		/* Motorola m68k family */
-#define EV_CURRENT	1		/* Current version */
-
-/*
- * Section Headers
- */
-typedef struct {
-	Elf32_Word	sh_name;	/* section name (.shstrtab index) */
-	Elf32_Word	sh_type;	/* section type */
-	Elf32_Word	sh_flags;	/* section flags */
-	Elf32_Addr	sh_addr;	/* virtual address */
-	Elf32_Off	sh_offset;	/* file offset */
-	Elf32_Word	sh_size;	/* section size */
-	Elf32_Word	sh_link;	/* link to another */
-	Elf32_Word	sh_info;	/* misc info */
-	Elf32_Word	sh_addralign;	/* memory alignment */
-	Elf32_Word	sh_entsize;	/* table entry size */
-} Elf32_Shdr;
-
-/* sh_type */
-#define	SHT_NULL	0		/* Section header table entry unused */
-#define	SHT_PROGBITS	1		/* Program information */
-#define	SHT_SYMTAB	2		/* Symbol table */
-#define	SHT_STRTAB	3		/* String table */
-#define	SHT_RELA	4		/* Relocation information w/ addend */
-#define	SHT_HASH	5		/* Symbol hash table */
-#define	SHT_DYNAMIC	6		/* Dynamic linking information */
-#define	SHT_NOTE	7		/* Auxiliary information */
-#define	SHT_NOBITS	8		/* No space allocated in file image */
-#define	SHT_REL		9		/* Relocation information w/o addend */
-#define	SHT_SHLIB	10		/* Reserved, unspecified semantics */
-#define	SHT_DYNSYM	11		/* Symbol table for dynamic linker */
-#define	SHT_NUM		12
-
-#define	SHT_LOOS	0x60000000	/* Operating system specific range */
-#define	SHT_HIOS	0x6fffffff
-#define	SHT_LOPROC	0x70000000	/* Processor-specific range */
-#define	SHT_HIPROC	0x7fffffff
-#define	SHT_LOUSER	0x80000000	/* Application-specific range */
-#define	SHT_HIUSER	0xffffffff
-
-/* sh_flags */
-#define	SHF_WRITE	0x1		/* Section contains writable data */
-#define	SHF_ALLOC	0x2		/* Section occupies memory */
-#define	SHF_EXECINSTR	0x4		/* Section contains executable insns */
-
-#define	SHF_MASKOS	0x0f000000	/* Operating system specific values */
-#define	SHF_MASKPROC	0xf0000000	/* Processor-specific values */
-
-/* end of rip from elf.h */
-
 /*
  * Values for 'bootflags'.
  * Note: These must match the values NetBSD uses!
-- 
2.24.0


--nextPart47411014.jKvtMvv4xN
Content-Disposition: attachment; filename="0003-Move-symbol_t-struct-to-symbols.h.patch"
Content-Transfer-Encoding: 7Bit
Content-Type: text/x-patch; charset="UTF-8"; name="0003-Move-symbol_t-struct-to-symbols.h.patch"



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/