mirror of
https://github.com/rui314/mold.git
synced 2024-10-26 13:10:46 +03:00
Reorganize directory structure
This commit is contained in:
parent
7571305cd1
commit
5b8594979b
112
CMakeLists.txt
112
CMakeLists.txt
@ -252,7 +252,7 @@ if(NOT APPLE AND NOT WIN32)
|
||||
# Remove the default `lib` prefix
|
||||
set_target_properties(mold-wrapper PROPERTIES PREFIX "")
|
||||
target_link_libraries(mold-wrapper PRIVATE ${CMAKE_DL_LIBS})
|
||||
target_sources(mold-wrapper PRIVATE elf/mold-wrapper.c)
|
||||
target_sources(mold-wrapper PRIVATE src/mold-wrapper.c)
|
||||
endif()
|
||||
|
||||
# If atomics doesn't work by default, add -latomic.
|
||||
@ -284,15 +284,15 @@ add_custom_target(git_hash
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-DSOURCE_DIR=${CMAKE_SOURCE_DIR}
|
||||
-DOUTPUT_FILE=${CMAKE_BINARY_DIR}/git-hash.cc
|
||||
-P ${CMAKE_SOURCE_DIR}/common/update-git-hash.cmake
|
||||
DEPENDS common/update-git-hash.cmake
|
||||
-P ${CMAKE_SOURCE_DIR}/lib/update-git-hash.cmake
|
||||
DEPENDS lib/update-git-hash.cmake
|
||||
BYPRODUCTS git-hash.cc
|
||||
VERBATIM)
|
||||
|
||||
add_dependencies(mold git_hash)
|
||||
|
||||
# Create config.h file
|
||||
configure_file(common/config.h.in config.h)
|
||||
configure_file(lib/config.h.in config.h)
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
# Almost all functions are template in mold which take a target type
|
||||
@ -308,35 +308,35 @@ list(APPEND MOLD_ELF_TARGETS
|
||||
S390X SPARC64 M68K SH4 ALPHA LOONGARCH32 LOONGARCH64)
|
||||
|
||||
list(APPEND MOLD_ELF_TEMPLATE_FILES
|
||||
elf/arch-loongarch.cc
|
||||
elf/arch-riscv.cc
|
||||
elf/cmdline.cc
|
||||
elf/gc-sections.cc
|
||||
elf/gdb-index.cc
|
||||
elf/icf.cc
|
||||
elf/input-files.cc
|
||||
elf/input-sections.cc
|
||||
elf/linker-script.cc
|
||||
elf/main.cc
|
||||
elf/mapfile.cc
|
||||
elf/output-chunks.cc
|
||||
elf/passes.cc
|
||||
elf/relocatable.cc
|
||||
elf/shrink-sections.cc
|
||||
elf/thunks.cc
|
||||
elf/tls.cc
|
||||
src/arch-loongarch.cc
|
||||
src/arch-riscv.cc
|
||||
src/cmdline.cc
|
||||
src/gc-sections.cc
|
||||
src/gdb-index.cc
|
||||
src/icf.cc
|
||||
src/input-files.cc
|
||||
src/input-sections.cc
|
||||
src/linker-script.cc
|
||||
src/main.cc
|
||||
src/mapfile.cc
|
||||
src/output-chunks.cc
|
||||
src/passes.cc
|
||||
src/relocatable.cc
|
||||
src/shrink-sections.cc
|
||||
src/thunks.cc
|
||||
src/tls.cc
|
||||
)
|
||||
|
||||
if(WIN32 AND NOT MINGW)
|
||||
list(APPEND MOLD_ELF_TEMPLATE_FILES elf/lto-win32.cc)
|
||||
list(APPEND MOLD_ELF_TEMPLATE_FILES src/lto-win32.cc)
|
||||
else()
|
||||
list(APPEND MOLD_ELF_TEMPLATE_FILES elf/lto-unix.cc)
|
||||
list(APPEND MOLD_ELF_TEMPLATE_FILES src/lto-unix.cc)
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
list(APPEND MOLD_ELF_TEMPLATE_FILES elf/subprocess-win32.cc)
|
||||
list(APPEND MOLD_ELF_TEMPLATE_FILES src/subprocess-win32.cc)
|
||||
else()
|
||||
list(APPEND MOLD_ELF_TEMPLATE_FILES elf/subprocess-unix.cc)
|
||||
list(APPEND MOLD_ELF_TEMPLATE_FILES src/subprocess-unix.cc)
|
||||
endif()
|
||||
|
||||
function(mold_instantiate_templates SOURCE TARGET)
|
||||
@ -358,46 +358,46 @@ endforeach()
|
||||
|
||||
# Add other non-template source files.
|
||||
target_sources(mold PRIVATE
|
||||
common/compress.cc
|
||||
common/crc32.cc
|
||||
common/demangle.cc
|
||||
common/filepath.cc
|
||||
common/glob.cc
|
||||
common/hyperloglog.cc
|
||||
common/malloc.cc
|
||||
common/multi-glob.cc
|
||||
common/perf.cc
|
||||
common/random.cc
|
||||
common/tar.cc
|
||||
elf/arch-alpha.cc
|
||||
elf/arch-arm32.cc
|
||||
elf/arch-arm64.cc
|
||||
elf/arch-i386.cc
|
||||
elf/arch-m68k.cc
|
||||
elf/arch-ppc32.cc
|
||||
elf/arch-ppc64v1.cc
|
||||
elf/arch-ppc64v2.cc
|
||||
elf/arch-s390x.cc
|
||||
elf/arch-sh4.cc
|
||||
elf/arch-sparc64.cc
|
||||
elf/arch-x86-64.cc
|
||||
elf/config.cc
|
||||
elf/elf.cc
|
||||
git-hash.cc
|
||||
lib/compress.cc
|
||||
lib/crc32.cc
|
||||
lib/demangle.cc
|
||||
lib/elf.cc
|
||||
lib/filepath.cc
|
||||
lib/glob.cc
|
||||
lib/hyperloglog.cc
|
||||
lib/malloc.cc
|
||||
lib/multi-glob.cc
|
||||
lib/perf.cc
|
||||
lib/random.cc
|
||||
lib/tar.cc
|
||||
src/arch-alpha.cc
|
||||
src/arch-arm32.cc
|
||||
src/arch-arm64.cc
|
||||
src/arch-i386.cc
|
||||
src/arch-m68k.cc
|
||||
src/arch-ppc32.cc
|
||||
src/arch-ppc64v1.cc
|
||||
src/arch-ppc64v2.cc
|
||||
src/arch-s390x.cc
|
||||
src/arch-sh4.cc
|
||||
src/arch-sparc64.cc
|
||||
src/arch-x86-64.cc
|
||||
src/config.cc
|
||||
third-party/rust-demangle/rust-demangle.c
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
target_sources(mold PRIVATE
|
||||
common/jobs-win32.cc
|
||||
common/mapped-file-win32.cc
|
||||
common/signal-win32.cc
|
||||
lib/jobs-win32.cc
|
||||
lib/mapped-file-win32.cc
|
||||
lib/signal-win32.cc
|
||||
)
|
||||
else()
|
||||
target_sources(mold PRIVATE
|
||||
common/jobs-unix.cc
|
||||
common/mapped-file-unix.cc
|
||||
common/signal-unix.cc
|
||||
lib/jobs-unix.cc
|
||||
lib/mapped-file-unix.cc
|
||||
lib/signal-unix.cc
|
||||
)
|
||||
endif()
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "mold.h"
|
||||
#include "elf.h"
|
||||
|
||||
namespace mold::elf {
|
||||
namespace mold {
|
||||
|
||||
static std::string unknown_type(u32 r_type) {
|
||||
char buf[50];
|
||||
@ -1059,4 +1059,4 @@ std::string rel_to_string<LOONGARCH32>(u32 r_type) {
|
||||
return rel_to_string<LOONGARCH64>(r_type);
|
||||
}
|
||||
|
||||
} // namespace mold::elf
|
||||
} // namespace mold
|
@ -1,13 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "../common/integers.h"
|
||||
#include "integers.h"
|
||||
|
||||
#include <concepts>
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
|
||||
namespace mold::elf {
|
||||
namespace mold {
|
||||
|
||||
struct X86_64;
|
||||
struct I386;
|
||||
@ -2313,4 +2313,4 @@ struct LOONGARCH32 {
|
||||
static constexpr u32 R_FUNCALL[] = { R_LARCH_B26, R_LARCH_CALL36 };
|
||||
};
|
||||
|
||||
} // namespace mold::elf
|
||||
} // namespace mold
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "common.h"
|
||||
#include "../elf/elf.h"
|
||||
#include "elf.h"
|
||||
|
||||
namespace mold {
|
||||
|
||||
@ -36,8 +36,6 @@ bool is_text_file(MappedFile *mf) {
|
||||
|
||||
template <typename E, typename Context, typename MappedFile>
|
||||
inline bool is_gcc_lto_obj(Context &ctx, MappedFile *mf) {
|
||||
using namespace mold::elf;
|
||||
|
||||
const char *data = mf->get_contents().data();
|
||||
ElfEhdr<E> &ehdr = *(ElfEhdr<E> *)data;
|
||||
ElfShdr<E> *sh_begin = (ElfShdr<E> *)(data + ehdr.e_shoff);
|
||||
@ -91,8 +89,6 @@ inline bool is_gcc_lto_obj(Context &ctx, MappedFile *mf) {
|
||||
|
||||
template <typename Context, typename MappedFile>
|
||||
FileType get_file_type(Context &ctx, MappedFile *mf) {
|
||||
using namespace elf;
|
||||
|
||||
std::string_view data = mf->get_contents();
|
||||
|
||||
if (data.empty())
|
@ -36,7 +36,7 @@
|
||||
|
||||
#include "mold.h"
|
||||
|
||||
namespace mold::elf {
|
||||
namespace mold {
|
||||
|
||||
using E = ALPHA;
|
||||
|
||||
@ -327,4 +327,4 @@ void AlphaGotSection::copy_buf(Context<E> &ctx) {
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace mold::elf
|
||||
} // namespace mold
|
@ -37,7 +37,7 @@
|
||||
#include <tbb/parallel_for_each.h>
|
||||
#include <tbb/parallel_sort.h>
|
||||
|
||||
namespace mold::elf {
|
||||
namespace mold {
|
||||
|
||||
using E = ARM32;
|
||||
|
||||
@ -787,4 +787,4 @@ void fixup_arm_exidx_section(Context<E> &ctx) {
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace mold::elf
|
||||
} // namespace mold
|
@ -19,7 +19,7 @@
|
||||
|
||||
#include "mold.h"
|
||||
|
||||
namespace mold::elf {
|
||||
namespace mold {
|
||||
|
||||
using E = ARM64;
|
||||
|
||||
@ -628,4 +628,4 @@ void Thunk<E>::copy_buf(Context<E> &ctx) {
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace mold::elf
|
||||
} // namespace mold
|
@ -35,7 +35,7 @@
|
||||
|
||||
#include "mold.h"
|
||||
|
||||
namespace mold::elf {
|
||||
namespace mold {
|
||||
|
||||
using E = I386;
|
||||
|
||||
@ -613,4 +613,4 @@ void InputSection<E>::scan_relocations(Context<E> &ctx) {
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace mold::elf
|
||||
} // namespace mold
|
@ -25,7 +25,7 @@
|
||||
|
||||
#include "mold.h"
|
||||
|
||||
namespace mold::elf {
|
||||
namespace mold {
|
||||
|
||||
using E = MOLD_TARGET;
|
||||
|
||||
@ -977,6 +977,6 @@ void shrink_section(Context<E> &ctx, InputSection<E> &isec, bool use_rvc) {
|
||||
isec.sh_size -= delta;
|
||||
}
|
||||
|
||||
} // namespace mold::elf
|
||||
} // namespace mold
|
||||
|
||||
#endif
|
@ -16,7 +16,7 @@
|
||||
|
||||
#include "mold.h"
|
||||
|
||||
namespace mold::elf {
|
||||
namespace mold {
|
||||
|
||||
using E = M68K;
|
||||
|
||||
@ -322,4 +322,4 @@ void InputSection<E>::scan_relocations(Context<E> &ctx) {
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace mold::elf
|
||||
} // namespace mold
|
@ -42,7 +42,7 @@
|
||||
|
||||
#include "mold.h"
|
||||
|
||||
namespace mold::elf {
|
||||
namespace mold {
|
||||
|
||||
using E = PPC32;
|
||||
|
||||
@ -450,4 +450,4 @@ void Thunk<E>::copy_buf(Context<E> &ctx) {
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace mold::elf
|
||||
} // namespace mold
|
@ -50,7 +50,7 @@
|
||||
#include <algorithm>
|
||||
#include <tbb/parallel_for_each.h>
|
||||
|
||||
namespace mold::elf {
|
||||
namespace mold {
|
||||
|
||||
using E = PPC64V1;
|
||||
|
||||
@ -689,4 +689,4 @@ void PPC64OpdSection::copy_buf(Context<E> &ctx) {
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace mold::elf
|
||||
} // namespace mold
|
@ -82,7 +82,7 @@
|
||||
|
||||
#include "mold.h"
|
||||
|
||||
namespace mold::elf {
|
||||
namespace mold {
|
||||
|
||||
using E = PPC64V2;
|
||||
|
||||
@ -677,4 +677,4 @@ u64 get_eflags(Context<E> &ctx) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
} // namespace mold::elf
|
||||
} // namespace mold
|
@ -19,14 +19,13 @@
|
||||
|
||||
#if MOLD_RV64LE || MOLD_RV64BE || MOLD_RV32LE || MOLD_RV32BE
|
||||
|
||||
#include "elf.h"
|
||||
#include "mold.h"
|
||||
|
||||
#include <regex>
|
||||
#include <tbb/parallel_for.h>
|
||||
#include <tbb/parallel_for_each.h>
|
||||
|
||||
namespace mold::elf {
|
||||
namespace mold {
|
||||
|
||||
using E = MOLD_TARGET;
|
||||
|
||||
@ -1233,6 +1232,6 @@ void RiscvAttributesSection<E>::copy_buf(Context<E> &ctx) {
|
||||
write_vector(ctx.buf + this->shdr.sh_offset, contents);
|
||||
}
|
||||
|
||||
} // namespace mold::elf
|
||||
} // namespace mold
|
||||
|
||||
#endif
|
@ -37,7 +37,7 @@
|
||||
|
||||
#include "mold.h"
|
||||
|
||||
namespace mold::elf {
|
||||
namespace mold {
|
||||
|
||||
using E = S390X;
|
||||
|
||||
@ -486,4 +486,4 @@ void InputSection<E>::scan_relocations(Context<E> &ctx) {
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace mold::elf
|
||||
} // namespace mold
|
@ -60,7 +60,7 @@
|
||||
|
||||
#include "mold.h"
|
||||
|
||||
namespace mold::elf {
|
||||
namespace mold {
|
||||
|
||||
using E = SH4;
|
||||
|
||||
@ -373,4 +373,4 @@ void InputSection<E>::scan_relocations(Context<E> &ctx) {
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace mold::elf
|
||||
} // namespace mold
|
@ -58,7 +58,7 @@
|
||||
|
||||
#include "mold.h"
|
||||
|
||||
namespace mold::elf {
|
||||
namespace mold {
|
||||
|
||||
using E = SPARC64;
|
||||
|
||||
@ -651,4 +651,4 @@ void InputSection<E>::scan_relocations(Context<E> &ctx) {
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace mold::elf
|
||||
} // namespace mold
|
@ -30,7 +30,7 @@
|
||||
|
||||
#include <tbb/parallel_for_each.h>
|
||||
|
||||
namespace mold::elf {
|
||||
namespace mold {
|
||||
|
||||
using E = X86_64;
|
||||
|
||||
@ -908,4 +908,4 @@ void rewrite_endbr(Context<E> &ctx) {
|
||||
keep(sym);
|
||||
}
|
||||
|
||||
} // namespace mold::elf
|
||||
} // namespace mold
|
@ -15,7 +15,7 @@
|
||||
# define STDERR_FILENO (_fileno(stderr))
|
||||
#endif
|
||||
|
||||
namespace mold::elf {
|
||||
namespace mold {
|
||||
|
||||
inline const char helpmsg[] = R"(
|
||||
Options:
|
||||
@ -1524,4 +1524,4 @@ using E = MOLD_TARGET;
|
||||
template std::vector<std::string_view> expand_response_files(Context<E> &, char **);
|
||||
template std::vector<std::string> parse_nonpositional_args(Context<E> &ctx);
|
||||
|
||||
} // namespace mold::elf
|
||||
} // namespace mold
|
@ -1,7 +1,7 @@
|
||||
#include "mold.h"
|
||||
#include "config.h"
|
||||
|
||||
namespace mold::elf {
|
||||
namespace mold {
|
||||
|
||||
std::string get_mold_version() {
|
||||
if (mold_git_hash.empty())
|
||||
@ -10,4 +10,4 @@ std::string get_mold_version() {
|
||||
"; compatible with GNU ld)";
|
||||
}
|
||||
|
||||
} // namespace mold::elf
|
||||
} // namespace mold
|
@ -7,7 +7,7 @@
|
||||
#include <tbb/concurrent_vector.h>
|
||||
#include <tbb/parallel_for_each.h>
|
||||
|
||||
namespace mold::elf {
|
||||
namespace mold {
|
||||
|
||||
template <typename E>
|
||||
static bool should_keep(const InputSection<E> &isec) {
|
||||
@ -172,4 +172,4 @@ using E = MOLD_TARGET;
|
||||
|
||||
template void gc_sections(Context<E> &ctx);
|
||||
|
||||
} // namespace mold::elf
|
||||
} // namespace mold
|
@ -60,7 +60,7 @@
|
||||
#include <tbb/parallel_for_each.h>
|
||||
#include <tbb/parallel_sort.h>
|
||||
|
||||
namespace mold::elf {
|
||||
namespace mold {
|
||||
|
||||
enum DwarfKind { DWARF2_32, DWARF5_32, DWARF2_64, DWARF5_64 };
|
||||
|
||||
@ -791,4 +791,4 @@ using E = MOLD_TARGET;
|
||||
|
||||
template void write_gdb_index(Context<E> &);
|
||||
|
||||
} // namespace mold::elf
|
||||
} // namespace mold
|
@ -65,7 +65,7 @@
|
||||
// conditions.
|
||||
|
||||
#include "mold.h"
|
||||
#include "../common/siphash.h"
|
||||
#include "../lib/siphash.h"
|
||||
|
||||
#include <array>
|
||||
#include <cstdio>
|
||||
@ -91,7 +91,7 @@ template <> struct hash<Digest> {
|
||||
};
|
||||
}
|
||||
|
||||
namespace mold::elf {
|
||||
namespace mold {
|
||||
|
||||
static u8 hmac_key[16];
|
||||
|
||||
@ -612,4 +612,4 @@ using E = MOLD_TARGET;
|
||||
|
||||
template void icf_sections(Context<E> &ctx);
|
||||
|
||||
} // namespace mold::elf
|
||||
} // namespace mold
|
@ -8,7 +8,7 @@
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
namespace mold::elf {
|
||||
namespace mold {
|
||||
|
||||
// If we haven't seen the same `key` before, create a new instance
|
||||
// of Symbol and returns it. Otherwise, returns the previously-
|
||||
@ -1497,4 +1497,4 @@ template std::string_view demangle(const Symbol<E> &);
|
||||
template std::ostream &operator<<(std::ostream &, const Symbol<E> &);
|
||||
template std::ostream &operator<<(std::ostream &, const InputFile<E> &);
|
||||
|
||||
} // namespace mold::elf
|
||||
} // namespace mold
|
@ -4,7 +4,7 @@
|
||||
#include <zlib.h>
|
||||
#include <zstd.h>
|
||||
|
||||
namespace mold::elf {
|
||||
namespace mold {
|
||||
|
||||
typedef enum {
|
||||
NONE, ERROR, COPYREL, DYN_COPYREL, PLT, CPLT, DYN_CPLT, DYNREL,
|
||||
@ -675,4 +675,4 @@ template bool cie_equals(const CieRecord<E> &, const CieRecord<E> &);
|
||||
template class InputSection<E>;
|
||||
template class MergeableSection<E>;
|
||||
|
||||
} // namespace mold::elf
|
||||
} // namespace mold
|
@ -8,7 +8,7 @@
|
||||
#include <cctype>
|
||||
#include <iomanip>
|
||||
|
||||
namespace mold::elf {
|
||||
namespace mold {
|
||||
|
||||
static std::string_view get_line(std::string_view input, const char *pos) {
|
||||
assert(input.data() <= pos);
|
||||
@ -421,4 +421,4 @@ template class Script<E>;
|
||||
template
|
||||
std::vector<DynamicPattern> parse_dynamic_list(Context<E> &, std::string_view);
|
||||
|
||||
} // namespace mold::elf
|
||||
} // namespace mold
|
@ -95,7 +95,7 @@
|
||||
# define LOG std::ostringstream()
|
||||
#endif
|
||||
|
||||
namespace mold::elf {
|
||||
namespace mold {
|
||||
|
||||
// Global variables
|
||||
// We store LTO-related information to global variables,
|
||||
@ -746,4 +746,4 @@ template ObjectFile<E> *read_lto_object(Context<E> &, MappedFile *);
|
||||
template std::vector<ObjectFile<E> *> do_lto(Context<E> &);
|
||||
template void lto_cleanup(Context<E> &);
|
||||
|
||||
} // namespace mold::elf
|
||||
} // namespace mold
|
@ -1,7 +1,7 @@
|
||||
#include "mold.h"
|
||||
#include "lto.h"
|
||||
|
||||
namespace mold::elf {
|
||||
namespace mold {
|
||||
|
||||
template <typename E>
|
||||
ObjectFile<E> *read_lto_object(Context<E> &ctx, MappedFile *mf) {
|
||||
@ -22,4 +22,4 @@ template ObjectFile<E> *read_lto_object(Context<E> &, MappedFile *);
|
||||
template std::vector<ObjectFile<E> *> do_lto(Context<E> &);
|
||||
template void lto_cleanup(Context<E> &);
|
||||
|
||||
} // namespace mold::elf
|
||||
} // namespace mold
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "../common/integers.h"
|
||||
#include "../lib/integers.h"
|
||||
|
||||
namespace mold {
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "mold.h"
|
||||
#include "../common/archive-file.h"
|
||||
#include "../common/output-file.h"
|
||||
#include "../lib/archive-file.h"
|
||||
#include "../lib/output-file.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <functional>
|
||||
@ -23,11 +23,11 @@
|
||||
|
||||
#ifdef MOLD_X86_64
|
||||
int main(int argc, char **argv) {
|
||||
return mold::elf::elf_main<mold::elf::X86_64>(argc, argv);
|
||||
return mold::mold_main<mold::X86_64>(argc, argv);
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace mold::elf {
|
||||
namespace mold {
|
||||
|
||||
// Read the beginning of a given file and returns its machine type
|
||||
// (e.g. EM_X86_64 or EM_386).
|
||||
@ -340,7 +340,7 @@ static void read_input_files(Context<E> &ctx, std::span<std::string> args) {
|
||||
}
|
||||
|
||||
template <typename E>
|
||||
int elf_main(int argc, char **argv) {
|
||||
int mold_main(int argc, char **argv) {
|
||||
Context<E> ctx;
|
||||
|
||||
// Process -run option first. process_run_subcommand() does not return.
|
||||
@ -716,6 +716,6 @@ int elf_main(int argc, char **argv) {
|
||||
|
||||
using E = MOLD_TARGET;
|
||||
|
||||
template int elf_main<E>(int, char **);
|
||||
template int mold_main<E>(int, char **);
|
||||
|
||||
} // namespace mold::elf
|
||||
} // namespace mold
|
@ -7,7 +7,7 @@
|
||||
#include <tbb/parallel_for_each.h>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace mold::elf {
|
||||
namespace mold {
|
||||
|
||||
template <typename E>
|
||||
using Map =
|
||||
@ -114,4 +114,4 @@ using E = MOLD_TARGET;
|
||||
|
||||
template void print_map(Context<E> &ctx);
|
||||
|
||||
} // namespace mold::elf
|
||||
} // namespace mold
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "elf.h"
|
||||
#include "../common/common.h"
|
||||
#include "../lib/common.h"
|
||||
#include "../lib/elf.h"
|
||||
|
||||
#include <atomic>
|
||||
#include <bitset>
|
||||
@ -34,7 +34,7 @@
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
namespace mold::elf {
|
||||
namespace mold {
|
||||
|
||||
template <typename E> class InputFile;
|
||||
template <typename E> class InputSection;
|
||||
@ -2038,9 +2038,7 @@ template <typename E>
|
||||
void read_file(Context<E> &ctx, ReaderContext &rctx, MappedFile *mf);
|
||||
|
||||
template <typename E>
|
||||
int elf_main(int argc, char **argv);
|
||||
|
||||
int main(int argc, char **argv);
|
||||
int mold_main(int argc, char **argv);
|
||||
|
||||
template <typename E>
|
||||
std::ostream &operator<<(std::ostream &out, const InputFile<E> &file);
|
||||
@ -2995,4 +2993,4 @@ inline bool is_c_identifier(std::string_view s) {
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace mold::elf
|
||||
} // namespace mold
|
@ -9,7 +9,7 @@
|
||||
#include <tbb/parallel_scan.h>
|
||||
#include <tbb/parallel_sort.h>
|
||||
|
||||
namespace mold::elf {
|
||||
namespace mold {
|
||||
|
||||
// The hash function for .hash.
|
||||
static u32 elf_hash(std::string_view name) {
|
||||
@ -2954,4 +2954,4 @@ template OutputSection<E> *find_section(Context<E> &, std::string_view);
|
||||
template i64 to_phdr_flags(Context<E> &ctx, Chunk<E> *chunk);
|
||||
template ElfSym<E> to_output_esym(Context<E> &, Symbol<E> &, u32, U32<E> *);
|
||||
|
||||
} // namespace mold::elf
|
||||
} // namespace mold
|
@ -1,6 +1,6 @@
|
||||
#include "mold.h"
|
||||
#include "blake3.h"
|
||||
#include "../common/output-file.h"
|
||||
#include "../lib/output-file.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <functional>
|
||||
@ -13,49 +13,49 @@
|
||||
#include <tbb/partitioner.h>
|
||||
#include <unordered_set>
|
||||
|
||||
namespace mold::elf {
|
||||
namespace mold {
|
||||
|
||||
// Since elf_main is a template, we can't run it without a type parameter.
|
||||
// We speculatively run elf_main with X86_64, and if the speculation was
|
||||
// Since mold_main is a template, we can't run it without a type parameter.
|
||||
// We speculatively run mold_main with X86_64, and if the speculation was
|
||||
// wrong, re-run it with an actual machine type.
|
||||
template <typename E>
|
||||
int redo_main(Context<E> &ctx, int argc, char **argv) {
|
||||
std::string_view target = ctx.arg.emulation;
|
||||
|
||||
if (target == I386::target_name)
|
||||
return elf_main<I386>(argc, argv);
|
||||
return mold_main<I386>(argc, argv);
|
||||
if (target == ARM64::target_name)
|
||||
return elf_main<ARM64>(argc, argv);
|
||||
return mold_main<ARM64>(argc, argv);
|
||||
if (target == ARM32::target_name)
|
||||
return elf_main<ARM32>(argc, argv);
|
||||
return mold_main<ARM32>(argc, argv);
|
||||
if (target == RV64LE::target_name)
|
||||
return elf_main<RV64LE>(argc, argv);
|
||||
return mold_main<RV64LE>(argc, argv);
|
||||
if (target == RV64BE::target_name)
|
||||
return elf_main<RV64BE>(argc, argv);
|
||||
return mold_main<RV64BE>(argc, argv);
|
||||
if (target == RV32LE::target_name)
|
||||
return elf_main<RV32LE>(argc, argv);
|
||||
return mold_main<RV32LE>(argc, argv);
|
||||
if (target == RV32BE::target_name)
|
||||
return elf_main<RV32BE>(argc, argv);
|
||||
return mold_main<RV32BE>(argc, argv);
|
||||
if (target == PPC32::target_name)
|
||||
return elf_main<PPC32>(argc, argv);
|
||||
return mold_main<PPC32>(argc, argv);
|
||||
if (target == PPC64V1::target_name)
|
||||
return elf_main<PPC64V1>(argc, argv);
|
||||
return mold_main<PPC64V1>(argc, argv);
|
||||
if (target == PPC64V2::target_name)
|
||||
return elf_main<PPC64V2>(argc, argv);
|
||||
return mold_main<PPC64V2>(argc, argv);
|
||||
if (target == S390X::target_name)
|
||||
return elf_main<S390X>(argc, argv);
|
||||
return mold_main<S390X>(argc, argv);
|
||||
if (target == SPARC64::target_name)
|
||||
return elf_main<SPARC64>(argc, argv);
|
||||
return mold_main<SPARC64>(argc, argv);
|
||||
if (target == M68K::target_name)
|
||||
return elf_main<M68K>(argc, argv);
|
||||
return mold_main<M68K>(argc, argv);
|
||||
if (target == SH4::target_name)
|
||||
return elf_main<SH4>(argc, argv);
|
||||
return mold_main<SH4>(argc, argv);
|
||||
if (target == ALPHA::target_name)
|
||||
return elf_main<ALPHA>(argc, argv);
|
||||
return mold_main<ALPHA>(argc, argv);
|
||||
if (target == LOONGARCH32::target_name)
|
||||
return elf_main<LOONGARCH32>(argc, argv);
|
||||
return mold_main<LOONGARCH32>(argc, argv);
|
||||
if (target == LOONGARCH64::target_name)
|
||||
return elf_main<LOONGARCH64>(argc, argv);
|
||||
return mold_main<LOONGARCH64>(argc, argv);
|
||||
unreachable();
|
||||
}
|
||||
|
||||
@ -3283,4 +3283,4 @@ template void write_separate_debug_file(Context<E> &);
|
||||
template void write_dependency_file(Context<E> &);
|
||||
template void show_stats(Context<E> &);
|
||||
|
||||
} // namespace mold::elf
|
||||
} // namespace mold
|
@ -35,7 +35,7 @@
|
||||
#include <tbb/parallel_for.h>
|
||||
#include <tbb/parallel_for_each.h>
|
||||
|
||||
namespace mold::elf {
|
||||
namespace mold {
|
||||
|
||||
// Create linker-synthesized sections
|
||||
template <typename E>
|
||||
@ -194,4 +194,4 @@ using E = MOLD_TARGET;
|
||||
|
||||
template void combine_objects(Context<E> &);
|
||||
|
||||
} // namespace mold::elf
|
||||
} // namespace mold
|
@ -62,7 +62,7 @@
|
||||
|
||||
#include <tbb/parallel_for_each.h>
|
||||
|
||||
namespace mold::elf {
|
||||
namespace mold {
|
||||
|
||||
using E = MOLD_TARGET;
|
||||
|
||||
@ -142,6 +142,6 @@ i64 compute_distance<E>(Context<E> &ctx, Symbol<E> &sym,
|
||||
return S + A - P;
|
||||
}
|
||||
|
||||
} // namespace mold::elf
|
||||
} // namespace mold
|
||||
|
||||
#endif
|
@ -9,7 +9,7 @@
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
|
||||
namespace mold::elf {
|
||||
namespace mold {
|
||||
|
||||
#ifdef MOLD_X86_64
|
||||
static int pipe_write_fd = -1;
|
||||
@ -126,4 +126,4 @@ using E = MOLD_TARGET;
|
||||
|
||||
template void process_run_subcommand(Context<E> &, int, char **);
|
||||
|
||||
} // namespace mold::elf
|
||||
} // namespace mold
|
@ -1,6 +1,6 @@
|
||||
#include "mold.h"
|
||||
|
||||
namespace mold::elf {
|
||||
namespace mold {
|
||||
|
||||
#ifdef MOLD_X86_64
|
||||
void fork_child() {}
|
||||
@ -17,4 +17,4 @@ using E = MOLD_TARGET;
|
||||
|
||||
template void process_run_subcommand(Context<E> &, int, char **);
|
||||
|
||||
} // namespace mold::elf
|
||||
} // namespace mold
|
@ -27,7 +27,7 @@
|
||||
#include <tbb/parallel_for.h>
|
||||
#include <tbb/parallel_for_each.h>
|
||||
|
||||
namespace mold::elf {
|
||||
namespace mold {
|
||||
|
||||
using E = MOLD_TARGET;
|
||||
|
||||
@ -294,6 +294,6 @@ void OutputSection<E>::create_range_extension_thunks(Context<E> &ctx) {
|
||||
std::max<u32>(this->shdr.sh_addralign, 1 << isec->p2align);
|
||||
}
|
||||
|
||||
} // namespace mold::elf
|
||||
} // namespace mold
|
||||
|
||||
#endif
|
@ -122,7 +122,7 @@
|
||||
|
||||
#include "mold.h"
|
||||
|
||||
namespace mold::elf {
|
||||
namespace mold {
|
||||
|
||||
// Returns the TP address which can be used for efficient TLV accesses in
|
||||
// the main executable. TP at runtime refers to a per-process TLS block
|
||||
@ -189,4 +189,4 @@ using E = MOLD_TARGET;
|
||||
template u64 get_tp_addr<E>(const ElfPhdr<E> &);
|
||||
template u64 get_dtp_addr<E>(const ElfPhdr<E> &);
|
||||
|
||||
} // namespace mold::elf
|
||||
} // namespace mold
|
Loading…
Reference in New Issue
Block a user