Skip to content

Commit f370080

Browse files
committed
[lld][ELF] Update code related to type units.
- Keep type unit counts in output header at zero, regardless of input, to avoid crashing LLD, since we're not actually handling type units yet. - Move the type units warning to the point where we can check the input counts. - Add a type units test (that LLD doesn't crash and outputs the warning).
1 parent cee8c29 commit f370080

File tree

2 files changed

+539
-7
lines changed

2 files changed

+539
-7
lines changed

lld/ELF/SyntheticSections.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2904,8 +2904,15 @@ void DebugNamesBaseSection::computeHdrAndAbbrevTable(
29042904
numCu += chunks[i].compUnits.size();
29052905
for (const NameData &nd : inputChunk.nameData) {
29062906
hdr.CompUnitCount += nd.hdr.CompUnitCount;
2907-
hdr.LocalTypeUnitCount += nd.hdr.LocalTypeUnitCount;
2908-
hdr.ForeignTypeUnitCount += nd.hdr.ForeignTypeUnitCount;
2907+
// We are not actually handling or emitting type units yet, so
2908+
// so non-zero type unit counts will crash LLD.
2909+
// TODO: Uncomment the two lines below when we implement this for
2910+
// type units & remove the following check/warning.
2911+
//hdr.LocalTypeUnitCount += nd.hdr.LocalTypeUnitCount;
2912+
//hdr.ForeignTypeUnitCount += nd.hdr.ForeignTypeUnitCount;
2913+
if (nd.hdr.LocalTypeUnitCount || nd. hdr.ForeignTypeUnitCount)
2914+
warn(toString(inputChunk.section.sec) +
2915+
Twine(": type units are not implemented"));
29092916
// If augmentation strings are not identical, use an empty string.
29102917
if (i == 0) {
29112918
hdr.AugmentationStringSize = nd.hdr.AugmentationStringSize;
@@ -3039,7 +3046,7 @@ std::pair<uint32_t, uint32_t> DebugNamesBaseSection::computeEntryPool(
30393046
}
30403047
});
30413048

3042-
// Compute entry offsets in parallel. First, comptute offsets relative to the
3049+
// Compute entry offsets in parallel. First, compute offsets relative to the
30433050
// current shard.
30443051
uint32_t offsets[numShards];
30453052
parallelFor(0, numShards, [&](size_t shard) {
@@ -3234,10 +3241,7 @@ template <class ELFT> void DebugNamesSection<ELFT>::writeTo(uint8_t *buf) {
32343241
for (uint32_t cuOffset : chunks[i].compUnits)
32353242
endian::writeNext<uint32_t, ELFT::Endianness>(buf, cuOffset);
32363243

3237-
// Write the local TU list, then the foreign TU list..
3238-
// TODO: Fix this, once we get everything working without TUs.
3239-
if (hdr.LocalTypeUnitCount || hdr.ForeignTypeUnitCount)
3240-
warn(".debug_names: type units are not implemented");
3244+
// TODO: Write the local TU list, then the foreign TU list..
32413245

32423246
// Write the hash lookup table.
32433247
SmallVector<SmallVector<NameEntry *, 0>, 0> buckets(hdr.BucketCount);

0 commit comments

Comments
 (0)