OpenCores
URL https://opencores.org/ocsvn/riscv_vhdl/riscv_vhdl/trunk

Subversion Repositories riscv_vhdl

[/] [riscv_vhdl/] [trunk/] [debugger/] [src/] [libdbg64g/] [services/] [elfloader/] [elfreader.h] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 sergeykhbr
/**
2
 * @file
3
 * @copyright  Copyright 2016 GNSS Sensor Ltd. All right reserved.
4
 * @author     Sergey Khabarov - sergeykhbr@gmail.com
5
 * @brief      elf-file loader class declaration.
6
 */
7
 
8
#ifndef __DEBUGGER_ELF_LOADER_H__
9
#define __DEBUGGER_ELF_LOADER_H__
10
 
11
#include "iclass.h"
12
#include "iservice.h"
13
#include "coreservices/itap.h"
14
#include "coreservices/ielfreader.h"
15
#include "coreservices/isrccode.h"
16
#include "elf_types.h"
17
 
18
namespace debugger {
19
 
20
class ElfReaderService : public IService,
21
                         public IElfReader {
22
public:
23
    explicit ElfReaderService(const char *name);
24
    virtual ~ElfReaderService();
25
 
26
    /** IService interface */
27
    virtual void postinitService();
28
 
29
    /** IElfReader interface */
30
    virtual int readFile(const char *filename);
31
 
32
    virtual unsigned loadableSectionTotal() {
33
        return loadSectionList_.size();
34
    }
35
 
36
    virtual const char *sectionName(unsigned idx) {
37
        return loadSectionList_[idx][LoadSh_name].to_string();
38
    }
39
 
40
    virtual uint64_t sectionAddress(unsigned idx)  {
41
        return loadSectionList_[idx][LoadSh_addr].to_uint64();
42
    }
43
 
44
    virtual uint64_t sectionSize(unsigned idx)  {
45
        return loadSectionList_[idx][LoadSh_size].to_uint64();
46
    }
47
 
48
    virtual uint8_t *sectionData(unsigned idx)  {
49
        return loadSectionList_[idx][LoadSh_data].data();
50
    }
51
 
52
private:
53
    int readElfHeader();
54
    int loadSections();
55
    void processDebugSymbol(SectionHeaderType *sh);
56
 
57
private:
58
    enum ELoadSectionItem {
59
        LoadSh_name,
60
        LoadSh_addr,
61
        LoadSh_size,
62
        LoadSh_data,
63
        LoadSh_Total,
64
    };
65
 
66
    enum EMode {
67
        Mode_32bits,
68
        Mode_64bits
69
    } emode_;
70
 
71
    AttributeType sourceProc_;
72
    AttributeType symbolList_;
73
    AttributeType loadSectionList_;
74
 
75
    ISourceCode *isrc_;
76
    uint8_t *image_;
77
    ElfHeaderType *header_;
78
    SectionHeaderType **sh_tbl_;
79
    char *sectionNames_;
80
    char *symbolNames_;
81
};
82
 
83
DECLARE_CLASS(ElfReaderService)
84
 
85
}  // namespace debugger
86
 
87
#endif  // __DEBUGGER_ELF_LOADER_H__

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.