1// Derived from code in LLVM, which is:
2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
3// See https://llvm.org/LICENSE.txt for license information.
4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5
6// Derived from https://github.com/llvm/llvm-project/blob/8ef3e895ad8ab1724e2b87cabad1dacdc7a397a3/llvm/include/llvm/Object/Archive.h
7
8/// Size field is 10 decimal digits long
9pub(crate) const MAX_MEMBER_SIZE: u64 = 9999999999;
10
11#[derive(Copy, Clone, Debug, PartialEq)]
12pub enum ArchiveKind {
13 Gnu,
14 Gnu64,
15 Bsd,
16 Darwin,
17 Darwin64,
18 Coff,
19 AixBig,
20}
21
22pub(crate) mod big_archive {
23 #[repr(C)]
24 pub(crate) struct BigArMemHdrType {
25 /// File member size in decimal
26 size: [u8; 20],
27
28 /// Next member offset in decimal
29 next_offset: [u8; 20],
30
31 /// Previous member offset in decimal
32 prev_offset: [u8; 20],
33
34 last_modified: [u8; 12],
35
36 uid: [u8; 12],
37 gid: [u8; 12],
38
39 access_mode: [u8; 12],
40
41 /// File member name length in decimal
42 name_len: [u8; 4],
43
44 terminator: [u8; 2],
45 }
46
47 /// Fixed-Length Header.
48 #[repr(C)]
49 pub(crate) struct FixLenHdr {
50 /// Big archive magic string.
51 magic: [u8; 8],
52
53 /// Offset to member table.
54 mem_offset: [u8; 20],
55
56 /// Offset to global symbol table.
57 glob_sym_offset: [u8; 20],
58
59 /// Offset global symbol table for 64-bit objects.
60 glob_sym64_offset: [u8; 20],
61
62 /// Offset to first archive member.
63 first_child_offset: [u8; 20],
64
65 /// Offset to last archive member.
66 last_child_offset: [u8; 20],
67
68 /// Offset to first mem on free list.
69 free_offset: [u8; 20],
70 }
71}
72