From b6211d9084e13d892faa6c7020561d9193b5513f Mon Sep 17 00:00:00 2001 From: Simon Atanasyan Date: Fri, 4 May 2018 20:48:53 +0000 Subject: [PATCH] [ELF][MIPS] Reorganize isMipsPIC routine. NFC llvm-svn: 331555 --- lld/ELF/Arch/Mips.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lld/ELF/Arch/Mips.cpp b/lld/ELF/Arch/Mips.cpp index 51ecb8bf30d5..f2a1aea1bb54 100644 --- a/lld/ELF/Arch/Mips.cpp +++ b/lld/ELF/Arch/Mips.cpp @@ -658,18 +658,21 @@ template bool MIPS::usesOnlyLowPageBits(RelType Type) const { // Return true if the symbol is a PIC function. template bool elf::isMipsPIC(const Defined *Sym) { - typedef typename ELFT::Ehdr Elf_Ehdr; - if (!Sym->Section || !Sym->isFunc()) + if (!Sym->isFunc()) return false; - auto *Sec = cast(Sym->Section); - ObjFile *File = Sec->template getFile(); + if (Sym->StOther & STO_MIPS_PIC) + return true; + + if (!Sym->Section) + return false; + + ObjFile *File = + cast(Sym->Section)->template getFile(); if (!File) return false; - const Elf_Ehdr *Hdr = File->getObj().getHeader(); - return (Sym->StOther & STO_MIPS_MIPS16) == STO_MIPS_PIC || - (Hdr->e_flags & EF_MIPS_PIC); + return File->getObj().getHeader()->e_flags & EF_MIPS_PIC; } template TargetInfo *elf::getMipsTargetInfo() {