llvm.org GIT mirror llvm / 206252c
Adding changes to support GNU style archive library reading git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167853 91177308-0d34-0410-b5e6-96231b3b80d8 Shankar Easwaran 7 years ago
9 changed file(s) with 431 addition(s) and 26 deletion(s). Raw diff Collapse all Expand all
121121
122122 Archive(MemoryBuffer *source, error_code &ec);
123123
124 enum Kind {
125 K_GNU,
126 K_BSD,
127 K_COFF
128 };
129
130 Kind kind() const {
131 return Format;
132 }
133
124134 child_iterator begin_children(bool skip_internal = true) const;
125135 child_iterator end_children() const;
126136
132142 return v->isArchive();
133143 }
134144
145 // check if a symbol is in the archive
146 child_iterator findSym(StringRef name) const;
147
135148 private:
136149 child_iterator SymbolTable;
137150 child_iterator StringTable;
151 Kind Format;
138152 };
139153
140154 }
121121 + sizeof(ArchiveMemberHeader)
122122 + Parent->StringTable->getSize()))
123123 return object_error::parse_failed;
124 Result = addr;
124
125 // GNU long file names end with a /.
126 if (Parent->kind() == K_GNU) {
127 StringRef::size_type End = StringRef(addr).find('/');
128 Result = StringRef(addr, End);
129 } else {
130 Result = addr;
131 }
125132 return object_error::success;
126133 } else if (name.startswith("#1/")) {
127134 APInt name_size;
186193 child_iterator i = begin_children(false);
187194 child_iterator e = end_children();
188195
189 if (i != e) ++i; // Nobody cares about the first member.
190 if (i != e) {
196 StringRef name;
197 if ((ec = i->getName(name)))
198 return;
199
200 // Below is the pattern that is used to figure out the archive format
201 // GNU archive format
202 // First member : / (points to the symbol table )
203 // Second member : // (may exist, if it exists, points to the string table)
204 // Note : The string table is used if the filename exceeds 15 characters
205 // BSD archive format
206 // First member : __.SYMDEF (points to the symbol table)
207 // There is no string table, if the filename exceeds 15 characters or has a
208 // embedded space, the filename has #1/, The size represents the size
209 // of the filename that needs to be read after the archive header
210 // COFF archive format
211 // First member : /
212 // Second member : / (provides a directory of symbols)
213 // Third member : // contains the string table, this is present even if the
214 // string table is empty
215 if (name == "/") {
191216 SymbolTable = i;
192 ++i;
193 }
194 if (i != e) {
195 StringTable = i;
196 }
197
217 StringTable = e;
218 if (i != e) ++i;
219 if ((ec = i->getName(name)))
220 return;
221 if (name[0] != '/') {
222 Format = K_GNU;
223 } else if ((name.size() > 1) && (name == "//")) {
224 Format = K_GNU;
225 StringTable = i;
226 ++i;
227 } else {
228 Format = K_COFF;
229 if (i != e) {
230 SymbolTable = i;
231 ++i;
232 }
233 if (i != e) {
234 StringTable = i;
235 }
236 }
237 } else if (name == "__.SYMDEF") {
238 Format = K_BSD;
239 SymbolTable = i;
240 StringTable = e;
241 }
198242 ec = object_error::success;
199243 }
200244
221265
222266 error_code Archive::Symbol::getMember(child_iterator &Result) const {
223267 const char *buf = Parent->SymbolTable->getBuffer()->getBufferStart();
224 uint32_t member_count = *reinterpret_cast(buf);
225268 const char *offsets = buf + 4;
226 buf += 4 + (member_count * 4); // Skip offsets.
227 const char *indicies = buf + 4;
228
229 uint16_t offsetindex =
230 *(reinterpret_cast(indicies)
231 + SymbolIndex);
232
233 uint32_t offset = *(reinterpret_cast(offsets)
234 + (offsetindex - 1));
269 uint32_t offset = 0;
270 if (Parent->kind() == K_GNU) {
271 offset = *(reinterpret_cast(offsets)
272 + SymbolIndex);
273 } else if (Parent->kind() == K_BSD) {
274 assert("BSD format is not supported");
275 } else {
276 uint32_t member_count = 0;
277 member_count = *reinterpret_cast(buf);
278 buf += 4 + (member_count * 4); // Skip offsets.
279 const char *indicies = buf + 4;
280 uint16_t offsetindex =
281 *(reinterpret_cast(indicies)
282 + SymbolIndex);
283 uint32_t *offsetaddr =
284 (uint32_t *)(reinterpret_cast(offsets)
285 + (offsetindex - 1));
286 assert((const char *)offsetaddr <
287 Parent->SymbolTable->getBuffer()->getBufferEnd());
288 offset = *(offsetaddr);
289 }
235290
236291 const char *Loc = Parent->getData().begin() + offset;
237292 size_t Size = sizeof(ArchiveMemberHeader) +
252307
253308 Archive::symbol_iterator Archive::begin_symbols() const {
254309 const char *buf = SymbolTable->getBuffer()->getBufferStart();
255 uint32_t member_count = *reinterpret_cast(buf);
256 buf += 4 + (member_count * 4); // Skip offsets.
257 uint32_t symbol_count = *reinterpret_cast(buf);
258 buf += 4 + (symbol_count * 2); // Skip indices.
310 if (kind() == K_GNU) {
311 uint32_t symbol_count = 0;
312 symbol_count = *reinterpret_cast(buf);
313 buf += sizeof(uint32_t) + (symbol_count * (sizeof(uint32_t)));
314 } else if (kind() == K_BSD) {
315 assert("BSD archive format is not supported");
316 } else {
317 uint32_t member_count = 0;
318 uint32_t symbol_count = 0;
319 member_count = *reinterpret_cast(buf);
320 buf += 4 + (member_count * 4); // Skip offsets.
321 symbol_count = *reinterpret_cast(buf);
322 buf += 4 + (symbol_count * 2); // Skip indices.
323 }
259324 uint32_t string_start_offset =
260325 buf - SymbolTable->getBuffer()->getBufferStart();
261326 return symbol_iterator(Symbol(this, 0, string_start_offset));
263328
264329 Archive::symbol_iterator Archive::end_symbols() const {
265330 const char *buf = SymbolTable->getBuffer()->getBufferStart();
266 uint32_t member_count = *reinterpret_cast(buf);
267 buf += 4 + (member_count * 4); // Skip offsets.
268 uint32_t symbol_count = *reinterpret_cast(buf);
331 uint32_t symbol_count = 0;
332 if (kind() == K_GNU) {
333 symbol_count = *reinterpret_cast(buf);
334 buf += sizeof(uint32_t) + (symbol_count * (sizeof(uint32_t)));
335 } else if (kind() == K_BSD) {
336 assert("BSD archive format is not supported");
337 } else {
338 uint32_t member_count = 0;
339 member_count = *reinterpret_cast(buf);
340 buf += 4 + (member_count * 4); // Skip offsets.
341 symbol_count = *reinterpret_cast(buf);
342 }
269343 return symbol_iterator(
270344 Symbol(this, symbol_count, 0));
271345 }
346
347 Archive::child_iterator Archive::findSym(StringRef name) const {
348 Archive::symbol_iterator bs = begin_symbols();
349 Archive::symbol_iterator es = end_symbols();
350 Archive::child_iterator result;
351
352 StringRef symname;
353 for (; bs != es; ++bs) {
354 if (bs->getName(symname))
355 return end_children();
356 if (symname == name) {
357 if (bs->getMember(result))
358 return end_children();
359 return result;
360 }
361 }
362 return end_children();
363 }
0 #
1 # Check if the index is appearing properly in the output file
2 #
3 RUN: llvm-nm -s %p/Inputs/liblong_filenames.a | FileCheck -check-prefix=CHECKIDX %s
4
5 CHECKIDX: Archive map
6 CHECKIDX: abcdefghijklmnopqrstuvwxyz12345678 in 1.o
7 CHECKIDX: main in 1.o
8 CHECKIDX: fn1 in 2.o
9 CHECKIDX: fn3 in 3.o
10 CHECKIDX: fn1 in 3.o
11 CHECKIDX: shankar in 4.o
12 CHECKIDX: a in 5.o
13 CHECKIDX: b in 6.o
14 CHECKIDX: a in abcdefghijklmnopqrstuvwxyz1.o
15 CHECKIDX: b in abcdefghijklmnopqrstuvwxyz2.o
16 CHECKIDX: bda in abcdefghijklmnopqrstuvwxyz2.o
17 CHECKIDX: b in abcdefghijklmnopq.o
18 CHECKIDX: 1.o:
19 CHECKIDX: 00000000 D abcdefghijklmnopqrstuvwxyz12345678
20 CHECKIDX: U bda
21 CHECKIDX: 00000000 T main
22 CHECKIDX: 2.o:
23 CHECKIDX: 00000000 T fn1
24 CHECKIDX: 3.o:
25 CHECKIDX: 0000000b T fn1
26 CHECKIDX: 00000000 T fn3
27 CHECKIDX: 4.o:
28 CHECKIDX: C shankar
29 CHECKIDX: 5.o:
30 CHECKIDX: C a
31 CHECKIDX: 6.o:
32 CHECKIDX: C b
33 CHECKIDX: abcdefghijklmnopqrstuvwxyz1.o:
34 CHECKIDX: C a
35 CHECKIDX: abcdefghijklmnopqrstuvwxyz2.o:
36 CHECKIDX: C b
37 CHECKIDX: 00000000 T bda
38 CHECKIDX: abcdefghijklmnopq.o:
39 CHECKIDX: C b
0 #
1 # Check if the index is appearing properly in the output file
2 #
3 RUN: llvm-nm -s %p/Inputs/coff_archive.lib | FileCheck -check-prefix=CHECKIDX %s
4
5 CHECKIDX: Archive map
6 CHECKIDX: ??0invalid_argument@std@@QAE@PBD@Z in Debug\mymath.obj
7 CHECKIDX: ??0logic_error@std@@QAE@PBD@Z in Debug\mymath.obj
8 CHECKIDX: ??1invalid_argument@std@@UAE@XZ in Debug\mymath.obj
9 CHECKIDX: ??1logic_error@std@@UAE@XZ in Debug\mymath.obj
10 CHECKIDX: ??_7invalid_argument@std@@6B@ in Debug\mymath.obj
11 CHECKIDX: ??_7logic_error@std@@6B@ in Debug\mymath.obj
12 CHECKIDX: ??_C@_0BC@IHENMCGI@b?5cannot?5be?5zero?$CB?$AA@ in Debug\mymath.obj
13 CHECKIDX: ??_Ginvalid_argument@std@@UAEPAXI@Z in Debug\mymath.obj
14 CHECKIDX: ??_Glogic_error@std@@UAEPAXI@Z in Debug\mymath.obj
15 CHECKIDX: ??_R0?AVexception@std@@@8 in Debug\mymath.obj
16 CHECKIDX: ??_R0?AVinvalid_argument@std@@@8 in Debug\mymath.obj
17 CHECKIDX: ??_R0?AVlogic_error@std@@@8 in Debug\mymath.obj
18 CHECKIDX: ??_R0PAVexception@std@@@8 in Debug\mymath.obj
19 CHECKIDX: ??_R0PAVinvalid_argument@std@@@8 in Debug\mymath.obj
20 CHECKIDX: ??_R0PAVlogic_error@std@@@8 in Debug\mymath.obj
21 CHECKIDX: ??_R0PAX@8 in Debug\mymath.obj
22 CHECKIDX: ??_R1A@?0A@EA@exception@std@@8 in Debug\mymath.obj
23 CHECKIDX: ??_R1A@?0A@EA@invalid_argument@std@@8 in Debug\mymath.obj
24 CHECKIDX: ??_R1A@?0A@EA@logic_error@std@@8 in Debug\mymath.obj
25 CHECKIDX: ??_R2exception@std@@8 in Debug\mymath.obj
26 CHECKIDX: ??_R2invalid_argument@std@@8 in Debug\mymath.obj
27 CHECKIDX: ??_R2logic_error@std@@8 in Debug\mymath.obj
28 CHECKIDX: ??_R3exception@std@@8 in Debug\mymath.obj
29 CHECKIDX: ??_R3invalid_argument@std@@8 in Debug\mymath.obj
30 CHECKIDX: ??_R3logic_error@std@@8 in Debug\mymath.obj
31 CHECKIDX: ??_R4invalid_argument@std@@6B@ in Debug\mymath.obj
32 CHECKIDX: ??_R4logic_error@std@@6B@ in Debug\mymath.obj
33 CHECKIDX: ?Add@MyMathFuncs@MathFuncs@@SANNN@Z in Debug\mymath.obj
34 CHECKIDX: ?Divide@MyMathFuncs@MathFuncs@@SANNN@Z in Debug\mymath.obj
35 CHECKIDX: ?Multiply@MyMathFuncs@MathFuncs@@SANNN@Z in Debug\mymath.obj
36 CHECKIDX: ?Subtract@MyMathFuncs@MathFuncs@@SANNN@Z in Debug\mymath.obj
37 CHECKIDX: ?_Rank@?$_Arithmetic_traits@C@std@@2HB in Debug\mymath.obj
38 CHECKIDX: ?_Rank@?$_Arithmetic_traits@D@std@@2HB in Debug\mymath.obj
39 CHECKIDX: ?_Rank@?$_Arithmetic_traits@E@std@@2HB in Debug\mymath.obj
40 CHECKIDX: ?_Rank@?$_Arithmetic_traits@F@std@@2HB in Debug\mymath.obj
41 CHECKIDX: ?_Rank@?$_Arithmetic_traits@G@std@@2HB in Debug\mymath.obj
42 CHECKIDX: ?_Rank@?$_Arithmetic_traits@H@std@@2HB in Debug\mymath.obj
43 CHECKIDX: ?_Rank@?$_Arithmetic_traits@I@std@@2HB in Debug\mymath.obj
44 CHECKIDX: ?_Rank@?$_Arithmetic_traits@J@std@@2HB in Debug\mymath.obj
45 CHECKIDX: ?_Rank@?$_Arithmetic_traits@K@std@@2HB in Debug\mymath.obj
46 CHECKIDX: ?_Rank@?$_Arithmetic_traits@M@std@@2HB in Debug\mymath.obj
47 CHECKIDX: ?_Rank@?$_Arithmetic_traits@N@std@@2HB in Debug\mymath.obj
48 CHECKIDX: ?_Rank@?$_Arithmetic_traits@O@std@@2HB in Debug\mymath.obj
49 CHECKIDX: ?_Rank@?$_Arithmetic_traits@_J@std@@2HB in Debug\mymath.obj
50 CHECKIDX: ?_Rank@?$_Arithmetic_traits@_K@std@@2HB in Debug\mymath.obj
51 CHECKIDX: ?_Rank@?$_Arithmetic_traits@_N@std@@2HB in Debug\mymath.obj
52 CHECKIDX: ?value@?$integral_constant@I$0A@@tr1@std@@2IB in Debug\mymath.obj
53 CHECKIDX: ?value@?$integral_constant@_N$00@tr1@std@@2_NB in Debug\mymath.obj
54 CHECKIDX: ?value@?$integral_constant@_N$0A@@tr1@std@@2_NB in Debug\mymath.obj
55 CHECKIDX: __CT??_R0PAVexception@std@@@84 in Debug\mymath.obj
56 CHECKIDX: __CT??_R0PAVinvalid_argument@std@@@84 in Debug\mymath.obj
57 CHECKIDX: __CT??_R0PAVlogic_error@std@@@84 in Debug\mymath.obj
58 CHECKIDX: __CT??_R0PAX@84 in Debug\mymath.obj
59 CHECKIDX: __CTA4PAVinvalid_argument@std@@ in Debug\mymath.obj
60 CHECKIDX: __TI4PAVinvalid_argument@std@@ in Debug\mymath.obj
61 CHECKIDX: __real@0000000000000000 in Debug\mymath.obj
62 CHECKIDX: Debug\stdafx.obj:
63 CHECKIDX: 00000000 N .debug$S
64 CHECKIDX: 00000000 N .debug$T
65 CHECKIDX: 00000000 i .drectve
66 CHECKIDX: 00ab9d1b a @comp.id
67 CHECKIDX: 00000001 a @feat.00
68 CHECKIDX: Debug\mymath.obj:
69 CHECKIDX: 00000000 d .data
70 CHECKIDX: 00000000 d .data
71 CHECKIDX: 00000000 d .data
72 CHECKIDX: 00000000 d .data
73 CHECKIDX: 00000000 d .data
74 CHECKIDX: 00000000 d .data
75 CHECKIDX: 00000000 d .data
76 CHECKIDX: 00000000 N .debug$S
77 CHECKIDX: 00000000 N .debug$S
78 CHECKIDX: 00000000 N .debug$S
79 CHECKIDX: 00000000 N .debug$S
80 CHECKIDX: 00000000 N .debug$S
81 CHECKIDX: 00000000 N .debug$S
82 CHECKIDX: 00000000 N .debug$S
83 CHECKIDX: 00000000 N .debug$S
84 CHECKIDX: 00000000 N .debug$S
85 CHECKIDX: 00000000 N .debug$S
86 CHECKIDX: 00000000 N .debug$S
87 CHECKIDX: 00000000 N .debug$T
88 CHECKIDX: 00000000 i .drectve
89 CHECKIDX: 00000000 r .rdata
90 CHECKIDX: 00000000 r .rdata
91 CHECKIDX: 00000000 r .rdata
92 CHECKIDX: 00000000 r .rdata
93 CHECKIDX: 00000000 r .rdata
94 CHECKIDX: 00000000 r .rdata
95 CHECKIDX: 00000000 r .rdata
96 CHECKIDX: 00000000 r .rdata
97 CHECKIDX: 00000000 r .rdata
98 CHECKIDX: 00000000 r .rdata
99 CHECKIDX: 00000000 r .rdata
100 CHECKIDX: 00000000 r .rdata
101 CHECKIDX: 00000000 r .rdata
102 CHECKIDX: 00000000 r .rdata
103 CHECKIDX: 00000000 r .rdata
104 CHECKIDX: 00000000 r .rdata
105 CHECKIDX: 00000000 r .rdata
106 CHECKIDX: 00000000 r .rdata
107 CHECKIDX: 00000000 r .rdata
108 CHECKIDX: 00000000 r .rdata
109 CHECKIDX: 00000000 r .rdata
110 CHECKIDX: 00000000 r .rdata
111 CHECKIDX: 00000000 r .rdata$r
112 CHECKIDX: 00000000 r .rdata$r
113 CHECKIDX: 00000000 r .rdata$r
114 CHECKIDX: 00000000 r .rdata$r
115 CHECKIDX: 00000000 r .rdata$r
116 CHECKIDX: 00000000 r .rdata$r
117 CHECKIDX: 00000000 r .rdata$r
118 CHECKIDX: 00000000 r .rdata$r
119 CHECKIDX: 00000000 r .rdata$r
120 CHECKIDX: 00000000 r .rdata$r
121 CHECKIDX: 00000000 r .rdata$r
122 CHECKIDX: 00000000 r .rtc$IMZ
123 CHECKIDX: 00000000 r .rtc$TMZ
124 CHECKIDX: 00000000 N .sxdata
125 CHECKIDX: 00000000 t .text
126 CHECKIDX: 00000000 t .text
127 CHECKIDX: 00000000 t .text
128 CHECKIDX: 00000000 t .text
129 CHECKIDX: 00000000 t .text
130 CHECKIDX: 00000000 t .text
131 CHECKIDX: 00000000 t .text
132 CHECKIDX: 00000000 t .text
133 CHECKIDX: 00000000 t .text
134 CHECKIDX: 00000000 t .text
135 CHECKIDX: 00000000 t .text$x
136 CHECKIDX: 00000000 r .xdata$x
137 CHECKIDX: 00000000 r .xdata$x
138 CHECKIDX: 00000000 r .xdata$x
139 CHECKIDX: 00000000 r .xdata$x
140 CHECKIDX: 00000000 r .xdata$x
141 CHECKIDX: 00000000 r .xdata$x
142 CHECKIDX: 00000000 r .xdata$x
143 CHECKIDX: 00000000 T ??0invalid_argument@std@@QAE@PBD@Z
144 CHECKIDX: 00000000 T ??0logic_error@std@@QAE@PBD@Z
145 CHECKIDX: 00000000 T ??1invalid_argument@std@@UAE@XZ
146 CHECKIDX: 00000000 T ??1logic_error@std@@UAE@XZ
147 CHECKIDX: U ??2@YAPAXI@Z
148 CHECKIDX: U ??3@YAXPAX@Z
149 CHECKIDX: 00000004 R ??_7invalid_argument@std@@6B@
150 CHECKIDX: 00000004 R ??_7logic_error@std@@6B@
151 CHECKIDX: U ??_7type_info@@6B@
152 CHECKIDX: 00000000 R ??_C@_0BC@IHENMCGI@b?5cannot?5be?5zero?$CB?$AA@
153 CHECKIDX: w ??_Einvalid_argument@std@@UAEPAXI@Z
154 CHECKIDX: w ??_Elogic_error@std@@UAEPAXI@Z
155 CHECKIDX: U ??_Ginvalid_argument@std@@UAEPAXI@Z
156 CHECKIDX: 00000000 T ??_Ginvalid_argument@std@@UAEPAXI@Z
157 CHECKIDX: 00000000 T ??_Glogic_error@std@@UAEPAXI@Z
158 CHECKIDX: U ??_Glogic_error@std@@UAEPAXI@Z
159 CHECKIDX: 00000000 D ??_R0?AVexception@std@@@8
160 CHECKIDX: 00000000 D ??_R0?AVinvalid_argument@std@@@8
161 CHECKIDX: 00000000 D ??_R0?AVlogic_error@std@@@8
162 CHECKIDX: 00000000 D ??_R0PAVexception@std@@@8
163 CHECKIDX: 00000000 D ??_R0PAVinvalid_argument@std@@@8
164 CHECKIDX: 00000000 D ??_R0PAVlogic_error@std@@@8
165 CHECKIDX: 00000000 D ??_R0PAX@8
166 CHECKIDX: 00000000 R ??_R1A@?0A@EA@exception@std@@8
167 CHECKIDX: 00000000 R ??_R1A@?0A@EA@invalid_argument@std@@8
168 CHECKIDX: 00000000 R ??_R1A@?0A@EA@logic_error@std@@8
169 CHECKIDX: 00000000 R ??_R2exception@std@@8
170 CHECKIDX: 00000000 R ??_R2invalid_argument@std@@8
171 CHECKIDX: 00000000 R ??_R2logic_error@std@@8
172 CHECKIDX: 00000000 R ??_R3exception@std@@8
173 CHECKIDX: 00000000 R ??_R3invalid_argument@std@@8
174 CHECKIDX: 00000000 R ??_R3logic_error@std@@8
175 CHECKIDX: 00000000 R ??_R4invalid_argument@std@@6B@
176 CHECKIDX: 00000000 R ??_R4logic_error@std@@6B@
177 CHECKIDX: 00000000 T ?Add@MyMathFuncs@MathFuncs@@SANNN@Z
178 CHECKIDX: 00000000 T ?Divide@MyMathFuncs@MathFuncs@@SANNN@Z
179 CHECKIDX: 00000000 T ?Multiply@MyMathFuncs@MathFuncs@@SANNN@Z
180 CHECKIDX: 00000000 T ?Subtract@MyMathFuncs@MathFuncs@@SANNN@Z
181 CHECKIDX: 00000000 R ?_Rank@?$_Arithmetic_traits@C@std@@2HB
182 CHECKIDX: 00000000 R ?_Rank@?$_Arithmetic_traits@D@std@@2HB
183 CHECKIDX: 00000000 R ?_Rank@?$_Arithmetic_traits@E@std@@2HB
184 CHECKIDX: 00000000 R ?_Rank@?$_Arithmetic_traits@F@std@@2HB
185 CHECKIDX: 00000000 R ?_Rank@?$_Arithmetic_traits@G@std@@2HB
186 CHECKIDX: 00000000 R ?_Rank@?$_Arithmetic_traits@H@std@@2HB
187 CHECKIDX: 00000000 R ?_Rank@?$_Arithmetic_traits@I@std@@2HB
188 CHECKIDX: 00000000 R ?_Rank@?$_Arithmetic_traits@J@std@@2HB
189 CHECKIDX: 00000000 R ?_Rank@?$_Arithmetic_traits@K@std@@2HB
190 CHECKIDX: 00000000 R ?_Rank@?$_Arithmetic_traits@M@std@@2HB
191 CHECKIDX: 00000000 R ?_Rank@?$_Arithmetic_traits@N@std@@2HB
192 CHECKIDX: 00000000 R ?_Rank@?$_Arithmetic_traits@O@std@@2HB
193 CHECKIDX: 00000000 R ?_Rank@?$_Arithmetic_traits@_J@std@@2HB
194 CHECKIDX: 00000000 R ?_Rank@?$_Arithmetic_traits@_K@std@@2HB
195 CHECKIDX: 00000000 R ?_Rank@?$_Arithmetic_traits@_N@std@@2HB
196 CHECKIDX: 00000000 R ?value@?$integral_constant@I$0A@@tr1@std@@2IB
197 CHECKIDX: 00000000 R ?value@?$integral_constant@_N$00@tr1@std@@2_NB
198 CHECKIDX: 00000000 R ?value@?$integral_constant@_N$0A@@tr1@std@@2_NB
199 CHECKIDX: U ?what@exception@std@@UBEPBDXZ
200 CHECKIDX: U @__security_check_cookie@4
201 CHECKIDX: 00ab9d1b a @comp.id
202 CHECKIDX: 00000001 a @feat.00
203 CHECKIDX: 00000000 R __CT??_R0PAVexception@std@@@84
204 CHECKIDX: 00000000 R __CT??_R0PAVinvalid_argument@std@@@84
205 CHECKIDX: 00000000 R __CT??_R0PAVlogic_error@std@@@84
206 CHECKIDX: 00000000 R __CT??_R0PAX@84
207 CHECKIDX: 00000000 R __CTA4PAVinvalid_argument@std@@
208 CHECKIDX: U __CxxThrowException@8
209 CHECKIDX: U __RTC_CheckEsp
210 CHECKIDX: U __RTC_InitBase
211 CHECKIDX: 00000000 r __RTC_InitBase.rtc$IMZ
212 CHECKIDX: U __RTC_Shutdown
213 CHECKIDX: 00000000 r __RTC_Shutdown.rtc$TMZ
214 CHECKIDX: 00000000 R __TI4PAVinvalid_argument@std@@
215 CHECKIDX: U ___CxxFrameHandler3
216 CHECKIDX: U ___security_cookie
217 CHECKIDX: 00000008 r __ehfuncinfo$?Divide@MyMathFuncs@MathFuncs@@SANNN@Z
218 CHECKIDX: 0000000e t __ehhandler$?Divide@MyMathFuncs@MathFuncs@@SANNN@Z
219 CHECKIDX: U __fltused
220 CHECKIDX: U __imp_??0exception@std@@QAE@ABQBD@Z
221 CHECKIDX: U __imp_??1exception@std@@UAE@XZ
222 CHECKIDX: 00000000 R __real@0000000000000000
223 CHECKIDX: 00000000 t __unwindfunclet$?Divide@MyMathFuncs@MathFuncs@@SANNN@Z$0
224 CHECKIDX: 00000000 r __unwindtable$?Divide@MyMathFuncs@MathFuncs@@SANNN@Z
0 #
1 # Check if the index is appearing properly in the output file
2 #
3 RUN: llvm-nm -s %p/Inputs/libsimple_archive.a | FileCheck -check-prefix=CHECKIDX %s
4
5 CHECKIDX: Archive map
6 CHECKIDX: abcdefghijklmnopqrstuvwxyz12345678 in 1.o
7 CHECKIDX: main in 1.o
8 CHECKIDX: 1.o:
9 CHECKIDX: 00000000 D abcdefghijklmnopqrstuvwxyz12345678
10 CHECKIDX: U fn1
11 CHECKIDX: 00000000 T main
112112 cl::opt WithoutAliases("without-aliases", cl::Hidden,
113113 cl::desc("Exclude aliases from output"));
114114
115 cl::opt ArchiveMap("print-armap",
116 cl::desc("Print the archive map"));
117 cl::alias ArchiveMaps("s", cl::desc("Alias for --print-armap"),
118 cl::aliasopt(ArchiveMap));
115119 bool PrintAddress = true;
116120
117121 bool MultipleFiles = false;
345349 return;
346350
347351 if (object::Archive *a = dyn_cast(arch.get())) {
352 if (ArchiveMap) {
353 outs() << "Archive map" << "\n";
354 for (object::Archive::symbol_iterator i = a->begin_symbols(),
355 e = a->end_symbols(); i != e; ++i) {
356 object::Archive::child_iterator c;
357 StringRef symname;
358 StringRef filename;
359 if (error(i->getMember(c)))
360 return;
361 if (error(i->getName(symname)))
362 return;
363 if (error(c->getName(filename)))
364 return;
365 outs() << symname << " in " << filename << "\n";
366 }
367 outs() << "\n";
368 }
369
348370 for (object::Archive::child_iterator i = a->begin_children(),
349371 e = a->end_children(); i != e; ++i) {
350372 OwningPtr child;