[PATCH] D47497: [COFF] Unify output section code. NFC
Shoaib Meenai via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 29 15:15:43 PDT 2018
smeenai updated this revision to Diff 148994.
smeenai added a comment.
@pcc's comments
Repository:
rLLD LLVM Linker
https://reviews.llvm.org/D47497
Files:
COFF/Writer.cpp
Index: COFF/Writer.cpp
===================================================================
--- COFF/Writer.cpp
+++ COFF/Writer.cpp
@@ -602,20 +602,29 @@
}
Optional<coff_symbol16> Writer::createSymbol(Defined *Def) {
- // Relative symbols are unrepresentable in a COFF symbol table.
- if (isa<DefinedSynthetic>(Def))
- return None;
+ coff_symbol16 Sym;
+ switch (Def->kind()) {
+ case Symbol::DefinedAbsoluteKind:
+ Sym.Value = Def->getRVA();
+ Sym.SectionNumber = IMAGE_SYM_ABSOLUTE;
+ break;
+ default: {
+ // Relative symbols are unrepresentable in a COFF symbol table.
+ if (isa<DefinedSynthetic>(Def))
+ return None;
- // Don't write symbols that won't be written to the output to the symbol
- // table.
- OutputSection *OS = nullptr;
- if (Chunk *C = Def->getChunk()) {
- OS = C->getOutputSection();
+ // Don't write symbols that won't be written to the output to the symbol
+ // table.
+ OutputSection *OS = Def->getChunk()->getOutputSection();
if (!OS)
return None;
+
+ Sym.Value = Def->getRVA() - OS->getRVA();
+ Sym.SectionNumber = OS->SectionIndex;
+ break;
+ }
}
- coff_symbol16 Sym;
StringRef Name = Def->getName();
if (Name.size() > COFF::NameSize) {
Sym.Name.Offset.Zeroes = 0;
@@ -634,19 +643,6 @@
Sym.StorageClass = IMAGE_SYM_CLASS_EXTERNAL;
}
Sym.NumberOfAuxSymbols = 0;
-
- switch (Def->kind()) {
- case Symbol::DefinedAbsoluteKind:
- Sym.Value = Def->getRVA();
- Sym.SectionNumber = IMAGE_SYM_ABSOLUTE;
- break;
- default: {
- assert(OS && "Writing dead symbol to symbol table");
- Sym.Value = Def->getRVA() - OS->getRVA();
- Sym.SectionNumber = OS->SectionIndex;
- break;
- }
- }
return Sym;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47497.148994.patch
Type: text/x-patch
Size: 1747 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180529/d7f43e4b/attachment.bin>
More information about the llvm-commits
mailing list