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

Subversion Repositories lxp32

[/] [lxp32/] [trunk/] [tools/] [src/] [lxp32asm/] [linker.h] - Blame information for rev 2

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

Line No. Rev Author Line
1 2 ring0_mipt
/*
2
 * Copyright (c) 2016 by Alex I. Kuznetsov.
3
 *
4
 * Part of the LXP32 CPU IP core.
5
 *
6
 * This module defines the Linker class which performs
7
 * linking of LXP32 binary objects.
8
 */
9
 
10
#ifndef LINKER_H_INCLUDED
11
#define LINKER_H_INCLUDED
12
 
13
#include "linkableobject.h"
14
#include "outputwriter.h"
15
 
16
#include <iostream>
17
#include <map>
18
#include <vector>
19
#include <string>
20
 
21
class Linker {
22
        struct GlobalSymbolData {
23
                LinkableObject *obj=nullptr;
24
                LinkableObject::Word rva=0;
25
                std::multimap<const LinkableObject*,LinkableObject::Word> refs;
26
        };
27
 
28
        std::vector<LinkableObject*> _objects;
29
        LinkableObject *_entryObject;
30
        std::map<std::string,GlobalSymbolData> _globalSymbolTable;
31
 
32
// Various output options
33
        LinkableObject::Word _base=0;
34
        std::size_t _align=4;
35
        std::size_t _imageSize=0;
36
public:
37
        void addObject(LinkableObject &obj);
38
        void link(OutputWriter &writer);
39
        void setBase(LinkableObject::Word base);
40
        void setAlignment(std::size_t align);
41
        void setImageSize(std::size_t size);
42
private:
43
        void buildSymbolTable();
44
        void placeObjects();
45
        void relocateObject(LinkableObject *obj);
46
        void writeObjects(OutputWriter &writer);
47
};
48
 
49
#endif

powered by: WebSVN 2.1.0

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