Remove ELF

This commit is contained in:
Alex Kotov 2022-12-25 13:39:52 +04:00
parent f76a6630d6
commit 6c84bc942b
Signed by: kotovalexarian
GPG Key ID: 553C0EBBEB5D5F08
12 changed files with 0 additions and 263 deletions

View File

@ -73,9 +73,6 @@ endif
# Default packages #
####################
if WITH_ELF
libkernaux_la_SOURCES += src/elf.c
endif
if WITH_MBR
libkernaux_la_SOURCES += src/mbr.c
endif

View File

@ -46,7 +46,6 @@ zero). Work-in-progress APIs can change at any time.
* Algorithms
* [Page Frame Allocator](/include/kernaux/pfa.h) (*work in progress*)
* Data formats
* [ELF](/include/kernaux/elf.h) (*work in progress*)
* [MBR](/include/kernaux/mbr.h) (*work in progress*)
* libc replacement (*work in progress*)
* [ctype.h](/libc/include/ctype.h)

View File

@ -66,7 +66,6 @@ AC_ARG_WITH( [arch-i386], AS_HELP_STRING([--without-arch-i386], [wit
AC_ARG_WITH( [arch-riscv64], AS_HELP_STRING([--without-arch-riscv64], [without architecture riscv64]))
AC_ARG_WITH( [arch-x86-64], AS_HELP_STRING([--without-arch-x86-64], [without architecture x86-64]))
AC_ARG_WITH( [asm], AS_HELP_STRING([--without-asm], [without kernel assembler helpers]))
AC_ARG_WITH( [elf], AS_HELP_STRING([--without-elf], [without ELF utils]))
AC_ARG_WITH( [mbr], AS_HELP_STRING([--without-mbr], [without MBR utils]))
AC_ARG_WITH( [pfa], AS_HELP_STRING([--without-pfa], [without Page Frame Allocator]))
@ -100,7 +99,6 @@ if test -z "$with_arch_i386"; then with_arch_i386=no; fi
if test -z "$with_arch_riscv64"; then with_arch_riscv64=no; fi
if test -z "$with_arch_x86_64"; then with_arch_x86_64=no; fi
if test -z "$with_asm"; then with_asm=no; fi
if test -z "$with_elf"; then with_elf=no; fi
if test -z "$with_mbr"; then with_mbr=no; fi
if test -z "$with_pfa"; then with_pfa=no; fi
])
@ -135,7 +133,6 @@ AS_IF([test "$with_arch_i386" = no ], [with_arch_i386=no], [wit
AS_IF([test "$with_arch_riscv64" = no ], [with_arch_riscv64=no], [with_arch_riscv64=yes])
AS_IF([test "$with_arch_x86_64" = no ], [with_arch_x86_64=no], [with_arch_x86_64=yes])
AS_IF([test "$with_asm" = no ], [with_asm=no], [with_asm=yes])
AS_IF([test "$with_elf" = no ], [with_elf=no], [with_elf=yes])
AS_IF([test "$with_mbr" = no ], [with_mbr=no], [with_mbr=yes])
AS_IF([test "$with_pfa" = no ], [with_pfa=no], [with_pfa=yes])
@ -184,7 +181,6 @@ AM_CONDITIONAL([WITH_ARCH_I386], [test "$with_arch_i386" = yes])
AM_CONDITIONAL([WITH_ARCH_RISCV64], [test "$with_arch_riscv64" = yes])
AM_CONDITIONAL([WITH_ARCH_X86_64], [test "$with_arch_x86_64" = yes])
AM_CONDITIONAL([WITH_ASM], [test "$with_asm" = yes])
AM_CONDITIONAL([WITH_ELF], [test "$with_elf" = yes])
AM_CONDITIONAL([WITH_MBR], [test "$with_mbr" = yes])
AM_CONDITIONAL([WITH_PFA], [test "$with_pfa" = yes])
@ -225,7 +221,6 @@ AS_IF([test "$with_arch_i386" = yes], [AC_DEFINE([WITH_ARCH_I386],
AS_IF([test "$with_arch_riscv64" = yes], [AC_DEFINE([WITH_ARCH_RISCV64], [1], [with architecture riscv64])])
AS_IF([test "$with_arch_x86_64" = yes], [AC_DEFINE([WITH_ARCH_X86_64], [1], [with architecture x86_64])])
AS_IF([test "$with_asm" = yes], [AC_DEFINE([WITH_ASM], [1], [with kernel assembler helpers])])
AS_IF([test "$with_elf" = yes], [AC_DEFINE([WITH_ELF], [1], [with ELF utils])])
AS_IF([test "$with_mbr" = yes], [AC_DEFINE([WITH_MBR], [1], [with MBR utils])])
AS_IF([test "$with_pfa" = yes], [AC_DEFINE([WITH_PFA], [1], [with Page Frame Allocator])])
@ -249,7 +244,6 @@ dnl Packages (enabled by default)
AS_IF([test "$with_arch_i386" = no], [AC_SUBST([comment_line_arch_i386], [//])])
AS_IF([test "$with_arch_riscv64" = no], [AC_SUBST([comment_line_arch_riscv64], [//])])
AS_IF([test "$with_arch_x86_64" = no], [AC_SUBST([comment_line_arch_x86_64], [//])])
AS_IF([test "$with_elf" = no], [AC_SUBST([comment_line_elf], [//])])
AS_IF([test "$with_mbr" = no], [AC_SUBST([comment_line_mbr], [//])])
AS_IF([test "$with_pfa" = no], [AC_SUBST([comment_line_pfa], [//])])

View File

@ -9,7 +9,6 @@ nobase_include_HEADERS = \
kernaux/asm/riscv64.h \
kernaux/asm/x86_64.h \
kernaux/asm/x86.h \
kernaux/elf.h \
kernaux/macro.h \
kernaux/macro/packing_end.run \
kernaux/macro/packing_start.run \

View File

@ -6,7 +6,6 @@
#include <kernaux/arch/i386.h>
#include <kernaux/arch/riscv64.h>
#include <kernaux/arch/x86_64.h>
#include <kernaux/elf.h>
#include <kernaux/macro.h>
#include <kernaux/mbr.h>
#include <kernaux/pfa.h>

View File

@ -1,181 +0,0 @@
#ifndef KERNAUX_INCLUDED_ELF
#define KERNAUX_INCLUDED_ELF
#ifdef __cplusplus
extern "C" {
#endif
#include <kernaux/macro.h>
#include <stdint.h>
#include <kernaux/macro/packing_start.run>
struct KernAux_ELF_Ident {
uint8_t magic_0x7f;
uint8_t magic_E;
uint8_t magic_L;
uint8_t magic_F;
uint8_t class_;
uint8_t data;
uint8_t version;
uint8_t unused[9];
}
KERNAUX_PACKED;
KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_ELF_Ident, 16);
// KernAux_ELF_Ident.class_
#define KERNAUX_ELF_CLASS_NONE 0 // Invalid class
#define KERNAUX_ELF_CLASS_32 1 // 32-bit objects
#define KERNAUX_ELF_CLASS_64 2 // 64-bit objects
// KernAux_ELF_Ident.data
#define KERNAUX_ELF_DATA_NONE 0 // Invalid data encoding
#define KERNAUX_ELF_DATA_2LSB 1 // 0x01020304 == [0x04, 0x03, 0x02, 0x01]
#define KERNAUX_ELF_DATA_2MSB 2 // 0x01020304 == [0x01, 0x02, 0x03, 0x04]
struct KernAux_ELF_Header {
struct KernAux_ELF_Ident ident;
uint16_t type;
uint16_t machine;
uint32_t version;
uint32_t entry;
uint32_t phoff;
uint32_t shoff;
uint32_t flags;
uint16_t ehsize;
uint16_t phentsize;
uint16_t phnum;
uint16_t shentsize;
uint16_t shnum;
uint16_t shstrndx;
}
KERNAUX_PACKED;
KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_ELF_Header, 52);
// KernAux_ELF_Header.type
#define KERNAUX_ELF_TYPE_NONE 0 // No file type
#define KERNAUX_ELF_TYPE_REL 1 // Relocatable file
#define KERNAUX_ELF_TYPE_EXEC 2 // Executable file
#define KERNAUX_ELF_TYPE_DYN 3 // Shared object file
#define KERNAUX_ELF_TYPE_CORE 4 // Core file
#define KERNAUX_ELF_TYPE_LOPROC 0xff00 // Processor-specific
#define KERNAUX_ELF_TYPE_HIPROC 0xffff // Processor-specific
// KernAux_ELF_Header.machine
#define KERNAUX_ELF_MACHINE_NONE 0 // No machine
#define KERNAUX_ELF_MACHINE_M32 1 // AT&T WE 32100
#define KERNAUX_ELF_MACHINE_SPARC 2 // SPARC
#define KERNAUX_ELF_MACHINE_386 3 // Intel 80386
#define KERNAUX_ELF_MACHINE_68K 4 // Motorola 68000
#define KERNAUX_ELF_MACHINE_88K 5 // Motorola 88000
#define KERNAUX_ELF_MACHINE_860 7 // Intel 80860
#define KERNAUX_ELF_MACHINE_MIPS 8 // MIPS RS3000
// KernAux_ELF_Header.version
#define KERNAUX_ELF_VERSION_NONE 0 // Invalid version
#define KERNAUX_ELF_VERSION_CURRENT 1 // Current version
struct KernAux_ELF_Section {
uint32_t name;
uint32_t type;
uint32_t flags;
uint32_t addr;
uint32_t offset;
uint32_t size;
uint32_t link;
uint32_t info;
uint32_t addralign;
uint32_t entsize;
}
KERNAUX_PACKED;
KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_ELF_Section, 40);
#define KERNAUX_ELF_SECT_TYPE_NULL 0
#define KERNAUX_ELF_SECT_TYPE_PROGBITS 1
#define KERNAUX_ELF_SECT_TYPE_SYMTAB 2
#define KERNAUX_ELF_SECT_TYPE_STRTAB 3
#define KERNAUX_ELF_SECT_TYPE_RELA 4
#define KERNAUX_ELF_SECT_TYPE_HASH 5
#define KERNAUX_ELF_SECT_TYPE_DYNAMIC 6
#define KERNAUX_ELF_SECT_TYPE_NOTE 7
#define KERNAUX_ELF_SECT_TYPE_NOBITS 8
#define KERNAUX_ELF_SECT_TYPE_REL 9
#define KERNAUX_ELF_SECT_TYPE_SHLIB 10
#define KERNAUX_ELF_SECT_TYPE_DYNSYM 11
#define KERNAUX_ELF_SECT_TYPE_LOPROC 0x70000000
#define KERNAUX_ELF_SECT_TYPE_HIPROC 0x7fffffff
#define KERNAUX_ELF_SECT_TYPE_LOUSER 0x80000000
#define KERNAUX_ELF_SECT_TYPE_HIUSER 0xffffffff
#define KERNAUX_ELF_SECT_FLAGS_WRITE 0x1
#define KERNAUX_ELF_SECT_FLAGS_ALLOC 0x2
#define KERNAUX_ELF_SECT_FLAGS_EXECINSTR 0x4
#define KERNAUX_ELF_SECT_FLAGS_MASKPROC 0xf0000000
const char *KernAux_ELF_Section_Type_to_str(uint32_t type);
struct KernAux_ELF_Symbol {
uint32_t name;
uint32_t value;
uint32_t size;
uint8_t info;
uint8_t other;
uint16_t shndx;
}
KERNAUX_PACKED;
KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_ELF_Symbol, 16);
#define KERNAUX_ELF_SYM_INFO(bind, type) (((bind) << 4) + ((type) & 0xf))
#define KERNAUX_ELF_SYM_BIND(info) ((info) >> 4)
#define KERNAUX_ELF_SYM_TYPE(info) ((into) & 0xf)
#define KERNAUX_ELF_SYM_BIND_LOCAL 0
#define KERNAUX_ELF_SYM_BIND_GLOBAL 1
#define KERNAUX_ELF_SYM_BIND_WEAK 2
#define KERNAUX_ELF_SYM_BIND_LOPROC 13
#define KERNAUX_ELF_SYM_BIND_HIPROC 15
#define KERNAUX_ELF_SYM_TYPE_NOTYPE 0
#define KERNAUX_ELF_SYM_TYPE_OBJECT 1
#define KERNAUX_ELF_SYM_TYPE_FUNC 2
#define KERNAUX_ELF_SYM_TYPE_SECTION 3
#define KERNAUX_ELF_SYM_TYPE_FILE 4
#define KERNAUX_ELF_SYM_TYPE_LOPROC 13
#define KERNAUX_ELF_SYM_TYPE_HIPROC 15
struct KernAux_ELF_Program {
uint32_t type;
uint32_t offset;
uint32_t vaddr;
uint32_t paddr;
uint32_t filesz;
uint32_t memsz;
uint32_t flags;
uint32_t align;
}
KERNAUX_PACKED;
KERNAUX_STATIC_TEST_STRUCT_SIZE(KernAux_ELF_Program, 32);
#define KERNAUX_ELF_PROG_TYPE_NULL 0
#define KERNAUX_ELF_PROG_TYPE_LOAD 1
#define KERNAUX_ELF_PROG_TYPE_DYNAMIC 2
#define KERNAUX_ELF_PROG_TYPE_INTERP 3
#define KERNAUX_ELF_PROG_TYPE_NOTE 4
#define KERNAUX_ELF_PROG_TYPE_SHLIB 5
#define KERNAUX_ELF_PROG_TYPE_PHDR 6
#define KERNAUX_ELF_PROG_TYPE_LOPROC 0x70000000
#define KERNAUX_ELF_PROG_TYPE_HIPROC 0x7fffffff
#include <kernaux/macro/packing_end.run>
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,7 +1,6 @@
#ifndef KERNAUX_INCLUDED_VERSION
#define KERNAUX_INCLUDED_VERSION
@comment_line_elf@#define KERNAUX_VERSION_WITH_ELF
@comment_line_mbr@#define KERNAUX_VERSION_WITH_MBR
@comment_line_pfa@#define KERNAUX_VERSION_WITH_PFA

View File

@ -8,7 +8,6 @@ include/kernaux/asm/i386.h
include/kernaux/asm/riscv64.h
include/kernaux/asm/x86.h
include/kernaux/asm/x86_64.h
include/kernaux/elf.h
include/kernaux/macro.h
include/kernaux/macro/packing_end.run
include/kernaux/macro/packing_start.run

View File

@ -1,48 +0,0 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <kernaux/elf.h>
#include <kernaux/macro.h>
#include <stddef.h>
const char *KernAux_ELF_Section_Type_to_str(const uint32_t type)
{
switch (type) {
case KERNAUX_ELF_SECT_TYPE_NULL:
return "NULL";
case KERNAUX_ELF_SECT_TYPE_PROGBITS:
return "PROGBITS";
case KERNAUX_ELF_SECT_TYPE_SYMTAB:
return "SYMTAB";
case KERNAUX_ELF_SECT_TYPE_STRTAB:
return "STRTAB";
case KERNAUX_ELF_SECT_TYPE_RELA:
return "RELA";
case KERNAUX_ELF_SECT_TYPE_HASH:
return "HASH";
case KERNAUX_ELF_SECT_TYPE_DYNAMIC:
return "DYNAMIC";
case KERNAUX_ELF_SECT_TYPE_NOTE:
return "NOTE";
case KERNAUX_ELF_SECT_TYPE_NOBITS:
return "NOBITS";
case KERNAUX_ELF_SECT_TYPE_REL:
return "REL";
case KERNAUX_ELF_SECT_TYPE_SHLIB:
return "SHLIB";
case KERNAUX_ELF_SECT_TYPE_DYNSYM:
return "DYNSYM";
case KERNAUX_ELF_SECT_TYPE_LOPROC:
return "LOPROC";
case KERNAUX_ELF_SECT_TYPE_HIPROC:
return "HIPROC";
case KERNAUX_ELF_SECT_TYPE_LOUSER:
return "LOUSER";
case KERNAUX_ELF_SECT_TYPE_HIUSER:
return "HIUSER";
default:
return NULL;
}
}

1
tests/.gitignore vendored
View File

@ -1,5 +1,4 @@
/test_arch_i386
/test_elf
/test_mbr
/test_pfa
/test_pfa_assert

View File

@ -16,18 +16,6 @@ test_arch_i386_SOURCES = \
test_arch_i386.c
endif
############
# test_elf #
############
if WITH_ELF
TESTS += test_elf
test_elf_LDADD = $(top_builddir)/libkernaux.la
test_elf_SOURCES = \
main.c \
test_elf.c
endif
############
# test_mbr #
############

View File

@ -1,7 +0,0 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <kernaux/elf.h>
void test_main() {}