Index: ELF/AArch64ErrataFix.cpp
===================================================================
--- ELF/AArch64ErrataFix.cpp
+++ ELF/AArch64ErrataFix.cpp
@@ -411,7 +411,7 @@
         continue;
       if (!IsCodeMapSymbol(Def) && !IsDataMapSymbol(Def))
         continue;
-      if (auto *Sec = dyn_cast<InputSection>(Def->Section))
+      if (auto *Sec = dyn_cast<InputSection>(Def->getSection()))
         if (Sec->Flags & SHF_EXECINSTR)
           SectionMap[Sec].push_back(Def);
     }
Index: ELF/Arch/Mips.cpp
===================================================================
--- ELF/Arch/Mips.cpp
+++ ELF/Arch/Mips.cpp
@@ -657,10 +657,10 @@
 // Return true if the symbol is a PIC function.
 template <class ELFT> bool elf::isMipsPIC(const Defined *Sym) {
   typedef typename ELFT::Ehdr Elf_Ehdr;
-  if (!Sym->Section || !Sym->isFunc())
+  if (!Sym->getSection() || !Sym->isFunc())
     return false;
 
-  auto *Sec = cast<InputSectionBase>(Sym->Section);
+  auto *Sec = cast<InputSectionBase>(Sym->getSection());
   const Elf_Ehdr *Hdr = Sec->template getFile<ELFT>()->getObj().getHeader();
   return (Sym->StOther & STO_MIPS_MIPS16) == STO_MIPS_PIC ||
          (Hdr->e_flags & EF_MIPS_PIC);
Index: ELF/GdbIndex.cpp
===================================================================
--- ELF/GdbIndex.cpp
+++ ELF/GdbIndex.cpp
@@ -80,8 +80,8 @@
 
   // FIXME: We should be consistent about always adding the file
   // offset or not.
-  if (DR->Section->Flags & ELF::SHF_ALLOC)
-    Val += cast<InputSection>(DR->Section)->getOffsetInFile();
+  if (DR->getSection()->Flags & ELF::SHF_ALLOC)
+    Val += cast<InputSection>(DR->getSection())->getOffsetInFile();
 
   return RelocAddrEntry{SecIndex, Val};
 }
Index: ELF/ICF.cpp
===================================================================
--- ELF/ICF.cpp
+++ ELF/ICF.cpp
@@ -240,17 +240,18 @@
 
     // Relocations referring to absolute symbols are constant-equal if their
     // values are equal.
-    if (!DA->Section && !DB->Section && DA->Value + AddA == DB->Value + AddB)
+    if (!DA->getSection() && !DB->getSection() &&
+        DA->Value + AddA == DB->Value + AddB)
       continue;
-    if (!DA->Section || !DB->Section)
+    if (!DA->getSection() || !DB->getSection())
       return false;
 
-    if (DA->Section->kind() != DB->Section->kind())
+    if (DA->getSection()->kind() != DB->getSection()->kind())
       return false;
 
     // Relocations referring to InputSections are constant-equal if their
     // section offsets are equal.
