From 1ac1338ac8a88e6d14ddb2d5654df48e5e66f781 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Tue, 2 Feb 2016 05:55:28 +0000 Subject: [PATCH] ELF: Move code for MIPS local GOT entries to one place. NFC. llvm-svn: 259466 --- lld/ELF/Writer.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 24e5fb4..4a839e1 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -284,14 +284,19 @@ void Writer::scanRelocs( Out::RelaDyn->addReloc({&C, Rel}); } - bool NeedsGot = false; - bool NeedsMipsLocalGot = false; - bool NeedsPlt = false; + // MIPS has a special rule to create GOTs for local symbols. if (Config->EMachine == EM_MIPS && needsMipsLocalGot(Type, Body)) { - NeedsMipsLocalGot = true; // FIXME (simon): Do not add so many redundant entries. Out::Got->addMipsLocalEntry(); - } else if (Body) { + if (Body) + Body->setUsedInDynamicReloc(); + continue; + } + + bool NeedsGot = false; + bool NeedsPlt = false; + + if (Body) { if (auto *E = dyn_cast>(Body)) { if (E->NeedsCopy) continue; @@ -335,14 +340,13 @@ void Writer::scanRelocs( // relocation too because that case is possible for executable file // linking only. continue; - if (NeedsGot || NeedsMipsLocalGot) { + if (NeedsGot) { // MIPS ABI has special rules to process GOT entries // and doesn't require relocation entries for them. // See "Global Offset Table" in Chapter 5 in the following document // for detailed description: // ftp://www.linux-mips.org/pub/linux/mips/doc/ABI/mipsabi.pdf - if (NeedsGot) - Body->setUsedInDynamicReloc(); + Body->setUsedInDynamicReloc(); continue; } if (Body == Config->MipsGpDisp) -- 2.7.4