mirror of
https://github.com/rui314/mold.git
synced 2024-10-04 16:48:04 +03:00
parent
013e6ea06e
commit
e29bd8f42b
@ -660,6 +660,8 @@ void parse_nonpositional_args(Context<E> &ctx,
|
||||
ctx.arg.z_keep_text_section_prefix = true;
|
||||
} else if (read_z_flag(args, "nokeep-text-section-prefix")) {
|
||||
ctx.arg.z_keep_text_section_prefix = false;
|
||||
} else if (read_z_flag(args, "shstk")) {
|
||||
ctx.arg.z_shstk = true;
|
||||
} else if (read_z_flag(args, "text")) {
|
||||
ctx.arg.z_text = true;
|
||||
} else if (read_z_flag(args, "notext") || read_z_flag(args, "textoff")) {
|
||||
|
@ -227,6 +227,9 @@ static constexpr u32 NT_GNU_PROPERTY_TYPE_0 = 5;
|
||||
static constexpr u32 GNU_PROPERTY_AARCH64_FEATURE_1_AND = 0xc0000000;
|
||||
static constexpr u32 GNU_PROPERTY_X86_FEATURE_1_AND = 0xc0000002;
|
||||
|
||||
static constexpr u32 GNU_PROPERTY_X86_FEATURE_1_IBT = 1;
|
||||
static constexpr u32 GNU_PROPERTY_X86_FEATURE_1_SHSTK = 2;
|
||||
|
||||
static constexpr u32 ELFCOMPRESS_ZLIB = 1;
|
||||
|
||||
static constexpr u32 R_X86_64_NONE = 0;
|
||||
|
@ -1265,6 +1265,7 @@ struct Context {
|
||||
bool z_now = false;
|
||||
bool z_origin = false;
|
||||
bool z_relro = true;
|
||||
bool z_shstk = false;
|
||||
bool z_text = false;
|
||||
u16 default_version = VER_NDX_GLOBAL;
|
||||
i64 emulation = -1;
|
||||
|
@ -1769,6 +1769,9 @@ void NotePropertySection<E>::update_shdr(Context<E> &ctx) {
|
||||
if (file != ctx.internal_obj)
|
||||
features &= file->features;
|
||||
|
||||
if (ctx.arg.z_shstk)
|
||||
features |= GNU_PROPERTY_X86_FEATURE_1_SHSTK;
|
||||
|
||||
if (features != 0 && features != -1)
|
||||
this->shdr.sh_size = (E::word_size == 8) ? 32 : 28;
|
||||
}
|
||||
|
25
test/elf/z-shstk.sh
Executable file
25
test/elf/z-shstk.sh
Executable file
@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
export LANG=
|
||||
set -e
|
||||
CC="${CC:-cc}"
|
||||
CXX="${CXX:-c++}"
|
||||
testname=$(basename -s .sh "$0")
|
||||
echo -n "Testing $testname ... "
|
||||
cd "$(dirname "$0")"/../..
|
||||
mold="$(pwd)/mold"
|
||||
t=out/test/elf/$testname
|
||||
mkdir -p $t
|
||||
|
||||
cat <<EOF | $CC -o $t/a.o -c -x assembler -
|
||||
.globl main
|
||||
main:
|
||||
EOF
|
||||
|
||||
$CC -B. -o $t/exe $t/a.o
|
||||
readelf --notes $t/exe > $t/log
|
||||
! grep -qw SHSTK $t/log
|
||||
|
||||
$CC -B. -o $t/exe $t/a.o -Wl,-z,shstk
|
||||
readelf --notes $t/exe | grep -qw SHSTK
|
||||
|
||||
echo OK
|
Loading…
Reference in New Issue
Block a user