root/tools/elf2flt/elfflt.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


   1 #ifndef __ELFFLT_H__
   2 #define __ELFFLT_H__
   3 
   4 #include <unistd.h>
   5 #include "elf.h"
   6 #define USE_INT32_FOR_PTRS      // To avoid pointer size issues in structs in flt.h
   7 #include "flt.h"
   8 
   9 #define ELFFLT_OK                  0
  10 #define ELFFLT_BAD_ELF_HEADER      1
  11 #define ELFFLT_NO_SYMTAB           2
  12 #define ELFFLT_NO_STRTAB           3
  13 #define ELFFLT_NO_TEXT             4
  14 #define ELFFLT_SYMBOL_NOT_FOUND    5
  15 #define ELFFLT_SEGMENT_NOT_FOUND   6
  16 #define ELFFLT_NO_MODULEINFO       7
  17 #define ELFFLT_UNHANDLED_RELOC     8
  18 #define ELFFLT_OUTOF_RANGE         9
  19 #define ELFFLT_INPUT_ERROR         10
  20 #define ELFFLT_OUTPUT_ERROR        11
  21 #define ELFFLT_UNSAFE_SYMBOL       12
  22 
  23 /**
  24  * \brief      Load and relocate an ELF file.
  25  */
  26 int elfloader_load(char* fltfile );
  27 
  28 
  29 struct relevant_section {
  30   unsigned char number;     //#of section
  31   uint32_t offset;              //start offset in .elf file
  32   char *address;            //ptr in memory
  33 
  34   int size;
  35   char *name;           //name
  36   uint32_t base_addr;   //start addr in arm-objdump (to compare)
  37   uint32_t flat_offset; //start offset in .flt file
  38   
  39   uint32_t relaoff;             // fileoffset of related relocation section
  40   uint32_t relasize;    // size of related relocation section
  41 };
  42 
  43 extern struct relevant_section bss, data, rodata, text;
  44 
  45 extern char* flat_buf;
  46 extern flat_hdr* flat;
  47 
  48 typedef uint32_t reloc_record_t;
  49 
  50 extern uint32_t flat_reloc_count;
  51 extern reloc_record_t *flat_reloc;
  52 extern reloc_record_t *flat_reloc_cur;
  53 
  54 typedef struct
  55 {
  56     uint32_t offs;                      // offset of changed record from begin of flat
  57         uint32_t importidx;     // index of symbol in chdk_export_table
  58 } import_record_t;
  59 
  60 extern uint32_t flat_import_count;
  61 extern import_record_t* flat_import_buf; // point to begining of import table in memory
  62 extern import_record_t* flat_import_cur; // ptr to current import value (for write_import)
  63 
  64 extern unsigned int strtaboff;
  65 extern unsigned int symtaboff;
  66 
  67 
  68 int apply_realloc( struct relevant_section* base_sect, 
  69                    struct elf32_rela *rela, 
  70                    struct relevant_section* tgt_sect, 
  71                    struct elf32_sym *sym,
  72            int symidx
  73                  );
  74 
  75 int apply_import( struct relevant_section* base_sect, 
  76                    struct elf32_rela *rela, 
  77                    int importidx, 
  78                    struct elf32_sym *sym
  79                  );
  80 
  81 #endif /* __ELFFLT_H__ */
  82 

/* [<][>][^][v][top][bottom][index][help] */