[PATCH] D126484: [LLD][ELF] Drop the string null terminator from the hash in splitStrings
Andrew Ng via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu May 26 09:06:51 PDT 2022
andrewng created this revision.
andrewng added a reviewer: MaskRay.
Herald added subscribers: StephenFan, arichardson, emaste.
Herald added a project: All.
andrewng requested review of this revision.
https://reviews.llvm.org/D126484
Files:
lld/ELF/InputSection.cpp
lld/test/ELF/comment-gc.s
lld/test/ELF/merge-string.s
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
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/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);
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126484.432306.patch
Type: text/x-patch
Size: 1608 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220526/d4d8f522/attachment.bin>
More information about the llvm-commits
mailing list