[llvm-branch-commits] [lld] r353157 - Merging r352928:

Hans Wennborg via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Feb 5 03:15:26 PST 2019


Author: hans
Date: Tue Feb  5 03:15:26 2019
New Revision: 353157

URL: http://llvm.org/viewvc/llvm-project?rev=353157&view=rev
Log:
Merging r352928:
------------------------------------------------------------------------
r352928 | mstorsjo | 2019-02-01 23:08:03 +0100 (Fri, 01 Feb 2019) | 9 lines

[COFF] Fix crashes when writing a PDB after adding thunks.

When writing a PDB, the OutputSection of all chunks need to be set.
The thunks are added directly to OutputSection after the normal
machinery that sets it for all other chunks.

This fixes part of PR40467.

Differential Revision: https://reviews.llvm.org/D57574
------------------------------------------------------------------------

Added:
    lld/branches/release_80/test/COFF/arm-thumb-thunks-pdb.s
      - copied unchanged from r352928, lld/trunk/test/COFF/arm-thumb-thunks-pdb.s
Modified:
    lld/branches/release_80/   (props changed)
    lld/branches/release_80/COFF/Writer.cpp

Propchange: lld/branches/release_80/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Feb  5 03:15:26 2019
@@ -1 +1 @@
-/lld/trunk:351326,351335,351898-351899,352068,352082,352257,352302,352407,352413,352435,352459,352482,352606
+/lld/trunk:351326,351335,351898-351899,352068,352082,352257,352302,352407,352413,352435,352459,352482,352606,352928

Modified: lld/branches/release_80/COFF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/branches/release_80/COFF/Writer.cpp?rev=353157&r1=353156&r2=353157&view=diff
==============================================================================
--- lld/branches/release_80/COFF/Writer.cpp (original)
+++ lld/branches/release_80/COFF/Writer.cpp Tue Feb  5 03:15:26 2019
@@ -344,14 +344,14 @@ getThunk(DenseMap<uint64_t, Defined *> &
 // After adding thunks, we verify that all relocations are in range (with
 // no extra margin requirements). If this failed, we restart (throwing away
 // the previously created thunks) and retry with a wider margin.
-static bool createThunks(std::vector<Chunk *> &Chunks, int Margin) {
+static bool createThunks(OutputSection *OS, int Margin) {
   bool AddressesChanged = false;
   DenseMap<uint64_t, Defined *> LastThunks;
   size_t ThunksSize = 0;
   // Recheck Chunks.size() each iteration, since we can insert more
   // elements into it.
-  for (size_t I = 0; I != Chunks.size(); ++I) {
-    SectionChunk *SC = dyn_cast_or_null<SectionChunk>(Chunks[I]);
+  for (size_t I = 0; I != OS->Chunks.size(); ++I) {
+    SectionChunk *SC = dyn_cast_or_null<SectionChunk>(OS->Chunks[I]);
     if (!SC)
       continue;
     size_t ThunkInsertionSpot = I + 1;
@@ -388,7 +388,8 @@ static bool createThunks(std::vector<Chu
         Chunk *ThunkChunk = Thunk->getChunk();
         ThunkChunk->setRVA(
             ThunkInsertionRVA); // Estimate of where it will be located.
-        Chunks.insert(Chunks.begin() + ThunkInsertionSpot, ThunkChunk);
+        ThunkChunk->setOutputSection(OS);
+        OS->Chunks.insert(OS->Chunks.begin() + ThunkInsertionSpot, ThunkChunk);
         ThunkInsertionSpot++;
         ThunksSize += ThunkChunk->getSize();
         ThunkInsertionRVA += ThunkChunk->getSize();
@@ -477,7 +478,7 @@ void Writer::finalizeAddresses() {
     // to avoid things going out of range due to the added thunks.
     bool AddressesChanged = false;
     for (OutputSection *Sec : OutputSections)
-      AddressesChanged |= createThunks(Sec->Chunks, Margin);
+      AddressesChanged |= createThunks(Sec, Margin);
     // If the verification above thought we needed thunks, we should have
     // added some.
     assert(AddressesChanged);




More information about the llvm-branch-commits mailing list