[lld] r197470 - [PECOFF] Truncate long section name.

Rui Ueyama ruiu at google.com
Mon Dec 16 22:15:09 PST 2013


Author: ruiu
Date: Tue Dec 17 00:15:09 2013
New Revision: 197470

URL: http://llvm.org/viewvc/llvm-project?rev=197470&view=rev
Log:
[PECOFF] Truncate long section name.

Executable files do not use a string table, so section names longer than 8
characters are not permitted. Long section names should just be truncated.

Added:
    lld/trunk/test/pecoff/long-section-name.test
Modified:
    lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp

Modified: lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp?rev=197470&r1=197469&r2=197470&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp Tue Dec 17 00:15:09 2013
@@ -631,12 +631,9 @@ llvm::object::coff_section
 SectionHeaderTableChunk::createSectionHeader(SectionChunk *chunk) {
   llvm::object::coff_section header;
 
-  // Section name equal to or shorter than 8 byte fits in the section
-  // header. Longer names should be stored to string table, which is not
-  // implemented yet.
+  // Section name must be equal to or less than 8 characters in the
+  // executable. Longer names will be truncated.
   StringRef sectionName = chunk->getSectionName();
-  if (sizeof(header.Name) < sectionName.size())
-    llvm_unreachable("Cannot handle section name longer than 8 byte");
 
   // Name field must be NUL-padded. If the name is exactly 8 byte long,
   // there's no terminating NUL.

Added: lld/trunk/test/pecoff/long-section-name.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/long-section-name.test?rev=197470&view=auto
==============================================================================
--- lld/trunk/test/pecoff/long-section-name.test (added)
+++ lld/trunk/test/pecoff/long-section-name.test Tue Dec 17 00:15:09 2013
@@ -0,0 +1,7 @@
+# RUN: yaml2obj %p/Inputs/nop.obj.yaml > %t.obj
+#
+# RUN: lld -flavor link /out:%t.exe /subsystem:console /entry:start \
+# RUN:   /merge:.text=.longsectionname -- %t.obj
+# RUN: llvm-readobj -sections %t.exe | FileCheck %s
+
+CHECK: Name: .longsec (2E 6C 6F 6E 67 73 65 63)





More information about the llvm-commits mailing list