summaryrefslogtreecommitdiff
path: root/include/slibtool/slibtool_arbits.h
blob: 8ab8d0c95906984fb7fa55999bcd0da72d7083cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#ifndef SLIBTOOL_ARBITS_H
#define SLIBTOOL_ARBITS_H

#ifdef __cplusplus
extern "C" {
#endif

#include <stddef.h>

#define AR_SIGNATURE            "!<arch>\n"

#define AR_MEMBER_ATTR_DEFAULT  (0x00)
#define AR_MEMBER_ATTR_ASCII    (0x01)
#define AR_MEMBER_ATTR_UTF8     (0x02)
#define AR_MEMBER_ATTR_OBJECT   (0x04)
#define AR_MEMBER_ATTR_ARCHIVE  (0x08)
#define AR_MEMBER_ATTR_ARMAP    (0x10)
#define AR_MEMBER_ATTR_NAMESTRS (0x20)
#define AR_MEMBER_ATTR_LINKINFO (0x40)

#define AR_HEADER_ATTR_DEFAULT  (0x00)
#define AR_HEADER_ATTR_FILE_ID  (0x01)
#define AR_HEADER_ATTR_NAME_REF (0x02)
#define AR_HEADER_ATTR_BSD      (0x10)
#define AR_HEADER_ATTR_SYSV     (0x20)

#define AR_ARMAP_ATTR_PLAIN     (0x0000)
#define AR_ARMAP_ATTR_SORTED    (0x0001)
#define AR_ARMAP_ATTR_BSD       (0x0010)
#define AR_ARMAP_ATTR_SYSV      (0x0020)
#define AR_ARMAP_ATTR_COFF      (0x0040)
#define AR_ARMAP_ATTR_LE_32     (0x0100)
#define AR_ARMAP_ATTR_LE_64     (0x0200)
#define AR_ARMAP_ATTR_BE_32     (0x0400)
#define AR_ARMAP_ATTR_BE_64     (0x0800)

#define AR_OBJECT_ATTR_NONE     (0X0000)
#define AR_OBJECT_ATTR_ELF      (0x0001)
#define AR_OBJECT_ATTR_COFF     (0x0002)
#define AR_OBJECT_ATTR_MACHO    (0x0004)
#define AR_OBJECT_ATTR_LE_32    (0x0100)
#define AR_OBJECT_ATTR_LE_64    (0x0200)
#define AR_OBJECT_ATTR_BE_32    (0x0400)
#define AR_OBJECT_ATTR_BE_64    (0x0800)

struct ar_raw_signature {
	char    ar_signature                    [0x08];         /* 0x00 */
};

struct ar_raw_file_header {
	char    ar_file_id                      [0x10];         /* 0x00 */
	char    ar_time_date_stamp              [0x0c];         /* 0x10 */
	char    ar_uid                          [0x06];         /* 0x1c */
	char    ar_gid                          [0x06];         /* 0x22 */
	char    ar_file_mode                    [0x08];         /* 0x28 */
	char    ar_file_size                    [0x0a];         /* 0x30 */
	char    ar_end_tag                      [0x02];         /* 0x3a */
};

struct ar_raw_armap_ref_32 {
	unsigned char   ar_name_offset          [0x04];         /* 0x00 */
	unsigned char   ar_member_offset        [0x04];         /* 0x04 */
};

struct ar_raw_armap_ref_64 {
	unsigned char   ar_name_offset          [0x08];         /* 0x00 */
	unsigned char   ar_member_offset        [0x08];         /* 0x08 */
};

struct ar_raw_armap_bsd_32 {
	unsigned char   (*ar_size_of_refs)      [0x04];
	unsigned char   (*ar_first_name_offset) [0x04];
	unsigned char   (*ar_size_of_strs)      [0x04];
	const char *    (*ar_string_table);
};

struct ar_raw_armap_bsd_64 {
	unsigned char   (*ar_size_of_refs)      [0x08];
	unsigned char   (*ar_first_name_offset) [0x08];
	unsigned char   (*ar_size_of_strs)      [0x08];
	const char *    (*ar_string_table);
};

struct ar_raw_armap_sysv_32 {
	unsigned char   (*ar_num_of_syms)       [0x04];
	unsigned char   (*ar_first_ref_offset)  [0x04];
	const char *    (*ar_string_table);
};

struct ar_raw_armap_sysv_64 {
	unsigned char   (*ar_num_of_syms)       [0x08];
	unsigned char   (*ar_first_ref_offset)  [0x08];
	const char *    (*ar_string_table);
};

struct ar_raw_armap_xcoff_32 {
	unsigned char   (*ar_num_of_members)      [0x04];
	unsigned char   (*ar_first_member_offset) [0x04];
	unsigned char   (*ar_num_of_symbols)      [0x04];
	unsigned char   (*ar_sym_member_indices)  [0x02];
	char            (*ar_string_table)        [];
};

struct ar_meta_signature {
	const char *    ar_signature;
};

struct ar_meta_file_header {
	const char *    ar_member_name;
	uint32_t        ar_header_attr;
	uint32_t        ar_uid;
	uint32_t        ar_gid;
	uint32_t        ar_file_mode;
	uint64_t        ar_file_size;
	uint64_t        ar_time_date_stamp;
};

struct ar_meta_member_info {
	struct ar_meta_file_header      ar_file_header;
	struct ar_raw_file_header *     ar_member_data;
	uint32_t                        ar_member_attr;
	uint32_t                        ar_object_attr;
	uint64_t                        ar_object_size;
	void *                          ar_object_data;
};

struct ar_meta_armap_ref_32 {
	uint32_t                        ar_name_offset;
	uint32_t                        ar_member_offset;
};

struct ar_meta_armap_ref_64 {
	uint64_t                        ar_name_offset;
	uint64_t                        ar_member_offset;
};

struct ar_meta_armap_common_32 {
	struct ar_meta_member_info *    ar_member;
	struct ar_meta_armap_ref_32 *   ar_symrefs;
	struct ar_raw_armap_bsd_32 *    ar_armap_bsd;
	struct ar_raw_armap_sysv_32 *   ar_armap_sysv;
	struct ar_raw_armap_xcoff_32 *  ar_armap_xcoff;
	uint32_t                        ar_armap_attr;
	uint32_t                        ar_num_of_symbols;
	uint32_t                        ar_num_of_members;
	uint32_t                        ar_first_member_offset;
	uint32_t                        ar_size_of_refs;
	uint32_t                        ar_size_of_strs;
	uint16_t *                      ar_sym_member_indices;
	const char *                    ar_string_table;
};

struct ar_meta_armap_common_64 {
	struct ar_meta_member_info *    ar_member;
	struct ar_meta_armap_ref_64 *   ar_symrefs;
	struct ar_raw_armap_bsd_64 *    ar_armap_bsd;
	struct ar_raw_armap_sysv_64 *   ar_armap_sysv;
	void *                          ar_armap_xcoff;
	uint32_t                        ar_armap_attr;
	uint64_t                        ar_num_of_symbols;
	uint64_t                        ar_num_of_members;
	uint64_t                        ar_first_member_offset;
	uint64_t                        ar_size_of_refs;
	uint64_t                        ar_size_of_strs;
	uint16_t *                      ar_sym_member_indices;
	const char *                    ar_string_table;
};

struct ar_meta_symbol_info {
	const char *                    ar_archive_name;
	const char *                    ar_object_name;
	const char *                    ar_symbol_name;
	const char *                    ar_symbol_type;
	uint64_t                        ar_symbol_value;
	uint64_t                        ar_symbol_size;
};

struct ar_meta_armap_info {
	const struct ar_meta_armap_common_32 *  ar_armap_common_32;
	const struct ar_meta_armap_common_64 *  ar_armap_common_64;
};

#ifdef __cplusplus
}
#endif

#endif