@@ -203,42 +203,32 @@ void macho::writeMapFile() {
203203 seg->name .str ().c_str (), osec->name .str ().c_str ());
204204 }
205205
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+ };
206217 // Shared function to print one or two arrays of ConcatInputSection in
207218 // ascending outSecOff order. The second array is optional; if provided, we
208219 // interleave the printing in sorted order without allocating a merged temp
209220 // 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 = {}) {
233223 size_t i = 0 , j = 0 ;
234224 size_t size1 = arr1.size ();
235- size_t size2 = arr2-> size ();
225+ size_t size2 = arr2. size ();
236226 while (i < size1 || j < size2) {
237227 if (i < size1 &&
238- (j >= size2 || arr1[i]->outSecOff <= (* arr2) [j]->outSecOff )) {
228+ (j >= size2 || arr1[i]->outSecOff <= arr2[j]->outSecOff )) {
239229 printOne (arr1[i++]);
240230 } else if (j < size2) {
241- printOne ((* arr2) [j++]);
231+ printOne (arr2[j++]);
242232 }
243233 }
244234 };
@@ -248,7 +238,7 @@ void macho::writeMapFile() {
248238 for (const OutputSegment *seg : outputSegments) {
249239 for (const OutputSection *osec : seg->getSections ()) {
250240 if (auto *textOsec = dyn_cast<TextOutputSection>(osec)) {
251- printIsecArrSyms (textOsec->inputs , & textOsec->getThunks ());
241+ printIsecArrSyms (textOsec->inputs , textOsec->getThunks ());
252242 } else if (auto *concatOsec = dyn_cast<ConcatOutputSection>(osec)) {
253243 printIsecArrSyms (concatOsec->inputs );
254244 } else if (osec == in.cStringSection || osec == in.objcMethnameSection ) {
0 commit comments