/*
** ppc.library emulation
** (c)1998-99 Frank Wille <frank@phoenix.owl.de>
**
** ELF object functions (loading, unloading, info)
**
** V0.6d (13.05.1999) phx
**       ElfObjF_Executed is set, when ElfObject was executed. Other-
**       wise the .text and .data sections don't need to be reloaded.
** V0.1  (15.11.1998) phx
**       First partially working ppc.library emulation. Synchronous PPC
**       tasks, started by runelf, which only use the basic PowerUp kernel
**       functions for I/O, memory and context-switch seem to work fine.
** V0.0  (01.11.1998) phx
**       created
*/

#ifndef ELFOBJECT_H
#define ELFOBJECT_H

#include "elf32.h"


struct ELFSection {                     /* prog. sections for new tasks */
  char *name;
  APTR address;                         /* physical RAM address or NULL */
  UWORD flags;
  UWORD alignment;
  long offset;                          /* file offset and section size */
  ULONG size;
  int nrel;                             /* number of relocs */
  struct Elf32_Rela *relocs;            /* array of Elf32_Rela structs */
};

#define ElfSecB_NOBITS          0       /* bss section */
#define ElfSecF_NOBITS          1
#define ElfSecB_RELA            1       /* Relocs are of .rela type */
#define ElfSecF_RELA            2


struct ElfObject {
  struct Node n;                        /* contains object's name ptr */
  UWORD flags;
  struct PPCLibBase *ppcbase;
  void *pool;                           /* pooled memory for object data */
  APTR handle;                          /* ELF file handle */
  struct Hook *hook;                    /* hook functions for read/seek */
  struct Hook defaultHook;
  char *secnames;                       /* .shstrtab - section names */
  char *symnames;                       /* .strtab - symbol mames */
  struct Elf32_Ehdr *header;            /* the ELF file header */
  struct Elf32_Sym *symtab;             /* .symtab - symbol table */
  uint32 nsyms;                         /* number of symbols */
  uint32 gsyms;                         /* first global symbol */
  struct ELFSection **sections;         /* ELFSection pointers */
  uint32 nsects;                        /* number of sections */
  struct SignalSemaphore ElfSS;         /* ElfObject access arbitration */
};

#define ElfObjB_Relocated       0       /* Object is relocated */
#define ElfObjF_Relocated       1
#define ElfObjB_Executed        1       /* Object was executed */
#define ElfObjF_Executed        2


#endif /* ELFOBJECT_H */
