[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
Fri May 27 02:55:01 PDT 2022


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc78c00dc16bb: [LLD][ELF] Drop the string null terminator from the hash in splitStrings (authored by andrewng).
Herald added a project: LLVM.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126484/new/

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.432507.patch
Type: text/x-patch
Size: 1608 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220527/cc6b703d/attachment.bin>


More information about the llvm-commits mailing list