Skip to content
Open
Show file tree
Hide file tree
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
7 changes: 6 additions & 1 deletion .github/workflows/regression-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,13 @@ jobs:
fetch-depth: ${{ needs.prepare-test-matrix.outputs.fetch_depth }}
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}

# The global config lands in this step's $HOME. darker spawns git with
# its own idea of the home directory and misses it, so also write the
# HOME-independent system config.
- name: Mark everything as safe for Git
run: git config --global --add safe.directory '*'
run: |
git config --global --add safe.directory '*'
git config --system --add safe.directory '*'

- name: Define previous commit
id: previous-commit
Expand Down
5 changes: 0 additions & 5 deletions lld/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,6 @@ include_directories(BEFORE
${CMAKE_CURRENT_SOURCE_DIR}/include
)


add_subdirectory(lld-c)
add_subdirectory(Common)
add_subdirectory(tools/lld)

Expand All @@ -212,9 +210,6 @@ add_custom_target(lld-headers)
set_target_properties(lld-headers PROPERTIES FOLDER "Misc")
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
install(DIRECTORY include/lld
# EVM local begin
include/lld-c
# EVM local end
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
COMPONENT lld-headers
FILES_MATCHING
Expand Down
76 changes: 0 additions & 76 deletions lld/Common/DriverDispatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,22 +149,6 @@ static Driver whichDriver(llvm::SmallVectorImpl<const char *> &argsV,
return it->d;
}

// EVM local begin
static DriverMemBuf whichDriver(llvm::SmallVectorImpl<const char *> &argsV,
llvm::ArrayRef<DriverDefMemBuf> drivers) {
Flavor f = parseFlavor(argsV);
const auto *const it =
llvm::find_if(drivers, [=](auto &driverdef) { return driverdef.f == f; });
if (it == drivers.end()) {
// Driver is invalid or not available in this build.
return [](llvm::ArrayRef<llvm::MemoryBufferRef>, llvm::raw_pwrite_stream *,
llvm::ArrayRef<const char *>, llvm::raw_ostream &,
llvm::raw_ostream &, bool, bool) { return false; };
}
return it->d;
}
// EVM local end

namespace lld {
bool inTestOutputDisabled = false;

Expand All @@ -189,35 +173,6 @@ int unsafeLldMain(llvm::ArrayRef<const char *> args,

return r;
}

// EVM local begin
/// Universal linker main(). This linker emulates the gnu, darwin, or
/// windows linker based on the argv[0] or -flavor option.
int unsafeLldMainMemBuf(llvm::ArrayRef<llvm::MemoryBufferRef> inBuffers,
llvm::raw_pwrite_stream *outBuffer,
llvm::ArrayRef<const char *> args,
llvm::raw_ostream &stdoutOS,
llvm::raw_ostream &stderrOS,
llvm::ArrayRef<DriverDefMemBuf> drivers,
bool exitEarly) {
SmallVector<const char *, 256> argsV(make_range(args.begin(), args.end()));
DriverMemBuf d = whichDriver(argsV, drivers);
// Run the driver. If an error occurs, false will be returned.
const int r = !d(inBuffers, outBuffer, argsV, stdoutOS, stderrOS, exitEarly,
inTestOutputDisabled);
// At this point 'r' is either 1 for error, and 0 for no error.

// Call exit() if we can to avoid calling destructors.
if (exitEarly)
exitLld(r);

// Delete the global context and clear the global context pointer, so that it
// cannot be accessed anymore.
CommonLinkerContext::destroy();

return r;
}
// EVM local end
} // namespace lld

Result lld::lldMain(llvm::ArrayRef<const char *> args,
Expand Down Expand Up @@ -245,34 +200,3 @@ Result lld::lldMain(llvm::ArrayRef<const char *> args,
}
return {r, /*canRunAgain=*/true};
}

// EVM local begin
Result lld::lldMainMemBuf(llvm::ArrayRef<llvm::MemoryBufferRef> inBuffers,
llvm::raw_pwrite_stream *outBuffer,
llvm::ArrayRef<const char *> args,
llvm::raw_ostream &stdoutOS,
llvm::raw_ostream &stderrOS,
llvm::ArrayRef<DriverDefMemBuf> drivers) {
int r = 0;
{
// The crash recovery is here only to be able to recover from arbitrary
// control flow when fatal() is called (through setjmp/longjmp or
// __try/__except).
llvm::CrashRecoveryContext crc;
if (!crc.RunSafely([&]() {
r = unsafeLldMainMemBuf(inBuffers, outBuffer, args, stdoutOS,
stderrOS, drivers, /*exitEarly=*/false);
}))
return {crc.RetCode, /*canRunAgain=*/false};
}

// Cleanup memory and reset everything back in pristine condition. This path
// is only taken when LLD is in test, or when it is used as a library.
llvm::CrashRecoveryContext crc;
if (!crc.RunSafely([]() { CommonLinkerContext::destroy(); })) {
// The memory is corrupted beyond any possible recovery.
return {r, /*canRunAgain=*/false};
}
return {r, /*canRunAgain=*/true};
}
// EVM local end
94 changes: 0 additions & 94 deletions lld/ELF/Arch/EVM.cpp

This file was deleted.

1 change: 0 additions & 1 deletion lld/ELF/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ add_lld_library(lldELF
Arch/AMDGPU.cpp
Arch/ARM.cpp
Arch/AVR.cpp
Arch/EVM.cpp
Arch/Hexagon.cpp
Arch/LoongArch.cpp
Arch/Mips.cpp
Expand Down
8 changes: 0 additions & 8 deletions lld/ELF/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,6 @@ struct Config {
llvm::CachePruningPolicy thinLTOCachePolicy;
llvm::SetVector<llvm::CachedHashString> dependencyFiles; // for --dependency-file
llvm::StringMap<uint64_t> sectionStartMap;
// EVM local begin
llvm::ArrayRef<MemoryBufferRef> inBuffers;
llvm::raw_pwrite_stream *outBuffer;
bool useIOMemoryBuffers = false;
// EVM local end
llvm::StringRef bfdname;
llvm::StringRef chroot;
llvm::StringRef dependencyFile;
Expand Down Expand Up @@ -372,9 +367,6 @@ struct Config {
bool relaxGP;
bool relocatable;
bool resolveGroups;
// EVM local begin
bool evmAssembly = false;
// EVM local end
bool relrGlibc = false;
bool relrPackDynRelocs = false;
llvm::DenseSet<llvm::StringRef> saveTempsArgs;
Expand Down
65 changes: 4 additions & 61 deletions lld/ELF/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@
#include "llvm/Config/llvm-config.h"
#include "llvm/LTO/LTO.h"
#include "llvm/Object/Archive.h"
// EVM local begin
#include "llvm/Object/ELF.h"
// EVM local end
#include "llvm/Object/IRObjectFile.h"
#include "llvm/Remarks/HotnessThresholdParser.h"
#include "llvm/Support/CommandLine.h"
Expand Down Expand Up @@ -144,40 +141,6 @@ bool link(ArrayRef<const char *> args, llvm::raw_ostream &stdoutOS,

return errCount(ctx) == 0;
}

// EVM local begin
bool linkMemBuf(ArrayRef<MemoryBufferRef> inBuffers,
raw_pwrite_stream *outBuffer, ArrayRef<const char *> args,
llvm::raw_ostream &stdoutOS, llvm::raw_ostream &stderrOS,
bool exitEarly, bool disableOutput) {
// This driver-specific context will be freed later by unsafeLldMainMemBuf().
auto *context = new Ctx;
Ctx &ctx = *context;

context->e.initialize(stdoutOS, stderrOS, exitEarly, disableOutput);
context->e.logName = args::getFilenameWithoutExe(args[0]);
context->e.errorLimitExceededMsg =
"too many errors emitted, stopping now (use "
"--error-limit=0 to see all errors)";

LinkerScript script(ctx);
ctx.script = &script;
ctx.symAux.emplace_back();
ctx.symtab = std::make_unique<SymbolTable>(ctx);

ctx.partitions.clear();
ctx.partitions.emplace_back(ctx);

ctx.arg.progName = args[0];
ctx.arg.inBuffers = inBuffers;
ctx.arg.outBuffer = outBuffer;
ctx.arg.useIOMemoryBuffers = true;

ctx.driver.linkerMain(args);

return errCount(ctx) == 0;
}
// EVM local end
} // namespace elf
} // namespace lld

Expand Down Expand Up @@ -2004,14 +1967,6 @@ static void readConfigs(Ctx &ctx, opt::InputArgList &args) {
} else {
ErrAlways(ctx) << "cannot find version script " << arg->getValue();
}

// EVM local begin
if (args.hasArg(OPT_evm_assembly)) {
ctx.arg.evmAssembly = true;
ctx.arg.unresolvedSymbols = UnresolvedPolicy::Ignore;
ctx.arg.emitRelocs = true;
}
// EVM local end
}

// Some Config members do not directly correspond to any particular
Expand Down Expand Up @@ -2084,19 +2039,13 @@ static void setConfigs(Ctx &ctx, opt::InputArgList &args) {
(!ctx.arg.entry.empty() || (!ctx.arg.shared && !ctx.arg.relocatable));
if (ctx.arg.entry.empty() && !ctx.arg.relocatable)
ctx.arg.entry = ctx.arg.emachine == EM_MIPS ? "__start" : "_start";
if (!ctx.arg.useIOMemoryBuffers && ctx.arg.outputFile.empty()) // EVM local
if (ctx.arg.outputFile.empty())
ctx.arg.outputFile = "a.out";

// EVM local begin
if (ctx.arg.useIOMemoryBuffers && !ctx.arg.outputFile.empty())
error("specification of an out file name has no effect, as the memory "
"buffer will be used instead");
// EVM local end

// Fail early if the output file or map file is not writable. If a user has a
// long link, e.g. due to a large LTO link, they do not wish to run it and
// find that it failed because there was a mistake in their command-line.
if (!ctx.arg.useIOMemoryBuffers) { // EVM local
{
llvm::TimeTraceScope timeScope("Create output files");
if (auto e = tryCreateFile(ctx.arg.outputFile))
ErrAlways(ctx) << "cannot open output file " << ctx.arg.outputFile << ": "
Expand All @@ -2107,7 +2056,7 @@ static void setConfigs(Ctx &ctx, opt::InputArgList &args) {
if (auto e = tryCreateFile(ctx.arg.whyExtract))
ErrAlways(ctx) << "cannot open --why-extract= file " << ctx.arg.whyExtract
<< ": " << e.message();
} // EVM local
}
}

static bool isFormatBinary(Ctx &ctx, StringRef s) {
Expand Down Expand Up @@ -2149,13 +2098,7 @@ void LinkerDriver::createFiles(opt::InputArgList &args) {
}
case OPT_script:
case OPT_default_script:
// EVM local begin
if (ctx.arg.useIOMemoryBuffers) {
if (std::optional<MemoryBufferRef> mb = readFile(ctx, arg->getValue()))
readLinkerScript(ctx, *mb);
break;
// EVM local end
} else if (std::optional<std::string> path =
if (std::optional<std::string> path =
searchScript(ctx, arg->getValue())) {
if (std::optional<MemoryBufferRef> mb = readFile(ctx, *path)) {
if (arg->getOption().matches(OPT_default_script)) {
Expand Down
Loading
Loading