@@ -203,42 +203,32 @@ void macho::writeMapFile() {
203
203
seg->name .str ().c_str (), osec->name .str ().c_str ());
204
204
}
205
205
206
+ // Helper lambda that prints all symbols from one ConcatInputSection.
207
+ auto printOne = [&](const ConcatInputSection *isec) {
208
+ for (Defined *sym : isec->symbols ) {
209
+ if (!(isPrivateLabel (sym->getName ()) && getSymSizeForMap (sym) == 0 )) {
210
+ os << format (" 0x%08llX\t 0x%08llX\t [%3u] %s\n " , sym->getVA (),
211
+ getSymSizeForMap (sym),
212
+ readerToFileOrdinal.lookup (sym->getFile ()),
213
+ sym->getName ().str ().data ());
214
+ }
215
+ }
216
+ };
206
217
// Shared function to print one or two arrays of ConcatInputSection in
207
218
// ascending outSecOff order. The second array is optional; if provided, we
208
219
// interleave the printing in sorted order without allocating a merged temp
209
220
// array.
210
- auto printIsecArrSyms = [&](const std::vector<ConcatInputSection *> &arr1,
211
- const std::vector<ConcatInputSection *> *arr2 =
212
- nullptr ) {
213
- // Helper lambda that prints all symbols from one ConcatInputSection.
214
- auto printOne = [&](const ConcatInputSection *isec) {
215
- for (Defined *sym : isec->symbols ) {
216
- if (!(isPrivateLabel (sym->getName ()) && getSymSizeForMap (sym) == 0 )) {
217
- os << format (" 0x%08llX\t 0x%08llX\t [%3u] %s\n " , sym->getVA (),
218
- getSymSizeForMap (sym),
219
- readerToFileOrdinal.lookup (sym->getFile ()),
220
- sym->getName ().str ().data ());
221
- }
222
- }
223
- };
224
-
225
- // If there is only one array, print all symbols from it and return.
226
- // This simplifies the logic for the merge case below.
227
- if (!arr2) {
228
- for (const ConcatInputSection *isec : arr1)
229
- printOne (isec);
230
- return ;
231
- }
232
-
221
+ auto printIsecArrSyms = [&](ArrayRef<ConcatInputSection *> arr1,
222
+ ArrayRef<ConcatInputSection *> arr2 = {}) {
233
223
size_t i = 0 , j = 0 ;
234
224
size_t size1 = arr1.size ();
235
- size_t size2 = arr2-> size ();
225
+ size_t size2 = arr2. size ();
236
226
while (i < size1 || j < size2) {
237
227
if (i < size1 &&
238
- (j >= size2 || arr1[i]->outSecOff <= (* arr2) [j]->outSecOff )) {
228
+ (j >= size2 || arr1[i]->outSecOff <= arr2[j]->outSecOff )) {
239
229
printOne (arr1[i++]);
240
230
} else if (j < size2) {
241
- printOne ((* arr2) [j++]);
231
+ printOne (arr2[j++]);
242
232
}
243
233
}
244
234
};
@@ -248,7 +238,7 @@ void macho::writeMapFile() {
248
238
for (const OutputSegment *seg : outputSegments) {
249
239
for (const OutputSection *osec : seg->getSections ()) {
250
240
if (auto *textOsec = dyn_cast<TextOutputSection>(osec)) {
251
- printIsecArrSyms (textOsec->inputs , & textOsec->getThunks ());
241
+ printIsecArrSyms (textOsec->inputs , textOsec->getThunks ());
252
242
} else if (auto *concatOsec = dyn_cast<ConcatOutputSection>(osec)) {
253
243
printIsecArrSyms (concatOsec->inputs );
254
244
} else if (osec == in.cStringSection || osec == in.objcMethnameSection ) {
0 commit comments