void copyLocalSymbols();
void addReservedSymbols();
- bool createSections();
+ void createSections();
void addPredefinedSections();
bool needsGot();
void setPhdrs();
void fixSectionAlignments();
void fixAbsoluteSymbols();
- bool openFile();
+ void openFile();
void writeHeader();
void writeSections();
void writeBuildId();
if (!Config->DiscardAll)
copyLocalSymbols();
addReservedSymbols();
- if (!createSections())
+ createSections();
+ if (HasError)
return;
if (Config->Relocatable) {
fixAbsoluteSymbols();
}
- if (!openFile())
+ openFile();
+ if (HasError)
return;
writeHeader();
writeSections();
}
// Create output section objects and add them to OutputSections.
-template <class ELFT> bool Writer<ELFT>::createSections() {
+template <class ELFT> void Writer<ELFT>::createSections() {
OutputSections.push_back(Out<ELFT>::ElfHeader);
if (!Config->Relocatable)
OutputSections.push_back(Out<ELFT>::ProgramHeaders);
// Do not proceed if there was an undefined symbol.
if (HasError)
- return false;
+ return;
addCommonSymbols(CommonSymbols);
addCopyRelSymbols(CopyRelSymbols);
if (isOutputDynamic())
Out<ELFT>::Dynamic->finalize();
- return true;
}
template <class ELFT> bool Writer<ELFT>::needsGot() {
Sec->writeHeaderTo(++SHdrs);
}
-template <class ELFT> bool Writer<ELFT>::openFile() {
+template <class ELFT> void Writer<ELFT>::openFile() {
ErrorOr<std::unique_ptr<FileOutputBuffer>> BufferOrErr =
FileOutputBuffer::create(Config->OutputFile, FileSize,
FileOutputBuffer::F_executable);
- if (!BufferOrErr) {
+ if (BufferOrErr)
+ Buffer = std::move(*BufferOrErr);
+ else
error(BufferOrErr, "failed to open " + Config->OutputFile);
- return false;
- }
- Buffer = std::move(*BufferOrErr);
- return true;
}
// Write section contents to a mmap'ed file.