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

Subversion Repositories forwardcom

[/] [forwardcom/] [bintools/] [library.h] - Blame information for rev 54

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

Line No. Rev Author Line
1 35 Agner
/****************************  library.h   ********************************
2
* Author:        Agner Fog
3
* date created:  2017-11-08
4
* Last modified: 2018-03-30
5
* Version:       1.10
6
* Project:       Binary tools for ForwardCom instruction set
7
* Module:        library.h
8
* Description:
9
* header file for library manager
10
*
11
* Copyright 2017-2020 GNU General Public License http://www.gnu.org/licenses
12
*****************************************************************************/
13
 
14
// Structure for list of library members
15
struct SLibMember {
16
    uint32_t name;                     // member name as index into cmd.fileNameBuffer
17
    uint32_t oldOffset;                // offset in old library file
18
    uint32_t newOffset;                // offset in new library file
19
    uint32_t size;                     // size, not including library header
20
    uint32_t action;                   // 1: preserve, 2: add or replace, 3: delete, 5: extract
21
};
22
 
23
 
24
// operator < for sorting library member list by name
25
static inline bool operator < (SLibMember const & a, SLibMember const & b) {
26
    return strcmp(cmd.getFilename(a.name), cmd.getFilename(b.name)) < 0;
27
}
28
 
29
// remove path from file name
30
const char * removePath(const char * filename);
31
 
32
// Class for extracting members from library or building a library
33
class CLibrary : public CFileBuffer {
34
public:
35
    CLibrary();                                  // Constructor
36
    void go();                                   // Do whatever the command line says
37
    const char * getMemberName(uint32_t memberOffset); // Get name of a library member
38
    uint32_t getMemberSize(uint32_t memberOffset); // get size of a library member
39
    void findLongNames();                        // Find longNames record
40
    uint32_t findSymbol(const char * name);      // Find exported symbol in library
41
    bool isForwardCom();                         // check if this is a ForwardCom library
42
    void addELF(CELF & elf);                     // make library from CELF modules during relinking
43
    void makeInternalLibrary();                  // make a library for internal use during relinking
44
    uint32_t findMember(uint32_t name);          // Find a module. name is an index into cmd.fileNameBuffer
45
    uint32_t libraryName;                        // file name as index into cmd.fileNameBuffer
46
    bool relinkable;                             // library can be replaced by relinking
47
protected:
48
    void checkActionList();                      // Check action list for errors
49
    void makeMemberList();                       // Make list of library member names
50
    void runActionList();                        // Run through commands from command line
51
    void addMember(uint32_t filename, uint32_t membername); // Add object file to library member list
52
    void deleteMember(uint32_t membername);      // Add object file to library
53
    void extractMember(uint32_t filename, uint32_t membername); // Extract member from library
54
    void extractAllMembers();                    // Extract all members from library
55
    void listMembers();                          // List all library members
56
    void generateNewLibraryBody();               // Generate data contents of new library from old one and additional object files
57
    void makeBinaryFile();                       // Make library header, symbol table, longnames record, data
58
    void checkDuplicateSymbols(CDynamicArray<SSymbolEntry>& symbolList);// Check if symbollist contains duplicate names
59
    int32_t  alignBy;                            // member alignment = 4
60
    uint32_t longNames;                          // offset to long names record
61
    uint32_t longNamesSize;                      // size of long names record
62
    CDynamicArray<SLibMember> members;           // list of member names
63
    CFileBuffer outFile;                         // Buffer for building output file
64
    CELF memberBuffer;                           // Buffer containing single library member
65
    CMemoryBuffer dataBuffer;                    // Buffer containing raw members
66
    //friend class CLinker;
67
};

powered by: WebSVN 2.1.0

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