Skip to content

Commit fe196b7

Browse files
committed
[lld][ELF] Minor fixes addressing review comments.
- Update comment about CompUnits in OutputChunk. - Replace two uses of 'seq' in for-loops. - Replace use of memcpy with llvm::copy.
1 parent d12762c commit fe196b7

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

lld/ELF/SyntheticSections.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3077,11 +3077,9 @@ std::pair<uint32_t, uint32_t> DebugNamesBaseSection::computeEntryPool(
30773077
// Abbrevs are indexed starting at 1; vector starts at 0. (abbrevCode
30783078
// corresponds to position in the merged table vector).
30793079
const Abbrev *abbrev = abbrevTable[ie.abbrevCode - 1];
3080-
for (auto i : seq(abbrev->attributes.size())) {
3081-
DWARFDebugNames::AttributeEncoding a = abbrev->attributes[i];
3080+
for (auto &[a, v] : zip_equal(abbrev->attributes, ie.attrValues))
30823081
if (a.Index == DW_IDX_parent && a.Form == DW_FORM_ref4)
3083-
ie.attrValues[i].attrValue = ie.parentEntry->poolOffset;
3084-
}
3082+
v.attrValue = ie.parentEntry->poolOfset;
30853083
}
30863084
}
30873085
});
@@ -3232,8 +3230,8 @@ template <class ELFT> void DebugNamesSection<ELFT>::writeTo(uint8_t *buf) {
32323230
buf += hdr.AugmentationStringSize;
32333231

32343232
// Write the CU list.
3235-
for (auto i : seq(numChunks))
3236-
for (uint32_t cuOffset : chunks[i].compUnits)
3233+
for (OutputChunk &chunk : chunks)
3234+
for (uint32_t cuOffset : chunk.compUnits)
32373235
endian::writeNext<uint32_t, ELFT::Endianness>(buf, cuOffset);
32383236

32393237
// Write the local TU list, then the foreign TU list..
@@ -3275,8 +3273,7 @@ template <class ELFT> void DebugNamesSection<ELFT>::writeTo(uint8_t *buf) {
32753273
endian::writeNext<uint32_t, ELFT::Endianness>(buf, ne->entryOffset);
32763274

32773275
// Write the abbrev table.
3278-
memcpy(buf, abbrevTableBuf.data(), abbrevTableBuf.size());
3279-
buf += abbrevTableBuf.size();
3276+
buf = llvm::copy(abbrevTableBuf, buf);
32803277

32813278
// Write the entry pool. Unlike the name table, the name entries follow the
32823279
// nameVecs order computed by `computeEntryPool`.

lld/ELF/SyntheticSections.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -858,10 +858,8 @@ class DebugNamesBaseSection : public SyntheticSection {
858858
// Pointer to the .debug_info section that contains compile units, used to
859859
// compute the relocated CU offsets.
860860
InputSection *infoSec;
861-
// This initially holds section offsets, which may not be consecutive if
862-
// there are multiple name indices in an input .debug_names section. After
863-
// relocation, the section offsets are changed to CU offsets relative to the
864-
// output section.
861+
// This initially holds section offsets. After relocation, the section
862+
// offsets are changed to CU offsets relative the the output section.
865863
SmallVector<uint32_t, 0> compUnits;
866864
};
867865

0 commit comments

Comments
 (0)