Index: lld/trunk/COFF/Chunks.cpp =================================================================== --- lld/trunk/COFF/Chunks.cpp +++ lld/trunk/COFF/Chunks.cpp @@ -58,7 +58,8 @@ return true; if (Sec->isCodeView()) return false; - fatal("SECREL relocation cannot be applied to absolute symbols"); + error("SECREL relocation cannot be applied to absolute symbols"); + return false; } static void applySecRel(const SectionChunk *Sec, uint8_t *Off, @@ -98,7 +99,7 @@ case IMAGE_REL_AMD64_SECTION: applySecIdx(Off, OS); break; case IMAGE_REL_AMD64_SECREL: applySecRel(this, Off, OS, S); break; default: - fatal("unsupported relocation type 0x" + Twine::utohexstr(Type) + " in " + + error("unsupported relocation type 0x" + Twine::utohexstr(Type) + " in " + toString(File)); } } @@ -113,7 +114,7 @@ case IMAGE_REL_I386_SECTION: applySecIdx(Off, OS); break; case IMAGE_REL_I386_SECREL: applySecRel(this, Off, OS, S); break; default: - fatal("unsupported relocation type 0x" + Twine::utohexstr(Type) + " in " + + error("unsupported relocation type 0x" + Twine::utohexstr(Type) + " in " + toString(File)); } } @@ -141,7 +142,7 @@ static void applyBranch20T(uint8_t *Off, int32_t V) { if (!isInt<21>(V)) - fatal("relocation out of range"); + error("relocation out of range"); uint32_t S = V < 0 ? 1 : 0; uint32_t J1 = (V >> 19) & 1; uint32_t J2 = (V >> 18) & 1; @@ -151,7 +152,7 @@ void applyBranch24T(uint8_t *Off, int32_t V) { if (!isInt<25>(V)) - fatal("relocation out of range"); + error("relocation out of range"); uint32_t S = V < 0 ? 1 : 0; uint32_t J1 = ((~V >> 23) & 1) ^ S; uint32_t J2 = ((~V >> 22) & 1) ^ S; @@ -176,7 +177,7 @@ case IMAGE_REL_ARM_SECTION: applySecIdx(Off, OS); break; case IMAGE_REL_ARM_SECREL: applySecRel(this, Off, OS, S); break; default: - fatal("unsupported relocation type 0x" + Twine::utohexstr(Type) + " in " + + error("unsupported relocation type 0x" + Twine::utohexstr(Type) + " in " + toString(File)); } } @@ -221,7 +222,7 @@ if ((Orig & 0x4800000) == 0x4800000) Size += 4; if ((Imm & ((1 << Size) - 1)) != 0) - fatal("misaligned ldr/str offset"); + error("misaligned ldr/str offset"); applyArm64Imm(Off, Imm >> Size, Size); } @@ -252,19 +253,19 @@ static void applyArm64Branch26(uint8_t *Off, int64_t V) { if (!isInt<28>(V)) - fatal("relocation out of range"); + error("relocation out of range"); or32(Off, (V & 0x0FFFFFFC) >> 2); } static void applyArm64Branch19(uint8_t *Off, int64_t V) { if (!isInt<21>(V)) - fatal("relocation out of range"); + error("relocation out of range"); or32(Off, (V & 0x001FFFFC) << 3); } static void applyArm64Branch14(uint8_t *Off, int64_t V) { if (!isInt<16>(V)) - fatal("relocation out of range"); + error("relocation out of range"); or32(Off, (V & 0x0000FFFC) << 3); } @@ -287,7 +288,7 @@ case IMAGE_REL_ARM64_SECREL_LOW12L: applySecRelLdr(this, Off, OS, S); break; case IMAGE_REL_ARM64_SECTION: applySecIdx(Off, OS); break; default: - fatal("unsupported relocation type 0x" + Twine::utohexstr(Type) + " in " + + error("unsupported relocation type 0x" + Twine::utohexstr(Type) + " in " + toString(File)); } } @@ -307,8 +308,10 @@ // we don't have the relocation size, which is only known after checking the // machine and relocation type. As a result, a relocation may overwrite the // beginning of the following input section. - if (Rel.VirtualAddress >= InputSize) - fatal("relocation points beyond the end of its parent section"); + if (Rel.VirtualAddress >= InputSize) { + error("relocation points beyond the end of its parent section"); + continue; + } uint8_t *Off = Buf + OutputSectionOff + Rel.VirtualAddress; @@ -326,7 +329,8 @@ check(File->getCOFFObj()->getSymbol(Rel.SymbolTableIndex)); StringRef Name; File->getCOFFObj()->getSymbolName(Sym, Name); - fatal("relocation against symbol in discarded section: " + Name); + error("relocation against symbol in discarded section: " + Name); + continue; } Chunk *C = Sym->getChunk(); OutputSection *OS = C ? C->getOutputSection() : nullptr; @@ -339,8 +343,9 @@ if (!OS && !isa(Sym) && !isa(Sym)) { if (isCodeView() || isDWARF()) continue; - fatal("relocation against symbol in discarded section: " + + error("relocation against symbol in discarded section: " + Sym->getName()); + continue; } uint64_t S = Sym->getRVA();