Skip to content

Commit

Permalink
Update comments
Browse files Browse the repository at this point in the history
  • Loading branch information
rui314 committed Dec 15, 2023
1 parent e921486 commit afe57e9
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 10 deletions.
18 changes: 9 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
# You can customize a build by specifying CMake options. An option may be
# given in the -Dvariable=value form. For a boolean variable, `ON` or `1`
# means true while `OFF` or `0` means false.
# means true, while `OFF` or `0` means false.
#
# Here are a couple of common cmake options:
#
# -DCMAKE_C_COMPILER=<command-name>
#
# Specifies a C compiler name to use. The default value is `cc`.
# Specifies the C compiler name to use. The default value is `cc`.
#
# -DCMAKE_CXX_COMPILER=<command-name>
#
# Specifies a C++ compiler name to use. The default value is `c++`.
# Specifies the C++ compiler name to use. The default value is `c++`.
#
# -DCMAKE_INSTALL_PREFIX=<directory>
#
# Specifies an install target directory. The default value is `/usr/local`.
# Specifies the install target directory. The default value is `/usr/local`.
#
# -DCMAKE_BUILD_TYPE=[Debug | Release | RelWithDebInfo | MinSizeRel]
#
# Specifies a build type. The default is `Release` which is the right
# Specifies the build type. The default is `Release`, which is the right
# option unless you are debugging mold.
#
# An example of a cmake command line is shown below:
#
# $ cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_CXX_COMPILER=g++-12 ..
#
# where `..` refers this directory.
# where `..` refers to this directory.
#
# With cmake, you may run `cmake --install .` instead of `make install` to
# install build artifacts to system directories. If you want to install
Expand All @@ -39,8 +39,8 @@
# how to build mold. However, as a policy, we do not provide a way to
# enable/disable any individual mold's feature. In other words, we do not
# provide options like `--enable-foo` or `--disable-foo`. The motivation
# behind it is build reproducibility. We want to guarantees that all builds
# of the mold linker of the same version will have the exactly same set of
# behind this is build reproducibility. We want to guarantee that all builds
# of the mold linker of the same version will have the exact same set of
# features and behave exactly the same.

cmake_minimum_required(VERSION 3.14)
Expand Down Expand Up @@ -134,7 +134,7 @@ else()
target_include_directories(mold PUBLIC third-party/blake3/c)
endif()

# Find zstd compression library. If libzstd.so is not found, we compile a
# Find zstd compression library. If zstd.h is not found, we compile a
# bundled one and statically-link it to mold.
include(CheckIncludeFile)
check_include_file(zstd.h HAVE_ZSTD_H)
Expand Down
27 changes: 27 additions & 0 deletions elf/arch-riscv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,33 @@ void InputSection<E>::apply_reloc_alloc(Context<E> &ctx, u8 *base) {
break;
}
case R_RISCV_TLSDESC_HI20:
// RISC-V TLSDESC uses the following code sequence to materialize
// a TP-relative address in x0.
//
// .L0:
// auipc tX, 0
// R_RISCV_TLSDESC_HI20 foo
// l[d|w] tY, tX, 0
// R_RISCV_TLSDESC_LOAD_LO12_I .L0
// addi a0, tX, 0
// R_RISCV_TLSDESC_ADD_LO12_I .L0
// jalr t0, tY
// R_RISCV_TLSDESC_CALL .L0
//
// For non-dlopen'd DSO, we may relax the instructions to the following:
//
// auipc a0, %gottp_hi(a0)
// l[d|w] a0, %gottp_lo(a0)
//
// For executable, if the TP offset is small enough, we'll relax
// it to the following:
//
// addi a0, zero, %tpoff_lo(a0)
//
// Otherwise, the following sequence is used:
//
// lui a0, %tpoff_hi(a0)
// addi a0, a0, %tpoff_lo(a0)
if (removed_bytes == 0)
write_utype(loc, sym.get_tlsdesc_addr(ctx) + A - P);
break;
Expand Down
2 changes: 1 addition & 1 deletion elf/passes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1609,7 +1609,7 @@ void rewrite_endbr(Context<E> &ctx) {
if (InputSection<E> *isec = sym->get_input_section()) {
if (OutputSection<E> *osec = isec->output_section) {
u8 *buf = ctx.buf + osec->shdr.sh_offset + isec->offset +
sym->value;
sym->value;
if (memcmp(buf, endbr64, 4) == 0)
memcpy(buf, nop, 4);
}
Expand Down

0 comments on commit afe57e9

Please sign in to comment.