[lld] r327736 - [COFF] Clarify comment. NFC

Shoaib Meenai via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 16 13:20:01 PDT 2018


Author: smeenai
Date: Fri Mar 16 13:20:01 2018
New Revision: 327736

URL: http://llvm.org/viewvc/llvm-project?rev=327736&view=rev
Log:
[COFF] Clarify comment. NFC

Reid pointed out the string table for supporting long section names is a
BFD extension and the comments should reflect that. Explicitly spell out
link.exe's and binutil's behavior around section names and the rationale
for LLD's behavior.

Differential Revision: https://reviews.llvm.org/D42659

Modified:
    lld/trunk/COFF/Writer.cpp

Modified: lld/trunk/COFF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Writer.cpp?rev=327736&r1=327735&r2=327736&view=diff
==============================================================================
--- lld/trunk/COFF/Writer.cpp (original)
+++ lld/trunk/COFF/Writer.cpp Fri Mar 16 13:20:01 2018
@@ -603,15 +603,17 @@ Optional<coff_symbol16> Writer::createSy
 }
 
 void Writer::createSymbolAndStringTable() {
-  // Name field in the section table is 8 byte long. Longer names need
-  // to be written to the string table. First, construct string table.
+  // PE/COFF images are limited to 8 byte section names. Longer names can be
+  // supported by writing a non-standard string table, but this string table is
+  // not mapped at runtime and the long names will therefore be inaccessible.
+  // link.exe always truncates section names to 8 bytes, whereas binutils always
+  // preserves long section names via the string table. LLD adopts a hybrid
+  // solution where discardable sections have long names preserved and
+  // non-discardable sections have their names truncated, to ensure that any
+  // section which is mapped at runtime also has its name mapped at runtime.
   for (OutputSection *Sec : OutputSections) {
     if (Sec->Name.size() <= COFF::NameSize)
       continue;
-    // If a section isn't discardable (i.e. will be mapped at runtime),
-    // prefer a truncated section name over a long section name in
-    // the string table that is unavailable at runtime. Note that link.exe
-    // always truncates, even for discardable sections.
     if ((Sec->getPermissions() & IMAGE_SCN_MEM_DISCARDABLE) == 0)
       continue;
     Sec->setStringTableOff(addEntryToStringTable(Sec->Name));




More information about the llvm-commits mailing list