[PATCH] D47391: [COFF] Simplify symbol table output section computation
Shoaib Meenai via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 29 12:11:52 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLD333450: [COFF] Simplify symbol table output section computation (authored by smeenai, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D47391?vs=148958&id=148959#toc
Repository:
rLLD LLVM Linker
https://reviews.llvm.org/D47391
Files:
COFF/Writer.cpp
test/COFF/gfids-gc.s
test/COFF/safeseh.s
Index: test/COFF/safeseh.s
===================================================================
--- test/COFF/safeseh.s
+++ test/COFF/safeseh.s
@@ -1,6 +1,8 @@
# RUN: llvm-mc -triple i686-windows-msvc %s -filetype=obj -o %t.obj
# RUN: lld-link %t.obj -safeseh -out:%t.exe -opt:noref -entry:main
# RUN: llvm-readobj -coff-basereloc -coff-load-config -file-headers %t.exe | FileCheck %s --check-prefix=CHECK-NOGC
+# RUN: lld-link %t.obj -safeseh -out:%t.exe -opt:noref -entry:main -debug:dwarf
+# RUN: llvm-readobj -coff-basereloc -coff-load-config -file-headers %t.exe | FileCheck %s --check-prefix=CHECK-NOGC
# RUN: lld-link %t.obj -safeseh -out:%t.exe -opt:ref -entry:main
# RUN: llvm-readobj -coff-basereloc -coff-load-config -file-headers %t.exe | FileCheck %s --check-prefix=CHECK-GC
@@ -13,7 +15,7 @@
# CHECK-NOGC: Type: HIGHLOW
# CHECK-NOGC: LoadConfig [
# CHECK-NOGC: Size: 0x48
-# CHECK-NOGC: SEHandlerTable: 0x402048
+# CHECK-NOGC: SEHandlerTable: 0x
# CHECK-NOGC: SEHandlerCount: 1
# CHECK-NOGC: ]
# CHECK-NOGC: SEHTable [
Index: test/COFF/gfids-gc.s
===================================================================
--- test/COFF/gfids-gc.s
+++ test/COFF/gfids-gc.s
@@ -1,6 +1,8 @@
# RUN: llvm-mc -triple x86_64-windows-msvc %s -filetype=obj -o %t.obj
# RUN: lld-link %t.obj -guard:nolongjmp -out:%t.exe -opt:noref -entry:main
# RUN: llvm-readobj -file-headers -coff-load-config %t.exe | FileCheck %s --check-prefix=CHECK-NOGC
+# RUN: lld-link %t.obj -guard:nolongjmp -out:%t.exe -opt:noref -entry:main -debug:dwarf
+# RUN: llvm-readobj -file-headers -coff-load-config %t.exe | FileCheck %s --check-prefix=CHECK-NOGC
# RUN: lld-link %t.obj -guard:nolongjmp -out:%t.exe -opt:ref -entry:main
# RUN: llvm-readobj -file-headers -coff-load-config %t.exe | FileCheck %s --check-prefix=CHECK-GC
Index: COFF/Writer.cpp
===================================================================
--- COFF/Writer.cpp
+++ COFF/Writer.cpp
@@ -606,13 +606,14 @@
if (isa<DefinedSynthetic>(Def))
return None;
- // Don't write dead symbols or symbols in codeview sections to the symbol
+ // Don't write symbols that won't be written to the output to the symbol
// table.
- if (!Def->isLive())
- return None;
- if (auto *D = dyn_cast<DefinedRegular>(Def))
- if (D->getChunk()->isCodeView())
+ OutputSection *OS = nullptr;
+ if (Chunk *C = Def->getChunk()) {
+ OS = C->getOutputSection();
+ if (!OS)
return None;
+ }
coff_symbol16 Sym;
StringRef Name = Def->getName();
@@ -640,15 +641,9 @@
Sym.SectionNumber = IMAGE_SYM_ABSOLUTE;
break;
default: {
- uint64_t RVA = Def->getRVA();
- OutputSection *Sec = nullptr;
- for (OutputSection *S : OutputSections) {
- if (S->getRVA() > RVA)
- break;
- Sec = S;
- }
- Sym.Value = RVA - Sec->getRVA();
- Sym.SectionNumber = Sec->SectionIndex;
+ assert(OS && "Writing dead symbol to symbol table");
+ Sym.Value = Def->getRVA() - OS->getRVA();
+ Sym.SectionNumber = OS->SectionIndex;
break;
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47391.148959.patch
Type: text/x-patch
Size: 3064 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180529/9b27c5c4/attachment.bin>
More information about the llvm-commits
mailing list