mirror of
https://github.com/drasko/codezero.git
synced 2026-01-31 04:03:13 +01:00
Initial changes for execve() support
This commit is contained in:
@@ -16,6 +16,8 @@ int sys_lseek(struct tcb *sender, int fd, off_t offset, int whence);
|
||||
int sys_close(struct tcb *sender, int fd);
|
||||
int sys_fsync(struct tcb *sender, int fd);
|
||||
int file_open(struct tcb *opener, int fd);
|
||||
|
||||
struct vm_file *do_open2(struct tcb *task, int fd, unsigned long vnum, unsigned long length);
|
||||
int flush_file_pages(struct vm_file *f);
|
||||
|
||||
struct vfs_file_data {
|
||||
|
||||
61
tasks/mm0/include/lib/elf.h
Normal file
61
tasks/mm0/include/lib/elf.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Definitions for Executable Linking Format
|
||||
* Based on Portable Formats Specification v1.1
|
||||
*
|
||||
* Copyright (C) 2008 Bahadir Balban
|
||||
*/
|
||||
|
||||
#ifndef __ELF_H__
|
||||
#define __ELF_H__
|
||||
|
||||
#include <l4/types.h>
|
||||
|
||||
/* ELF identification indices */
|
||||
#define EI_MAG0 0
|
||||
#define EI_MAG1 1
|
||||
#define EI_MAG2 2
|
||||
#define EI_MAG3 3
|
||||
#define EI_CLASS 4
|
||||
#define EI_DATA 5
|
||||
#define EI_VERSION 6
|
||||
#define EI_PAD 7
|
||||
|
||||
/* Size of ELF identification field */
|
||||
#define EI_NIDENT 16
|
||||
|
||||
/* Values for ELF identification fields */
|
||||
#define ELFMAG0 0x7f
|
||||
#define ELFMAG1 'E'
|
||||
#define ELFMAG2 'L'
|
||||
#define ELFMAG3 'F'
|
||||
|
||||
/* Values for the ELF Class field */
|
||||
#define ELFCLASSNONE 0
|
||||
#define ELFCLASS32 1
|
||||
#define ELFCLASS64 2
|
||||
|
||||
/* Values for the ELF Data field */
|
||||
#define ELFDATANONE 0
|
||||
#define ELFDATA2LSB 1
|
||||
#define ELFDATA2MSB 2
|
||||
|
||||
|
||||
struct elf_header {
|
||||
u8 e_ident[EI_NIDENT]; /* ELF identification */
|
||||
u16 e_type; /* Object file type */
|
||||
u16 e_machine; /* Machine architecture */
|
||||
u32 e_version; /* Object file version */
|
||||
u32 e_entry; /* Virtual entry address */
|
||||
u32 e_phoff; /* Program header offset */
|
||||
u32 e_shoff; /* Section header offset */
|
||||
u32 e_flags; /* Processor specific flags */
|
||||
u16 e_ehsize; /* ELF header size */
|
||||
u16 e_phentsize; /* Program header entry size */
|
||||
u16 e_phnum; /* Number of program headers */
|
||||
u16 e_shentsize; /* Section header entry size */
|
||||
u16 e_shnum; /* Number of section headers */
|
||||
u16 e_shstrndx; /* Shtable index for strings */
|
||||
} __attribute__((__packed__));
|
||||
|
||||
|
||||
#endif /* __ELF_H__ */
|
||||
60
tasks/mm0/include/lib/elfsect.h
Normal file
60
tasks/mm0/include/lib/elfsect.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Definitions for ELF Sections
|
||||
* Based on Portable Formats Specification v1.1
|
||||
*
|
||||
* Copyright (C) 2008 Bahadir Balban
|
||||
*/
|
||||
|
||||
#ifndef __ELFSECT_H__
|
||||
#define __ELFSECT_H__
|
||||
|
||||
#include <l4/types.h>
|
||||
|
||||
/* Special section indices */
|
||||
#define SHN_UNDEF 0
|
||||
#define SHN_LORESERVE 0xFF00
|
||||
#define SHN_LOPROC 0xFF00
|
||||
#define SHN_HIPROC 0xFF1F
|
||||
#define SHN_ABS 0xFFF1
|
||||
#define SHN_COMMON 0xFFF2
|
||||
#define SHN_HIRESERVE 0xFFFF
|
||||
|
||||
|
||||
struct elf_section_header {
|
||||
u32 sh_name; /* Index to section header str table for name */
|
||||
u32 sh_type; /* Categorises section's semantics */
|
||||
u32 sh_flags; /* Flags that define various attributes */
|
||||
u32 sh_addr; /* Virtual address for section */
|
||||
u32 sh_offset; /* Offset to contents from file beginning */
|
||||
u32 sh_size; /* Size of section (note SHT_NOBITS) */
|
||||
u32 sh_link;
|
||||
u32 sh_info; /* Extra section info */
|
||||
u32 sh_addralign; /* Section alignment in power of 2 */
|
||||
u32 sh_entsize; /* Size of each entry if fixed */
|
||||
} __attribute__((__packed__));
|
||||
|
||||
/* Section type codes */
|
||||
#define SHT_NULL 0 /* Inactive */
|
||||
#define SHT_PROGBITS 1 /* Program contents */
|
||||
#define SHT_SYMTAB 2 /* Symbol table */
|
||||
#define SHT_STRTAB 3 /* String table */
|
||||
#define SHT_RELA 4 /* Relocation entries */
|
||||
#define SHT_HASH 5 /* Symbol hash table */
|
||||
#define SHT_DYNAMIC 6 /* Dynamic linking info */
|
||||
#define SHT_NOTE 7 /* Optional, additional info */
|
||||
#define SHT_NOBITS 8 /* Does not occupy file space */
|
||||
#define SHT_REL 9 /* Relocation entries */
|
||||
#define SHT_SHLIB 10 /* Reserved */
|
||||
#define SHT_DYNSYM 11 /* Symbols for dynamic linking */
|
||||
#define SHT_LOPROC 0x70000000 /* Reserved for processors */
|
||||
#define SHT_HIPROC 0x7FFFFFFF /* Reserved for processors */
|
||||
#define SHT_LOUSER 0x80000000 /* Reserved for user progs */
|
||||
#define SHT_HIUSER 0xFFFFFFFF /* Reserved for user progs */
|
||||
|
||||
/* Section attribute flags */
|
||||
#define SHF_WRITE (1 << 0) /* Writeable */
|
||||
#define SHF_ALLOC (1 << 1) /* Occupies actual memory */
|
||||
#define SHF_EXECINSTR (1 << 2) /* Executable */
|
||||
#define SHF_MASCPROC 0xF0000000 /* Reserved for processors */
|
||||
|
||||
#endif /* __ELFSECT_H__ */
|
||||
59
tasks/mm0/include/lib/elfsym.h
Normal file
59
tasks/mm0/include/lib/elfsym.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Definitions for ELF Symbol tables, symbols
|
||||
* Based on Portable Formats Specification v1.1
|
||||
*
|
||||
* Copyright (C) 2008 Bahadir Balban
|
||||
*/
|
||||
#ifndef __ELFSYM_H__
|
||||
#define __ELFSYM_H__
|
||||
|
||||
#include <l4/types.h>
|
||||
|
||||
struct elf_symbol_entry {
|
||||
u32 st_name; /* Index into string table */
|
||||
u32 st_value; /* Symbol value; address, aboslute etc. */
|
||||
u32 st_size; /* Number of bytes contained in object */
|
||||
u8 st_info; /* Type and binding attributes */
|
||||
u8 st_other; /* Unused, 0 */
|
||||
u16 st_shndx; /* Section header index associated with entry */
|
||||
} __attribute__((__packed__));
|
||||
|
||||
/* To manipulate binding and type attributes on st_info field */
|
||||
#define ELF32_ST_BIND(i) ((i) >> 4)
|
||||
#define ELF32_ST_TYPE(i) ((i) & 0xF)
|
||||
#define ELF32_ST_INFO(b, t) (((b) << 4) + ((t) & 0xF))
|
||||
|
||||
/* Symbol binding codes */
|
||||
#define STB_LOCAL 0
|
||||
#define STB_GLOBAL 1
|
||||
#define STB_WEAK 2
|
||||
#define STB_LOPROC 13
|
||||
#define STB_HIPROC 15
|
||||
|
||||
/* Symbol types */
|
||||
#define STT_NOTYPE 0
|
||||
#define STT_OBJECT 1
|
||||
#define STT_FUNC 2
|
||||
#define STT_SECTION 3
|
||||
#define STT_FILE 4
|
||||
#define STT_LOPROC 13
|
||||
#define STT_HIPROC 15
|
||||
|
||||
/* Relocation structures */
|
||||
struct elf_rel {
|
||||
u32 r_offset;
|
||||
u32 r_info;
|
||||
} __attribute__((__packed__));
|
||||
|
||||
struct elf_rela {
|
||||
u32 r_offset;
|
||||
u32 r_info;
|
||||
s32 r_addend;
|
||||
} __attribute__((__packed__));
|
||||
|
||||
/* Macros to manipulate r_info field */
|
||||
#define ELF32_R_SYM(i) ((i) >> 8)
|
||||
#define ELF32_R_TYPE(i) ((u8)(i))
|
||||
#define ELF32_R_INFO(s,t) (((s) << 8) + (u8)(t))
|
||||
|
||||
#endif /* __ELFSYM_H__ */
|
||||
@@ -31,6 +31,7 @@ int sys_shmdt(struct tcb *requester, const void *shmaddr);
|
||||
|
||||
int sys_shmget(key_t key, int size, int shmflg);
|
||||
|
||||
int sys_execve(struct tcb *sender, char *pathname, char *argv[], char *envp[]);
|
||||
int sys_fork(struct tcb *parent);
|
||||
int sys_clone(struct tcb *parent, void *child_stack, unsigned int clone_flags);
|
||||
void sys_exit(struct tcb *task, int status);
|
||||
|
||||
@@ -17,6 +17,9 @@
|
||||
|
||||
#define __TASKNAME__ __PAGERNAME__
|
||||
|
||||
#define ARGS_MAX DEFAULT_ENV_SIZE
|
||||
#define PATH_MAX PAGE_SIZE
|
||||
|
||||
#define TASK_FILES_MAX 32
|
||||
|
||||
/* POSIX minimum is 4Kb */
|
||||
|
||||
Reference in New Issue
Block a user