[PATCH] D24120: [ELF] Do not omit debug sections when computing build-id

Petr Hosek via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 31 22:38:30 PDT 2016

phosek created this revision.
phosek added a reviewer: ruiu.
phosek added a subscriber: llvm-commits.
phosek added a project: lld.

The primary use of build-id is in debugging, hence omitting debug sections when computing it significantly reduces its usability as changes in debug section content wouldn't alter the build-id.



Index: ELF/Writer.cpp
--- ELF/Writer.cpp
+++ ELF/Writer.cpp
@@ -1320,20 +1320,11 @@
   if (!Out<ELFT>::BuildId)
-  // Compute a hash of all sections except .debug_* sections.
-  // We skip debug sections because they tend to be very large
-  // and their contents are very likely to be the same as long as
-  // other sections are the same.
+  // Compute a hash of all sections.
   uint8_t *Start = Buffer->getBufferStart();
-  uint8_t *Last = Start;
+  uint8_t *End = Start + FileSize;
   std::vector<ArrayRef<uint8_t>> Regions;
-  for (OutputSectionBase<ELFT> *Sec : OutputSections) {
-    uint8_t *End = Start + Sec->getFileOff();
-    if (!Sec->getName().startswith(".debug_"))
-      Regions.push_back({Last, End});
-    Last = End;
-  }
-  Regions.push_back({Last, Start + FileSize});
+  Regions.push_back({Start, End});

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24120.69945.patch
Type: text/x-patch
Size: 961 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160901/7eb75645/attachment.bin>

More information about the llvm-commits mailing list