summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lld/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp7
-rw-r--r--lld/test/pecoff/long-section-name.test7
2 files changed, 9 insertions, 5 deletions
diff --git a/lld/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp b/lld/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp
index aff6536d560..05621416015 100644
--- a/lld/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp
+++ b/lld/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp
@@ -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.
diff --git a/lld/test/pecoff/long-section-name.test b/lld/test/pecoff/long-section-name.test
new file mode 100644
index 00000000000..30c109e02ae
--- /dev/null
+++ b/lld/test/pecoff/long-section-name.test
@@ -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)
OpenPOWER on IntegriCloud