Subversion Repositories Kolibri OS

Rev

Rev 6613 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6613 Rev 7597
Line 1... Line 1...
1
(*
1
(*
2
    Copyright 2016 Anton Krotov
2
    BSD 2-Clause License
Line 3... Line 3...
3
 
3
 
4
    This file is part of Compiler.
-
 
5
 
-
 
6
    Compiler is free software: you can redistribute it and/or modify
-
 
7
    it under the terms of the GNU General Public License as published by
-
 
8
    the Free Software Foundation, either version 3 of the License, or
4
    Copyright (c) 2019, Anton Krotov
9
    (at your option) any later version.
-
 
10
 
-
 
11
    Compiler is distributed in the hope that it will be useful,
-
 
12
    but WITHOUT ANY WARRANTY; without even the implied warranty of
-
 
13
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-
 
14
    GNU General Public License for more details.
-
 
15
 
-
 
16
    You should have received a copy of the GNU General Public License
-
 
17
    along with Compiler. If not, see .
5
    All rights reserved.
Line 18... Line 6...
18
*)
6
*)
Line -... Line 7...
-
 
7
 
-
 
8
MODULE ELF;
-
 
9
 
-
 
10
IMPORT BIN, WR := WRITER, CHL := CHUNKLISTS;
-
 
11
 
-
 
12
 
-
 
13
CONST
19
 
14
 
-
 
15
    EI_NIDENT = 16;
-
 
16
    ET_EXEC = 2;
-
 
17
    ET_DYN = 3;
-
 
18
 
-
 
19
    EM_386 = 3;
-
 
20
    EM_8664 = 3EH;
-
 
21
 
-
 
22
    ELFCLASS32 = 1;
-
 
23
    ELFCLASS64 = 2;
-
 
24
 
-
 
25
    ELFDATA2LSB = 1;
-
 
26
    ELFDATA2MSB = 2;
-
 
27
 
-
 
28
    PF_X = 1;
-
 
29
    PF_W = 2;
-
 
30
    PF_R = 4;
-
 
31
 
-
 
32
 
-
 
33
TYPE
-
 
34
 
-
 
35
    Elf32_Ehdr = RECORD
-
 
36
 
-
 
37
        e_ident: ARRAY EI_NIDENT OF BYTE;
-
 
38
 
-
 
39
        e_type,
-
 
40
        e_machine: WCHAR;
-
 
41
 
-
 
42
        e_version,
-
 
43
        e_entry,
-
 
44
        e_phoff,
-
 
45
        e_shoff,
-
 
46
        e_flags: INTEGER;
-
 
47
 
-
 
48
        e_ehsize,
-
 
49
        e_phentsize,
-
 
50
        e_phnum,
-
 
51
        e_shentsize,
-
 
52
        e_shnum,
-
 
53
        e_shstrndx: WCHAR
-
 
54
 
-
 
55
    END;
-
 
56
 
-
 
57
 
-
 
58
    Elf32_Phdr = RECORD
-
 
59
 
-
 
60
        p_type,
-
 
61
        p_offset,
-
 
62
        p_vaddr,
-
 
63
        p_paddr,
-
 
64
        p_filesz,
Line 20... Line 65...
20
MODULE ELF;
65
        p_memsz,
Line -... Line 66...
-
 
66
        p_flags,
-
 
67
        p_align: INTEGER
-
 
68
 
-
 
69
    END;
-
 
70
 
-
 
71
    FILE = WR.FILE;
-
 
72
 
-
 
73
 
-
 
74
PROCEDURE align (n, _align: INTEGER): INTEGER;
-
 
75
BEGIN
-
 
76
    IF n MOD _align # 0 THEN
-
 
77
        n := n + _align - (n MOD _align)
-
 
78
    END
21
 
79
 
22
IMPORT SYSTEM;
80
    RETURN n
Line 289... Line 376...
289
END data;
376
    END;
290
 
377
    CHL.WriteToFile(File, program.data);