Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions lld/ELF/Writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
#include "Config.h"
#include "InputFiles.h"
#include "LinkerScript.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
#include "MapFile.h"
#include "OutputSections.h"
#include "Relocations.h"
Expand Down Expand Up @@ -2800,15 +2798,6 @@ template <class ELFT> void Writer<ELFT>::writeHeader() {
sec->writeHeaderTo<ELFT>(++sHdrs);
}

static StringRef parentPathOrDot(StringRef path) {
auto parent_path = sys::path::parent_path(path);
if (parent_path.empty() && !path.empty() && !sys::path::is_absolute(path)) {
return ".";
} else {
return parent_path;
}
}

// Open a result file.
template <class ELFT> void Writer<ELFT>::openFile() {
uint64_t maxSize = config->is64 ? INT64_MAX : UINT32_MAX;
Expand All @@ -2829,18 +2818,6 @@ template <class ELFT> void Writer<ELFT>::openFile() {
flags |= FileOutputBuffer::F_executable;
if (!config->mmapOutputFile)
flags |= FileOutputBuffer::F_no_mmap;
if (config->mmapOutputFile) {
// LLD relies on [fallocate] to mmap the output.
// In case there's no space left on the device
// it will error with SIGBUS, which is confusing
// for users
auto ErrOrSpaceInfo = sys::fs::disk_space(parentPathOrDot(config->outputFile));
if (!ErrOrSpaceInfo)
error("Can't get remaining size on disk");
if (ErrOrSpaceInfo.get().free < fileSize)
error("failed to open " + config->outputFile + ": " +
"No Space Left on Device");
}
Expected<std::unique_ptr<FileOutputBuffer>> bufferOrErr =
FileOutputBuffer::create(config->outputFile, fileSize, flags);

Expand Down