[LLD][ELF] Drop the string null terminator from the hash in splitStrings

Differential Revision: https://reviews.llvm.org/D126484
This commit is contained in:
Andrew Ng
2022-05-26 16:03:09 +01:00
parent 8d021670c3
commit c78c00dc16
3 changed files with 6 additions and 6 deletions

View File

@@ -1376,15 +1376,15 @@ void MergeInputSection::splitStrings(StringRef s, size_t entSize) {
if (entSize == 1) {
// Optimize the common case.
do {
size_t size = strlen(p) + 1;
size_t size = strlen(p);
pieces.emplace_back(p - s.begin(), xxHash64(StringRef(p, size)), live);
p += size;
p += size + 1;
} while (p != end);
} else {
do {
size_t size = findNull(StringRef(p, end - p), entSize) + entSize;
size_t size = findNull(StringRef(p, end - p), entSize);
pieces.emplace_back(p - s.begin(), xxHash64(StringRef(p, size)), live);
p += size;
p += size + entSize;
} while (p != end);
}
}

View File

@@ -5,7 +5,7 @@
# RUN: llvm-objdump -s %t1 | FileCheck %s
# CHECK: Contents of section .comment:
# CHECK-NEXT: foo..LLD 1.0.bar
# CHECK-NEXT: .LLD 1.0.foo.bar
.ident "foo"

View File

@@ -54,7 +54,7 @@ zed:
// NOTAIL-NEXT: AddressAlignment: 1
// NOTAIL-NEXT: EntrySize: 1
// NOTAIL-NEXT: SectionData (
// NOTAIL-NEXT: 0000: 62630061 626300 |bc.abc.|
// NOTAIL-NEXT: 0000: 61626300 626300 |abc.bc.|
// NOTAIL-NEXT: )
// NOMERGE: Name: .rodata1