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 2

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 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 "elf_types.h"
16
 
17
namespace debugger {
18
 
19
class ElfReaderService : public IService,
20
                         public IElfReader {
21
public:
22
    explicit ElfReaderService(const char *name);
23
    virtual ~ElfReaderService();
24
 
25
    /** IService interface */
26
    virtual void postinitService();
27
 
28
    /** IElfReader interface */
29
    virtual int readFile(const char *filename);
30
 
31
    virtual unsigned loadableSectionTotal() {
32
        return loadSectionList_.size();
33
    }
34
 
35
    virtual const char *sectionName(unsigned idx) {
36
        return loadSectionList_[idx][LoadSh_name].to_string();
37
    }
38
 
39
    virtual uint64_t sectionAddress(unsigned idx)  {
40
        return loadSectionList_[idx][LoadSh_addr].to_uint64();
41
    }
42
 
43
    virtual uint64_t sectionSize(unsigned idx)  {
44
        return loadSectionList_[idx][LoadSh_size].to_uint64();
45
    }
46
 
47
    virtual uint8_t *sectionData(unsigned idx)  {
48
        return loadSectionList_[idx][LoadSh_data].data();
49
    }
50
 
51
    virtual void getSymbols(AttributeType *list) { *list = symbolList_; }
52
 
53
    virtual void addressToSymbol(uint64_t addr, AttributeType *info);
54
 
55
private:
56
    int readElfHeader();
57
    int loadSections();
58
    void processStringTable(SectionHeaderType *sh);
59
    void processDebugSymbol(SectionHeaderType *sh);
60
 
61
private:
62
    enum ELoadSectionItem {
63
        LoadSh_name,
64
        LoadSh_addr,
65
        LoadSh_size,
66
        LoadSh_data,
67
        LoadSh_Total,
68
    };
69
 
70
    AttributeType symbolList_;
71
    AttributeType symbolListSortByAddr_;
72
    AttributeType loadSectionList_;
73
 
74
    uint8_t *image_;
75
    ElfHeaderType *header_;
76
    SectionHeaderType *sh_tbl_;
77
    char *sectionNames_;
78
    char *symbolNames_;
79
};
80
 
81
DECLARE_CLASS(ElfReaderService)
82
 
83
}  // namespace debugger
84
 
85
#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.