summaryrefslogtreecommitdiffstats
path: root/lld/COFF/Writer.cpp
diff options
context:
space:
mode:
authorShoaib Meenai <smeenai@fb.com>2018-03-16 20:20:01 +0000
committerShoaib Meenai <smeenai@fb.com>2018-03-16 20:20:01 +0000
commit290f26fefde5632880092def3bcf6fad3fb2739e (patch)
tree11bc4cddb01b28ba076fc5a5910f8028d758ce31 /lld/COFF/Writer.cpp
parente669f3aa7e34fede8c90a2b4af79e145f7d6dd7a (diff)
downloadbcm5719-llvm-290f26fefde5632880092def3bcf6fad3fb2739e.tar.gz
bcm5719-llvm-290f26fefde5632880092def3bcf6fad3fb2739e.zip
[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 llvm-svn: 327736
Diffstat (limited to 'lld/COFF/Writer.cpp')
-rw-r--r--lld/COFF/Writer.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/lld/COFF/Writer.cpp b/lld/COFF/Writer.cpp
index 19c0c39138a..6f173de50e8 100644
--- a/lld/COFF/Writer.cpp
+++ b/lld/COFF/Writer.cpp
@@ -603,15 +603,17 @@ Optional<coff_symbol16> Writer::createSymbol(Defined *Def) {
}
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));
OpenPOWER on IntegriCloud