-    if (isa<InputSection>(DA->Section)) {
+    if (isa<InputSection>(DA->getSection())) {
       if (DA->Value + AddA == DB->Value + AddB)
         continue;
       return false;
@@ -258,10 +259,10 @@
 
     // Relocations referring to MergeInputSections are constant-equal if their
     // offsets in the output section are equal.
-    auto *X = dyn_cast<MergeInputSection>(DA->Section);
+    auto *X = dyn_cast<MergeInputSection>(DA->getSection());
     if (!X)
       return false;
-    auto *Y = cast<MergeInputSection>(DB->Section);
+    auto *Y = cast<MergeInputSection>(DB->getSection());
     if (X->getParent() != Y->getParent())
       return false;
 
@@ -311,12 +312,12 @@
     // We already dealt with absolute and non-InputSection symbols in
     // constantEq, and for InputSections we have already checked everything
     // except the equivalence class.
-    if (!DA->Section)
+    if (!DA->getSection())
       continue;
-    auto *X = dyn_cast<InputSection>(DA->Section);
+    auto *X = dyn_cast<InputSection>(DA->getSection());
     if (!X)
       continue;
-    auto *Y = cast<InputSection>(DB->Section);
+    auto *Y = cast<InputSection>(DB->getSection());
 
     // Ineligible sections are in the special equivalence class 0.
     // They can never be the same in terms of the equivalence class.
Index: ELF/InputSection.cpp
===================================================================
--- ELF/InputSection.cpp
+++ ELF/InputSection.cpp
@@ -63,9 +63,9 @@
   for (InputFile *File : ObjectFiles) {
     for (Symbol *Sym : File->getSymbols()) {
       auto *D = dyn_cast<Defined>(Sym);
-      if (!D || !D->Section)
+      if (!D || !D->getSection())
         continue;
-      int &Priority = SectionOrder[D->Section];
+      int &Priority = SectionOrder[D->getSection()];
       Priority = std::min(Priority, SymbolOrder.lookup(D->getName()));
     }
   }
@@ -249,7 +249,7 @@
   // Find a function symbol that encloses a given location.
   for (Symbol *B : File->getSymbols())
     if (auto *D = dyn_cast<Defined>(B))
-      if (D->Section == this && D->Type == STT_FUNC)
+      if (D->getSection() == this && D->Type == STT_FUNC)
         if (D->Value <= Offset && Offset < D->Value + D->Size)
           return SrcFile + ":(function " + toString(*D) + ")";
 
@@ -315,7 +315,8 @@
   // Find a symbol that encloses a given location.
   for (Symbol *B : File->getSymbols())
     if (auto *D = dyn_cast<Defined>(B))
-      if (D->Section == this && D->Value <= Off && Off < D->Value + D->Size)
+      if (D->getSection() == this && D->Value <= Off &&
+          Off < D->Value + D->Size)
         return Filename + ":(" + toString(*D) + ")" + Archive;
 
   // If there's no symbol, print out the offset in the section.
@@ -406,7 +407,7 @@
         error("STT_SECTION symbol should be defined");
         continue;
       }
-      SectionBase *Section = D->Section;
+      SectionBase *Section = D->getSection();
       if (Section == &InputSection::Discarded) {
         P->setSymbolAndType(0, 0, false);
         continue;
Index: ELF/LTO.cpp
===================================================================
--- ELF/LTO.cpp
+++ ELF/LTO.cpp
@@ -145,7 +145,7 @@
     // flags an undefined in IR with a definition in ASM as prevailing.
     // Once IRObjectFile is fixed to report only one symbol this hack can
     // be removed.
-    R.Prevailing = !ObjSym.isUndefined() && Sym->File == &F;
+    R.Prevailing = !ObjSym.isUndefined() && Sym->getFile() == &F;
 
     // We ask LTO to preserve following global symbols:
     // 1) All symbols when doing relocatable link, so that them can be used
Index: ELF/LinkerScript.cpp
===================================================================
--- ELF/LinkerScript.cpp
+++ ELF/LinkerScript.cpp
@@ -167,10 +167,10 @@
 
   ExprValue V = Cmd->Expression();
   if (V.isAbsolute()) {
-    Cmd->Sym->Section = nullptr;
+    Cmd->Sym->SectionOrFile = (InputSectionBase *)nullptr;
     Cmd->Sym->Value = V.getValue();
   } else {
-    Cmd->Sym->Section = V.Sec;
+    Cmd->Sym->SectionOrFile = V.Sec;
     Cmd->Sym->Value = V.getSectionOffset();
   }
 }
@@ -985,10 +985,10 @@
 
   if (Symbol *Sym = Symtab->find(Name)) {
     if (auto *DS = dyn_cast<Defined>(Sym))
-      return {DS->Section, false, DS->Value, Loc};
+      return {DS->getSection(), false, DS->Value, Loc};
     if (auto *SS = dyn_cast<SharedSymbol>(Sym))
-      if (!ErrorOnMissingSection || SS->CopyRelSec)
-        return {SS->CopyRelSec, false, 0, Loc};
+      if (!ErrorOnMissingSection || SS->getSection())
+        return {SS->getSection(), false, 0, Loc};
   }
 
   error(Loc + ": symbol not found: " + Name);
Index: ELF/MapFile.cpp
===================================================================
--- ELF/MapFile.cpp
+++ ELF/MapFile.cpp
@@ -52,12 +52,12 @@
   std::vector<Symbol *> V;
   for (InputFile *File : ObjectFiles) {
     for (Symbol *B : File->getSymbols()) {
+      auto *Sec = dyn_cast_or_null<InputSectionBase>(B->getSection());
       if (auto *SS = dyn_cast<SharedSymbol>(B))
-        if (SS->CopyRelSec || SS->NeedsPltAddr)
+        if (Sec || SS->NeedsPltAddr)
           V.push_back(SS);
       if (auto *DR = dyn_cast<Defined>(B))
-        if (DR->File == File && !DR->isSection() && DR->Section &&
-            DR->Section->Live)
+        if (Sec && Sec->File == File && !DR->isSection() && Sec->Live)
           V.push_back(DR);
     }
   }
@@ -68,14 +68,8 @@
 static SymbolMapTy getSectionSyms(ArrayRef<Symbol *> Syms) {
   SymbolMapTy Ret;
   for (Symbol *S : Syms) {
-    if (auto *DR = dyn_cast<Defined>(S)) {
-      Ret[DR->Section].push_back(S);
-      continue;
-    }
-
-    SharedSymbol *SS = cast<SharedSymbol>(S);
-    if (SS->CopyRelSec)
-      Ret[SS->CopyRelSec].push_back(S);
+    if (auto *Sec = S->getSection())
+      Ret[Sec].push_back(S);
     else
       Ret[InX::Plt].push_back(S);
   }
Index: ELF/MarkLive.cpp
===================================================================
--- ELF/MarkLive.cpp
+++ ELF/MarkLive.cpp
@@ -71,7 +71,7 @@
       SS->getFile<ELFT>()->IsNeeded = true;
 
   if (auto *D = dyn_cast<Defined>(&B)) {
-    auto *RelSec = dyn_cast_or_null<InputSectionBase>(D->Section);
+    auto *RelSec = dyn_cast_or_null<InputSectionBase>(D->getSection());
     if (!RelSec)
       return;
     uint64_t Offset = D->Value;
@@ -220,7 +220,7 @@
 
   auto MarkSymbol = [&](Symbol *Sym) {
     if (auto *D = dyn_cast_or_null<Defined>(Sym))
-      if (auto *IS = dyn_cast_or_null<InputSectionBase>(D->Section))
+      if (auto *IS = dyn_cast_or_null<InputSectionBase>(D->getSection()))
         Enqueue(IS, D->Value);
   };
 
Index: ELF/Relocations.cpp
===================================================================
--- ELF/Relocations.cpp
+++ ELF/Relocations.cpp
@@ -74,7 +74,7 @@
 static std::string getLocation(InputSectionBase &S, const Symbol &Sym,
                                uint64_t Off) {
   std::string Msg =
-      "\n>>> defined in " + toString(Sym.File) + "\n>>> referenced by ";
+      "\n>>> defined in " + toString(Sym.getFile()) + "\n>>> referenced by ";
   std::string Src = S.getSrcMsg<ELFT>(Sym, Off);
   if (!Src.empty())
     Msg += Src + "\n>>>               ";
@@ -327,7 +327,7 @@
   if (Sym.isUndefWeak())
     return true;
   if (const auto *DR = dyn_cast<Defined>(&Sym))
-    return DR->Section == nullptr; // Absolute symbol.
+    return DR->getSection() == nullptr; // Absolute symbol.
   return false;
 }
 
@@ -529,6 +529,7 @@
   bool IsReadOnly = isReadOnly<ELFT>(SS);
   BssSection *Sec = make<BssSection>(IsReadOnly ? ".bss.rel.ro" : ".bss",
                                      SymSize, SS->Alignment);
+  Sec->File = SS->getFile<ELFT>();
   if (IsReadOnly)
     InX::BssRelRo->getParent()->addSection(Sec);
   else
@@ -538,7 +539,7 @@
   // dynamic symbol for each one. This causes the copy relocation to correctly
   // interpose any aliases.
   for (SharedSymbol *Sym : getSymbolsAt<ELFT>(SS)) {
-    Sym->CopyRelSec = Sec;
+    Sym->SectionOrFile = Sec;
     Sym->IsPreemptible = false;
     Sym->IsUsedInRegularObj = true;
     Sym->Used = true;
@@ -602,7 +603,7 @@
   if (Sym.isObject()) {
     // Produce a copy relocation.
     auto *B = dyn_cast<SharedSymbol>(&Sym);
-    if (B && !B->CopyRelSec) {
+    if (B && !B->getSection()) {
       if (Config->ZNocopyreloc)
         error("unresolvable relocation " + toString(Type) +
               " against symbol '" + toString(*B) +
@@ -641,7 +642,7 @@
   }
 
   errorOrWarn("symbol '" + toString(Sym) + "' defined in " +
-              toString(Sym.File) + " has no type");
+              toString(Sym.getFile()) + " has no type");
   return Expr;
 }
 
Index: ELF/SymbolTable.cpp
===================================================================
--- ELF/SymbolTable.cpp
+++ ELF/SymbolTable.cpp
@@ -272,7 +272,7 @@
   if (!WasInserted && S->Type != Symbol::UnknownType &&
       ((Type == STT_TLS) != S->isTls())) {
     error("TLS attribute mismatch: " + toString(*S) + "\n>>> defined in " +
-          toString(S->File) + "\n>>> defined in " + toString(File));
+          toString(S->getFile()) + "\n>>> defined in " + toString(File));
   }
 
   return {S, WasInserted};
@@ -362,13 +362,13 @@
   if (int Cmp = compareDefined(S, WasInserted, Binding, Name))
     return Cmp;
   if (auto *R = dyn_cast<Defined>(S)) {
-    if (R->Section && isa<BssSection>(R->Section)) {
+    if (R->getSection() && isa<BssSection>(R->getSection())) {
       // Non-common symbols take precedence over common symbols.
       if (Config->WarnCommon)
         warn("common " + S->getName() + " is overridden");
       return 1;
     }
-    if (R->Section == nullptr && Binding == STB_GLOBAL && IsAbsolute &&
+    if (R->getSection() == nullptr && Binding == STB_GLOBAL && IsAbsolute &&
         R->Value == Value)
       return -1;
   }
@@ -392,7 +392,7 @@
     replaceSymbol<Defined>(S, File, N, Binding, StOther, Type, 0, Size, Bss);
   } else if (Cmp == 0) {
     auto *D = cast<Defined>(S);
-    auto *Bss = dyn_cast_or_null<BssSection>(D->Section);
+    auto *Bss = dyn_cast_or_null<BssSection>(D->getSection());
     if (!Bss) {
       // Non-common symbols take precedence over common symbols.
       if (Config->WarnCommon)
@@ -405,7 +405,7 @@
 
     Bss->Alignment = std::max(Bss->Alignment, Alignment);
     if (Size > Bss->Size) {
-      D->File = Bss->File = File;
+      Bss->File = File;
       D->Size = Bss->Size = Size;
     }
   }
@@ -421,14 +421,15 @@
 
 static void reportDuplicate(Symbol *Sym, InputFile *NewFile) {
   warnOrError("duplicate symbol: " + toString(*Sym) + "\n>>> defined in " +
-              toString(Sym->File) + "\n>>> defined in " + toString(NewFile));
+              toString(Sym->getFile()) + "\n>>> defined in " +
+              toString(NewFile));
 }
 
 template <class ELFT>
 static void reportDuplicate(Symbol *Sym, InputSectionBase *ErrSec,
                             typename ELFT::uint ErrOffset) {
   Defined *D = cast<Defined>(Sym);
-  if (!D->Section || !ErrSec) {
+  if (!D->getSection() || !ErrSec) {
     reportDuplicate(Sym, ErrSec ? ErrSec->File : nullptr);
     return;
   }
@@ -440,7 +441,7 @@
   //   >>>            bar.o (/home/alice/src/bar.o)
   //   >>> defined at baz.c:563
   //   >>>            baz.o in archive libbaz.a
-  auto *Sec1 = cast<InputSectionBase>(D->Section);
+  auto *Sec1 = cast<InputSectionBase>(D->getSection());
   std::string Src1 = Sec1->getSrcMsg<ELFT>(*Sym, D->Value);
   std::string Obj1 = Sec1->getObjMsg(D->Value);
   std::string Src2 = ErrSec->getSrcMsg<ELFT>(*Sym, ErrOffset);
Index: ELF/Symbols.h
===================================================================
--- ELF/Symbols.h
+++ ELF/Symbols.h
@@ -15,6 +15,7 @@
 #ifndef LLD_ELF_SYMBOLS_H
 #define LLD_ELF_SYMBOLS_H
 
+#include "InputFiles.h"
 #include "InputSection.h"
 #include "Strings.h"
 
@@ -84,8 +85,17 @@
   // This symbol version was found in a version script.
   unsigned InVersionScript : 1;
 
-  // The file from which this symbol was created.
-  InputFile *File;
+  // For symbols that don't have a section we store the file in here. If they do
+  // have a section the file can be found via the section.
+  llvm::PointerUnion<SectionBase *, InputFile *> SectionOrFile;
+  InputFile *getFile() const {
+    if (auto *Sec = dyn_cast_or_null<InputSectionBase>(getSection()))
+      return Sec->File;
+    return SectionOrFile.dyn_cast<InputFile *>();
+  }
+  SectionBase *getSection() const {
+    return SectionOrFile.dyn_cast<SectionBase *>();
+  }
 
   bool includeInDynsym() const;
   uint8_t computeBinding() const;
@@ -130,10 +140,10 @@
 protected:
   Symbol(Kind K, InputFile *File, StringRefZ Name, uint8_t Binding,
          uint8_t StOther, uint8_t Type)
-      : Binding(Binding), File(File), SymbolKind(K), NeedsPltAddr(false),
-        IsInGlobalMipsGot(false), Is32BitMipsGot(false), IsInIplt(false),
-        IsInIgot(false), IsPreemptible(false), Used(!Config->GcSections),
-        Type(Type), StOther(StOther), Name(Name) {}
+      : Binding(Binding), SectionOrFile(File), SymbolKind(K),
+        NeedsPltAddr(false), IsInGlobalMipsGot(false), Is32BitMipsGot(false),
+        IsInIplt(false), IsInIgot(false), IsPreemptible(false),
+        Used(!Config->GcSections), Type(Type), StOther(StOther), Name(Name) {}
 
   const unsigned SymbolKind : 8;
 
@@ -186,13 +196,15 @@
   Defined(InputFile *File, StringRefZ Name, uint8_t Binding, uint8_t StOther,
           uint8_t Type, uint64_t Value, uint64_t Size, SectionBase *Section)
       : Symbol(DefinedKind, File, Name, Binding, StOther, Type), Value(Value),
-        Size(Size), Section(Section) {}
+        Size(Size) {
+    if (Section)
+      SectionOrFile = Section;
+  }
 
   static bool classof(const Symbol *S) { return S->isDefined(); }
 
   uint64_t Value;
   uint64_t Size;
-  SectionBase *Section;
 };
 
 class Undefined : public Symbol {
@@ -234,12 +246,9 @@
   }
 
   template <class ELFT> SharedFile<ELFT> *getFile() const {
-    return cast<SharedFile<ELFT>>(File);
+    return cast<SharedFile<ELFT>>(Symbol::getFile());
   }
 
-  // If not null, there is a copy relocation to this section.
-  InputSection *CopyRelSec = nullptr;
-
   uint64_t Value; // st_value
   uint64_t Size;  // st_size
 
Index: ELF/Symbols.cpp
===================================================================
--- ELF/Symbols.cpp
+++ ELF/Symbols.cpp
@@ -44,7 +44,7 @@
   switch (Sym.kind()) {
   case Symbol::DefinedKind: {
     auto &D = cast<Defined>(Sym);
-    SectionBase *IS = D.Section;
+    SectionBase *IS = D.getSection();
     if (auto *ISB = dyn_cast_or_null<InputSectionBase>(IS))
       IS = ISB->Repl;
 
@@ -93,7 +93,7 @@
 
     if (D.isTls() && !Config->Relocatable) {
       if (!Out::TlsPhdr)
-        fatal(toString(D.File) +
+        fatal(toString(D.getFile()) +
               " has an STT_TLS symbol but doesn't have an SHF_TLS section");
       return VA - Out::TlsPhdr->p_vaddr;
     }
@@ -101,8 +101,8 @@
   }
   case Symbol::SharedKind: {
     auto &SS = cast<SharedSymbol>(Sym);
-    if (SS.CopyRelSec)
-      return SS.CopyRelSec->getParent()->Addr + SS.CopyRelSec->OutSecOff;
+    if (auto Sec = dyn_cast_or_null<InputSection>(SS.getSection()))
+      return Sec->getParent()->Addr + Sec->OutSecOff;
     if (SS.NeedsPltAddr)
       return Sym.getPltVA();
     return 0;
@@ -160,18 +160,8 @@
 }
 
 OutputSection *Symbol::getOutputSection() const {
-  if (auto *S = dyn_cast<Defined>(this)) {
-    if (S->Section)
-      return S->Section->getOutputSection();
-    return nullptr;
-  }
-
-  if (auto *S = dyn_cast<SharedSymbol>(this)) {
-    if (S->CopyRelSec)
-      return S->CopyRelSec->getParent();
-    return nullptr;
-  }
-
+  if (auto *Sec = getSection())
+    return Sec->getOutputSection();
   return nullptr;
 }
 
@@ -215,7 +205,7 @@
   // but we may still want to override a versioned symbol from DSO,
   // so we do not report error in this case.
   if (Config->Shared)
-    error(toString(File) + ": symbol " + S + " has undefined version " +
+    error(toString(getFile()) + ": symbol " + S + " has undefined version " +
           Verstr);
 }
 
@@ -225,7 +215,9 @@
   return cast<LazyObject>(this)->fetch();
 }
 
-ArchiveFile *LazyArchive::getFile() { return cast<ArchiveFile>(File); }
+ArchiveFile *LazyArchive::getFile() {
+  return cast<ArchiveFile>(Symbol::getFile());
+}
 
 InputFile *LazyArchive::fetch() {
   std::pair<MemoryBufferRef, uint64_t> MBInfo = getFile()->getMember(&Sym);
@@ -237,7 +229,9 @@
   return createObjectFile(MBInfo.first, getFile()->getName(), MBInfo.second);
 }
 
-LazyObjFile *LazyObject::getFile() { return cast<LazyObjFile>(File); }
+LazyObjFile *LazyObject::getFile() {
+  return cast<LazyObjFile>(Symbol::getFile());
+}
 
 InputFile *LazyObject::fetch() { return getFile()->fetch(); }
 
@@ -272,12 +266,12 @@
     S = ": lazy definition of ";
   else if (Sym->isShared())
     S = ": shared definition of ";
-  else if (dyn_cast_or_null<BssSection>(cast<Defined>(Sym)->Section))
+  else if (dyn_cast_or_null<BssSection>(cast<Defined>(Sym)->getSection()))
     S = ": common definition of ";
   else
     S = ": definition of ";
 
-  message(toString(Sym->File) + S + Sym->getName());
+  message(toString(Sym->getFile()) + S + Sym->getName());
 }
 
 // Returns a symbol for an error message.
Index: ELF/SyntheticSections.cpp
===================================================================
--- ELF/SyntheticSections.cpp
+++ ELF/SyntheticSections.cpp
@@ -430,7 +430,7 @@
 
   // FDEs for garbage-collected or merged-by-ICF sections are dead.
   if (auto *D = dyn_cast<Defined>(&B))
-    if (auto *Sec = cast_or_null<InputSectionBase>(D->Section))
+    if (auto *Sec = cast_or_null<InputSectionBase>(D->getSection()))
       return Sec->Live && (Sec == Sec->Repl);
   return false;
 }
@@ -1597,7 +1597,7 @@
     BssSection *CommonSec = nullptr;
     if (!Config->DefineCommon)
       if (auto *D = dyn_cast<Defined>(Sym))
-        CommonSec = dyn_cast_or_null<BssSection>(D->Section);
+        CommonSec = dyn_cast_or_null<BssSection>(D->getSection());
     if (CommonSec)
       ESym->st_shndx = SHN_COMMON;
     else if (const OutputSection *OutSec = Sym->getOutputSection())
@@ -1786,7 +1786,7 @@
         // Shared symbols that this executable preempts are special. The dynamic
         // linker has to look them up, so they have to be in the hash table.
         if (auto *SS = dyn_cast<SharedSymbol>(S.Sym))
-          return SS->CopyRelSec == nullptr && !SS->NeedsPltAddr;
+          return SS->getSection() == nullptr && !SS->NeedsPltAddr;
         return !S.Sym->isDefined();
       });
   if (Mid == V.end())
Index: ELF/Thunks.cpp
===================================================================
--- ELF/Thunks.cpp
+++ ELF/Thunks.cpp
@@ -323,7 +323,7 @@
 
 InputSection *MipsThunk::getTargetInputSection() const {
   auto &DR = cast<Defined>(Destination);
-  return dyn_cast<InputSection>(DR.Section);
+  return dyn_cast<InputSection>(DR.getSection());
 }
 
 // Write microMIPS R2-R5 LA25 thunk code
@@ -348,7 +348,7 @@
 
 InputSection *MicroMipsThunk::getTargetInputSection() const {
   auto &DR = cast<Defined>(Destination);
-  return dyn_cast<InputSection>(DR.Section);
+  return dyn_cast<InputSection>(DR.getSection());
 }
 
 // Write microMIPS R6 LA25 thunk code
@@ -373,7 +373,7 @@
 
 InputSection *MicroMipsR6Thunk::getTargetInputSection() const {
   auto &DR = cast<Defined>(Destination);
-  return dyn_cast<InputSection>(DR.Section);
+  return dyn_cast<InputSection>(DR.getSection());
 }
 
 Thunk::Thunk(Symbol &D) : Destination(D), Offset(0) {}
Index: ELF/Writer.cpp
===================================================================
--- ELF/Writer.cpp
+++ ELF/Writer.cpp
@@ -284,8 +284,8 @@
   // This makes sure our relro is contiguous.
   bool HasDataRelRo =
       Script->HasSectionsCommand && findSection(".data.rel.ro");
-  InX::BssRelRo = make<BssSection>(
-      HasDataRelRo ? ".data.rel.ro.bss" : ".bss.rel.ro", 0, 1);
+  InX::BssRelRo =
+      make<BssSection>(HasDataRelRo ? ".data.rel.ro.bss" : ".bss.rel.ro", 0, 1);
   Add(InX::BssRelRo);
 
   // Add MIPS-specific sections.
@@ -513,7 +513,7 @@
 
   if (auto *D = dyn_cast<Defined>(&B)) {
     // Always include absolute symbols.
-    SectionBase *Sec = D->Section;
+    SectionBase *Sec = D->getSection();
     if (!Sec)
       return true;
     if (auto *IS = dyn_cast<InputSectionBase>(Sec)) {
@@ -550,7 +550,7 @@
       if (!includeInSymtab(*B))
         continue;
 
-      SectionBase *Sec = DR->Section;
+      SectionBase *Sec = DR->getSection();
       if (!shouldKeepInSymtab(Sec, B->getName(), *B))
         continue;
       InX::SymTab->addSymbol(B);
@@ -865,7 +865,7 @@
     // of the .got
     InputSection *GotSection = InX::MipsGot ? cast<InputSection>(InX::MipsGot)
                                             : cast<InputSection>(InX::Got);
-    ElfSym::GlobalOffsetTable->Section = GotSection;
+    ElfSym::GlobalOffsetTable->SectionOrFile = GotSection;
   }
 
   PhdrEntry *Last = nullptr;
@@ -882,9 +882,9 @@
   if (LastRO) {
     // _etext is the first location after the last read-only loadable segment.
     if (ElfSym::Etext1)
-      ElfSym::Etext1->Section = LastRO->LastSec;
+      ElfSym::Etext1->SectionOrFile = LastRO->LastSec;
     if (ElfSym::Etext2)
-      ElfSym::Etext2->Section = LastRO->LastSec;
+      ElfSym::Etext2->SectionOrFile = LastRO->LastSec;
   }
 
   if (Last) {
@@ -898,19 +898,19 @@
     }
 
     if (ElfSym::Edata1)
-      ElfSym::Edata1->Section = Edata;
+      ElfSym::Edata1->SectionOrFile = Edata;
     if (ElfSym::Edata2)
-      ElfSym::Edata2->Section = Edata;
+      ElfSym::Edata2->SectionOrFile = Edata;
 
     // _end is the first location after the uninitialized data region.
     if (ElfSym::End1)
-      ElfSym::End1->Section = Last->LastSec;
+      ElfSym::End1->SectionOrFile = Last->LastSec;
     if (ElfSym::End2)
-      ElfSym::End2->Section = Last->LastSec;
+      ElfSym::End2->SectionOrFile = Last->LastSec;
   }
 
   if (ElfSym::Bss)
-    ElfSym::Bss->Section = findSection(".bss");
+    ElfSym::Bss->SectionOrFile = findSection(".bss");
 
   // Setup MIPS _gp_disp/__gnu_local_gp symbols which should
   // be equal to the _gp symbol's value.
@@ -919,7 +919,7 @@
     // and use this address to calculate default _gp value.
     for (OutputSection *OS : OutputSections) {
       if (OS->Flags & SHF_MIPS_GPREL) {
-        ElfSym::MipsGp->Section = OS;
+        ElfSym::MipsGp->SectionOrFile = OS;
         ElfSym::MipsGp->Value = 0x7ff0;
         break;
       }
@@ -1325,7 +1325,7 @@
     if (InX::DynSymTab && Sym->includeInDynsym()) {
       InX::DynSymTab->addSymbol(Sym);
       if (auto *SS = dyn_cast<SharedSymbol>(Sym))
-        if (cast<SharedFile<ELFT>>(Sym->File)->IsNeeded)
+        if (cast<SharedFile<ELFT>>(Sym->getFile())->IsNeeded)
           In<ELFT>::VerNeed->addSymbol(SS);
     }
   }
Index: test/ELF/map-file.s
===================================================================
--- test/ELF/map-file.s
+++ test/ELF/map-file.s
@@ -75,9 +75,9 @@
 // CHECK-NEXT: 0000000000204000 0000000000000010    16 .bss
 // CHECK-NEXT: 0000000000204000 0000000000000004    16         {{.*}}{{/|\\}}map-file.s.tmp1.o:(COMMON)
 // CHECK-NEXT: 0000000000204000 0000000000000004     0                 common
-// CHECK-NEXT: 0000000000204004 0000000000000004     1         <internal>:(.bss)
+// CHECK-NEXT: 0000000000204004 0000000000000004     1         {{.*}}map-file.s.tmp5.so:(.bss)
 // CHECK-NEXT: 0000000000204004 0000000000000004     0                 sharedFoo
-// CHECK-NEXT: 0000000000204008 0000000000000008     1         <internal>:(.bss)
+// CHECK-NEXT: 0000000000204008 0000000000000008     1         {{.*}}map-file.s.tmp5.so:(.bss)
 // CHECK-NEXT: 0000000000204008 0000000000000008     0                 sharedBar
 // CHECK-NEXT: 0000000000000000 0000000000000008     1 .comment
 // CHECK-NEXT: 0000000000000000 0000000000000008     1         <internal>:(.comment)
Index: test/ELF/relro-script.s
===================================================================
--- test/ELF/relro-script.s
+++ test/ELF/relro-script.s
@@ -19,7 +19,7 @@
 // RUN: ld.lld %t3.o %t.so -o %t --script=%t.script --print-map | FileCheck %s
 
 // CHECK: .data.rel.ro
-// CHECK-NEXT: <internal>:(.bss.rel.ro)
+// CHECK-NEXT: relro-script.s.tmp.so:(.bss.rel.ro)
         .section .text, "ax", @progbits
         .global _start
         .global bar