for (std::unique_ptr<InputElement> &ei : _elements)
if (error_code ec = ei->parse(ctx, diag))
return ec;
- return error_code::success();
+ return error_code();
}
/// If Resolver made a progress using the current file, it's ok to revisit
/// \brief parse the input element
error_code parse(const LinkingContext &, raw_ostream &) override {
- return error_code::success();
+ return error_code();
}
/// \brief Return the next File thats part of this node to the
} else {
// if --whole-archive is around non-archive, just use it as normal.
_files.push_back(std::move(f));
- return error_code::success();
+ return error_code();
}
}
return ctx.registry().parseFile(_buffer, _files);
if (error_code ec = MemoryBuffer::getFileOrSTDIN(filePath, mb))
return ec;
_buffer = std::move(mb);
- return error_code::success();
+ return error_code();
}
/// \brief Return the next file that need to be processed by the resolver.
error_code PassManager::runOnFile(std::unique_ptr<MutableFile> &mf) {
for (std::unique_ptr<Pass> &pass : _passes)
pass->perform(mf);
- return error_code::success();
+ return error_code();
}
} // end namespace lld
case llvm::sys::fs::file_magic::elf_relocatable:
case llvm::sys::fs::file_magic::elf_shared_object:
case llvm::sys::fs::file_magic::unknown:
- return error_code::success();
+ return error_code();
default:
break;
}
}
// if --whole-archive is around non-archive, just use it as normal.
_files.push_back(std::move(f));
- return error_code::success();
+ return error_code();
}
return ctx.registry().parseFile(_buffer, _files);
}
if (!_linkerScript)
return LinkerScriptReaderError::parse_error;
- return error_code::success();
+ return error_code();
}
static bool isPathUnderSysroot(StringRef sysroot, StringRef path) {
}
_expandElements.push_back(std::move(groupStart));
}
- return error_code::success();
+ return error_code();
}
error_code PECOFFFileNode::parse(const LinkingContext &ctx,
raw_ostream &diagnostics) {
if (_parsed)
- return error_code::success();
+ return error_code();
_parsed = true;
ErrorOr<StringRef> filePath = getPath(ctx);
if (error_code ec = filePath.getError()) {
}
}
_references.reserve(totalRelocs);
- return error_code::success();
+ return error_code();
}
template <class ELFT> error_code ELFFile<ELFT>::createMergeableAtoms() {
_definedAtoms._atoms.push_back(*mergeAtom);
_mergeAtoms.push_back(*mergeAtom);
}
- return error_code::success();
+ return error_code();
}
template <class ELFT>
}
}
- return error_code::success();
+ return error_code();
}
template <class ELFT> error_code ELFFile<ELFT>::createAtoms() {
}
updateReferences();
- return error_code::success();
+ return error_code();
}
template <class ELFT>
if (error_code ec = f.getError())
return ec;
result.push_back(std::move(*f));
- return error_code::success();
+ return error_code();
}
protected:
if (error_code ec = f.getError())
return ec;
result.push_back(std::move(*f));
- return error_code::success();
+ return error_code();
}
protected:
virtual error_code setELFHeader() {
DynamicLibraryWriter<ELFT>::setELFHeader();
HexagonELFWriter<ELFT>::setELFHeader(*this->_elfHeader);
- return error_code::success();
+ return error_code();
}
private:
if (error_code ec = f.getError())
return ec;
result.push_back(std::move(*f));
- return error_code::success();
+ return error_code();
}
};
if (error_code ec = f.getError())
return ec;
result.push_back(std::move(*f));
- return error_code::success();
+ return error_code();
}
};
virtual error_code setELFHeader() {
ExecutableWriter<ELFT>::setELFHeader();
HexagonELFWriter<ELFT>::setELFHeader(*this->_elfHeader);
- return error_code::success();
+ return error_code();
}
private:
uint64_t relocVAddress = atom._virtualAddr + ref.offsetInAtom();
if (ref.kindNamespace() != Reference::KindNamespace::ELF)
- return error_code::success();
+ return error_code();
assert(ref.kindArch() == Reference::KindArch::Hexagon);
switch (ref.kindValue()) {
case R_HEX_B22_PCREL:
}
}
- return error_code::success();
+ return error_code();
}
error_code handleGOTREL(const Reference &ref) {
// Turn this so that the target is set to the GOT entry
const_cast<Reference &>(ref).setTarget(getGOTEntry(ref.target()));
- return error_code::success();
+ return error_code();
}
error_code handlePLT32(const Reference &ref) {
assert(ref.kindArch() == Reference::KindArch::Hexagon);
const_cast<Reference &>(ref).setKindValue(R_HEX_B22_PCREL);
const_cast<Reference &>(ref).setTarget(getPLTEntry(ref.target()));
- return error_code::success();
+ return error_code();
}
};
error_code setELFHeader() override {
DynamicLibraryWriter<ELFT>::setELFHeader();
_writeHelper.setELFHeader(*this->_elfHeader);
- return error_code::success();
+ return error_code();
}
LLD_UNIQUE_BUMP_PTR(DynamicTable<ELFT>) createDynamicTable();
} else if (!_tpOff.hasValue() && section.sh_flags & llvm::ELF::SHF_TLS)
_tpOff = section.sh_addr + TP_OFFSET;
}
- return error_code::success();
+ return error_code();
}
void createRelocationReferences(const Elf_Sym &symbol,
if (error_code ec = f.getError())
return ec;
result.push_back(std::move(*f));
- return error_code::success();
+ return error_code();
}
};
error_code setELFHeader() override {
ExecutableWriter<ELFT>::setELFHeader();
_writeHelper.setELFHeader(*this->_elfHeader);
- return error_code::success();
+ return error_code();
}
LLD_UNIQUE_BUMP_PTR(DynamicTable<ELFT>) createDynamicTable();
ELFWriter &writer, llvm::FileOutputBuffer &buf, const lld::AtomLayout &atom,
const Reference &ref) const {
if (ref.kindNamespace() != lld::Reference::KindNamespace::ELF)
- return error_code::success();
+ return error_code();
assert(ref.kindArch() == Reference::KindArch::Mips);
AtomLayout *gpAtom = _mipsTargetLayout.getGP();
}
}
- return error_code::success();
+ return error_code();
}
if (_context.isDynamic())
_dynamicTable->updateDynamicTable();
- return error_code::success();
+ return error_code();
}
template <class ELFT> error_code OutputELFWriter<ELFT>::setELFHeader() {
_layout.findAtomAddrByName(_context.entrySymbolName(), virtualAddr);
_elfHeader->e_entry(virtualAddr);
- return error_code::success();
+ return error_code();
}
template <class ELFT> uint64_t OutputELFWriter<ELFT>::outputFileSize() const {
if (!f)
return f;
result.push_back(std::move(*f));
- return error_code::success();
+ return error_code();
}
};
if (!f)
return f;
result.push_back(std::move(*f));
- return error_code::success();
+ return error_code();
}
};
uint64_t relocVAddress = atom._virtualAddr + ref.offsetInAtom();
if (ref.kindNamespace() != Reference::KindNamespace::ELF)
- return error_code::success();
+ return error_code();
assert(ref.kindArch() == Reference::KindArch::PowerPC);
switch (ref.kindValue()) {
case R_PPC_REL24:
}
}
- return error_code::success();
+ return error_code();
}
PPCTargetHandler::PPCTargetHandler(PPCLinkingContext &context)
uint64_t relocVAddress = atom._virtualAddr + ref.offsetInAtom();
if (ref.kindNamespace() != Reference::KindNamespace::ELF)
- return error_code::success();
+ return error_code();
assert(ref.kindArch() == Reference::KindArch::x86);
switch (ref.kindValue()) {
case R_386_32:
}
}
- return error_code::success();
+ return error_code();
}
X86TargetHandler::X86TargetHandler(X86LinkingContext &context)
uint64_t relocVAddress = atom._virtualAddr + ref.offsetInAtom();
if (ref.kindNamespace() != Reference::KindNamespace::ELF)
- return error_code::success();
+ return error_code();
assert(ref.kindArch() == Reference::KindArch::x86_64);
switch (ref.kindValue()) {
case R_X86_64_NONE:
}
}
- return error_code::success();
+ return error_code();
}
auto target = dyn_cast_or_null<const DefinedAtom>(ref.target());
if (target && target->contentType() == DefinedAtom::typeResolver)
const_cast<Reference &>(ref).setTarget(getIFUNCPLTEntry(target));
- return error_code::success();
+ return error_code();
}
/// \brief Create a GOT entry for the TP offset of a TLS atom.
// __tls_get_addr is handled elsewhere.
if (ref.target() && ref.target()->name() == "__tls_get_addr") {
const_cast<Reference &>(ref).setKindValue(R_X86_64_NONE);
- return error_code::success();
+ return error_code();
}
// Static code doesn't need PLTs.
const_cast<Reference &>(ref).setKindValue(R_X86_64_PC32);
dyn_cast_or_null<const DefinedAtom>(ref.target()))
if (da->contentType() == DefinedAtom::typeResolver)
return handleIFUNC(ref);
- return error_code::success();
+ return error_code();
}
error_code handleGOT(const Reference &ref) {
const_cast<Reference &>(ref).setTarget(getNullGOT());
else if (const DefinedAtom *da = dyn_cast<const DefinedAtom>(ref.target()))
const_cast<Reference &>(ref).setTarget(getGOT(da));
- return error_code::success();
+ return error_code();
}
};
error_code handlePlain(const Reference &ref) {
if (!ref.target())
- return error_code::success();
+ return error_code();
if (auto sla = dyn_cast<SharedLibraryAtom>(ref.target())) {
if (sla->type() == SharedLibraryAtom::Type::Data)
const_cast<Reference &>(ref).setTarget(getObjectEntry(sla));
const_cast<Reference &>(ref).setTarget(getPLTEntry(sla));
} else
return handleIFUNC(ref);
- return error_code::success();
+ return error_code();
}
error_code handlePLT32(const Reference &ref) {
return handleIFUNC(ref);
if (isa<const SharedLibraryAtom>(ref.target()))
const_cast<Reference &>(ref).setTarget(getPLTEntry(ref.target()));
- return error_code::success();
+ return error_code();
}
const GOTAtom *getSharedGOT(const SharedLibraryAtom *sla) {
const_cast<Reference &>(ref).setTarget(getGOT(da));
else if (const auto sla = dyn_cast<const SharedLibraryAtom>(ref.target()))
const_cast<Reference &>(ref).setTarget(getSharedGOT(sla));
- return error_code::success();
+ return error_code();
}
};
} // end anon namespace
if (error_code ec = instantiateMember(mf, result))
return ec;
}
- return error_code::success();
+ return error_code();
}
const atom_collection<DefinedAtom> &defined() const override {
_registry.parseFile(mb, result);
const char *memberStart = member->getBuffer().data();
_membersInstantiated.insert(memberStart);
- return error_code::success();
+ return error_code();
}
error_code isDataSymbol(std::unique_ptr<MemoryBuffer> mb, StringRef symbol) const {
return ec;
if (symtype == SymbolRef::ST_Data) {
- return error_code::success();
+ return error_code();
}
}
return object_error::parse_failed;
<< "'" << name << "'\n");
_symbolMemberMap[name] = member;
}
- return error_code::success();
+ return error_code();
}
}; // class FileArchive
mb.release();
result.push_back(std::move(file));
- return error_code::success();
+ return error_code();
}
private:
return llvm::make_error_code(llvm::errc::executable_format_error);
if (func(slc->cmd, slc->cmdsize, p))
- return error_code::success();
+ return error_code();
p += slc->cmdsize;
}
- return error_code::success();
+ return error_code();
}
for(uint32_t i=0; i < nreloc; ++i) {
relocs.push_back(unpackRelocation(relocsArray[i], swap, bigEndian));
}
- return error_code::success();
+ return error_code();
}
static error_code
for(uint32_t i=0; i < count; ++i) {
isyms.push_back(read32(swap, indirectSymbolArray[startIndex+i]));
}
- return error_code::success();
+ return error_code();
}
result.push_back(std::move(*file));
- return error_code::success();
+ return error_code();
}
private:
MachOLinkingContext::Arch _arch;
++sout;
}
lc = next;
- return error_code::success();
+ return error_code();
}
if (_swap)
swapStruct(*cmd);
lc = next;
- return error_code::success();
+ return error_code();
}
writeLinkEditContent();
fob->commit();
- return error_code::success();
+ return error_code();
}
case symbolsOk:
break;
case symbolsIgnored:
- return error_code::success();
+ return error_code();
break;
case symbolsIllegal:
return make_dynamic_error_code(Twine("Symbol '") + sym.name
copyRefs);
}
}
- return error_code::success();
+ return error_code();
}
"last string in the section is not zero "
"terminated.");
}
- return error_code::success();
+ return error_code();
}
// A __DATA/__cfstring section contain NS/CFString objects. Atom boundaries
DefinedAtom::mergeByContent, byteContent, copyRefs);
offset += cfsObjSize;
}
- return error_code::success();
+ return error_code();
}
bytes, copyRefs);
offset += len;
}
- return error_code::success();
+ return error_code();
}
static error_code
DefinedAtom::mergeNo, byteContent, copyRefs);
offset += cuObjSize;
}
- return error_code::success();
+ return error_code();
}
static error_code processSection(MachOFile &file, const Section §ion,
llvm_unreachable("mach-o section type not supported yet");
break;
}
- return error_code::success();
+ return error_code();
}
static ErrorOr<std::unique_ptr<lld::File>>
// Stream out yaml.
yout << *f;
- return error_code::success();
+ return error_code();
}
} // namespace normalized
parseFile(std::unique_ptr<MemoryBuffer> &mb, const class Registry &,
std::vector<std::unique_ptr<File>> &result) const override {
return lld::native::File::make(std::move(mb), result);
- return error_code::success();
+ return error_code();
}
};
}
llvm::raw_fd_ostream out(outPath.data(), errorInfo,
llvm::sys::fs::F_None);
if (!errorInfo.empty())
- return error_code::success(); // FIXME
+ return error_code(); // FIXME
this->write(out);
- return error_code::success();
+ return error_code();
}
virtual ~Writer() {
error_code
parseAllMembers(std::vector<std::unique_ptr<File>> &result) const override {
- return error_code::success();
+ return error_code();
}
private:
return ec;
if (error_code ec = maybeCreateSXDataAtoms())
return ec;
- return error_code::success();
+ return error_code();
}
/// Iterate over the symbol table to retrieve all symbols.
next:
i += sym->NumberOfAuxSymbols;
}
- return error_code::success();
+ return error_code();
}
/// Create atoms for the absolute symbols.
result.push_back(atom);
_symbolAtom[sym] = atom;
}
- return error_code::success();
+ return error_code();
}
/// Create atoms for the defined symbols. This pass is a bit complicated than
if (error_code ec = AtomizeDefinedSymbols(definedSymbols, result))
return ec;
- return error_code::success();
+ return error_code();
}
// Cache the COMDAT attributes, which indicate whether the symbols in the
if (!_merge.count(sec))
_merge[sec] = DefinedAtom::mergeNo;
}
- return error_code::success();
+ return error_code();
}
/// Atomize \p symbols and append the results to \p atoms. The symbols are
atoms.push_back(atom);
_symbolAtom[sym] = atom;
}
- return error_code::success();
+ return error_code();
}
ArrayRef<uint8_t> secData;
// a part of the output image. That's what the COFF spec says.
if (section->Characteristics & llvm::COFF::IMAGE_SCN_LNK_INFO ||
section->Characteristics & llvm::COFF::IMAGE_SCN_LNK_REMOVE)
- return error_code::success();
+ return error_code();
// Supporting debug info needs more work than just linking and combining
// .debug sections. We don't support it yet. Let's discard .debug sections at
// blobs that nobody would understand.
if ((section->Characteristics & llvm::COFF::IMAGE_SCN_MEM_DISCARDABLE) &&
(sectionName == ".debug" || sectionName.startswith(".debug$"))) {
- return error_code::success();
+ return error_code();
}
DefinedAtom::ContentType type = getContentType(section);
perms, _merge[section], data, _ordinal++);
atoms.push_back(atom);
_definedAtomLocations[section][0].push_back(atom);
- return error_code::success();
+ return error_code();
}
// Create an unnamed atom if the first atom isn't at the start of the
// Finally, set alignment to the first atom so that the section contents
// will be aligned as specified by the object section header.
_definedAtomLocations[section][0][0]->setAlignment(getAlignment(section));
- return error_code::success();
+ return error_code();
}
error_code
definedAtoms.push_back(atom);
}
}
- return error_code::success();
+ return error_code();
}
/// Find the atom that is at \p targetAddress in \p section.
targetAddress < atomAddress + atom->size()) {
result = atom;
offsetInAtom = targetAddress - atomAddress;
- return error_code::success();
+ return error_code();
}
}
// Relocation target is out of range
return ec;
ret = _symbolAtom[symbol];
assert(ret);
- return error_code::success();
+ return error_code();
}
/// Add relocation information to an atom based on \p rel. \p rel is an
new COFFReference(targetAtom, offsetInAtom, rel->Type,
Reference::KindNamespace::COFF,
_referenceArch)));
- return error_code::success();
+ return error_code();
}
// Read section contents.
if (error_code ec = findSection(sectionName, section))
return ec;
if (!section)
- return error_code::success();
+ return error_code();
if (error_code ec = _obj->getSectionContents(section, result))
return ec;
- return error_code::success();
+ return error_code();
}
/// Returns the target machine type of the current object file.
switch (header->Machine) {
case llvm::COFF::IMAGE_FILE_MACHINE_I386:
result = Reference::KindArch::x86;
- return error_code::success();
+ return error_code();
case llvm::COFF::IMAGE_FILE_MACHINE_AMD64:
result = Reference::KindArch::x86_64;
- return error_code::success();
+ return error_code();
case llvm::COFF::IMAGE_FILE_MACHINE_UNKNOWN:
result = Reference::KindArch::all;
- return error_code::success();
+ return error_code();
}
llvm::errs() << "Unsupported machine type: " << header->Machine << "\n";
return llvm::object::object_error::parse_failed;
return ec;
}
}
- return error_code::success();
+ return error_code();
}
// Read .sxdata section if exists. .sxdata is a x86-only section that contains a
if (error_code ec = getSectionContents(".sxdata", sxdata))
return ec;
if (sxdata.empty())
- return error_code::success();
+ return error_code();
std::vector<uint8_t> atomContent =
*new (_alloc) std::vector<uint8_t>((size_t)sxdata.size());
}
_definedAtoms._atoms.push_back(atom);
- return error_code::success();
+ return error_code();
}
/// Find a section by name.
return ec;
if (sectionName == name) {
result = section;
- return error_code::success();
+ return error_code();
}
}
// Section was not found, but it's not an error. This method returns
// an error only when there's a read error.
- return error_code::success();
+ return error_code();
}
// Convert ArrayRef<uint8_t> to std::string. The array contains a string which
if (error_code ec = file->parse())
return ec;
result.push_back(std::move(file));
- return error_code::success();
+ return error_code();
}
private:
createAlternateNameAtoms(*file);
result.push_back(std::move(file));
- return error_code::success();
+ return error_code();
}
private:
if (!errorMessage.empty()) {
llvm::errs() << "lld warning: " << errorMessage << "\n";
}
- return error_code::success();
+ return error_code();
}
AliasAtom *createAlias(FileCOFF &file, StringRef name,
if (type == llvm::COFF::IMPORT_CODE)
addDefinedAtom(symbolName, dllName, dataAtom);
- ec = error_code::success();
+ ec = error_code();
}
const atom_collection<DefinedAtom> &defined() const override {
if (ec)
return ec;
result.push_back(std::move(file));
- return error_code::success();
+ return error_code();
}
};
if (ec)
return ec;
result.push_back(std::move(file));
- return error_code::success();
+ return error_code();
}
} // end namespace pecoff
virtual error_code
parseAllMembers(std::vector<std::unique_ptr<File>> &result) const override {
- return error_code::success();
+ return error_code();
}
StringRef _path;
const lld::File *fileRef = &file;
yout << fileRef;
- return error_code::success();
+ return error_code();
}
private: