Index: lld/ELF/InputSection.cpp =================================================================== --- lld/ELF/InputSection.cpp +++ lld/ELF/InputSection.cpp @@ -1376,15 +1376,15 @@ 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); } } Index: lld/test/ELF/comment-gc.s =================================================================== --- lld/test/ELF/comment-gc.s +++ lld/test/ELF/comment-gc.s @@ -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" Index: lld/test/ELF/merge-string.s =================================================================== --- lld/test/ELF/merge-string.s +++ lld/test/ELF/merge-string.s @@ -54,7 +54,7 @@ // 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