Add `--aslr` and `--no-aslr` options.
This commit is contained in:
parent
24e665f38f
commit
61de46cea2
1
Changes
1
Changes
|
|
@ -25,6 +25,7 @@ Verilator 5.041 devel
|
||||||
* Add error on `virtual new` (#6486). [Alex Solomatnikov]
|
* Add error on `virtual new` (#6486). [Alex Solomatnikov]
|
||||||
* Add error on ranges with tristate values (#6534). [Alex Solomatnikov]
|
* Add error on ranges with tristate values (#6534). [Alex Solomatnikov]
|
||||||
* Add NORETURN warning on functions without return values (#6534). [Alex Solomatnikov]
|
* Add NORETURN warning on functions without return values (#6534). [Alex Solomatnikov]
|
||||||
|
* Add `--aslr` and `--no-aslr` options.
|
||||||
* Deprecate sensitivity list on public_flat_rw attributes (#6443). [Geza Lore]
|
* Deprecate sensitivity list on public_flat_rw attributes (#6443). [Geza Lore]
|
||||||
* Deprecate clocker attribute and --clk option (#6463). [Geza Lore]
|
* Deprecate clocker attribute and --clk option (#6463). [Geza Lore]
|
||||||
* Deprecate '--make cmake' option (#6540). [Geza Lore]
|
* Deprecate '--make cmake' option (#6540). [Geza Lore]
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ autoflush STDOUT 1;
|
||||||
autoflush STDERR 1;
|
autoflush STDERR 1;
|
||||||
|
|
||||||
$Debug = 0;
|
$Debug = 0;
|
||||||
|
my $opt_aslr;
|
||||||
my $opt_gdb;
|
my $opt_gdb;
|
||||||
my $opt_rr;
|
my $opt_rr;
|
||||||
my $opt_gdbbt;
|
my $opt_gdbbt;
|
||||||
|
|
@ -56,6 +57,7 @@ if (! GetOptions(
|
||||||
"debug" => \&debug,
|
"debug" => \&debug,
|
||||||
# "version!" => \&version, # Also passthru'ed
|
# "version!" => \&version, # Also passthru'ed
|
||||||
# Switches
|
# Switches
|
||||||
|
"aslr!" => \$opt_aslr,
|
||||||
"gdb!" => \$opt_gdb,
|
"gdb!" => \$opt_gdb,
|
||||||
"gdbbt!" => \$opt_gdbbt,
|
"gdbbt!" => \$opt_gdbbt,
|
||||||
"quiet!" => \$opt_quiet_exit, # As -quiet implies -quiet-exit
|
"quiet!" => \$opt_quiet_exit, # As -quiet implies -quiet-exit
|
||||||
|
|
@ -97,7 +99,7 @@ my @quoted_sw = map { sh_escape($_) } @Opt_Verilator_Sw;
|
||||||
if ($opt_gdb) {
|
if ($opt_gdb) {
|
||||||
# Generic GDB interactive
|
# Generic GDB interactive
|
||||||
run (ulimit_stack_unlimited()
|
run (ulimit_stack_unlimited()
|
||||||
. aslr_off()
|
. aslr(0)
|
||||||
. ($ENV{VERILATOR_GDB} || "gdb")
|
. ($ENV{VERILATOR_GDB} || "gdb")
|
||||||
. " " . verilator_bin()
|
. " " . verilator_bin()
|
||||||
# Note, uncomment to set breakpoints before running:
|
# Note, uncomment to set breakpoints before running:
|
||||||
|
|
@ -114,13 +116,13 @@ if ($opt_gdb) {
|
||||||
} elsif ($opt_rr) {
|
} elsif ($opt_rr) {
|
||||||
# Record with rr
|
# Record with rr
|
||||||
run (ulimit_stack_unlimited()
|
run (ulimit_stack_unlimited()
|
||||||
. aslr_off()
|
. aslr(0)
|
||||||
. "rr record " . verilator_bin()
|
. "rr record " . verilator_bin()
|
||||||
. " " . join(' ', @quoted_sw));
|
. " " . join(' ', @quoted_sw));
|
||||||
} elsif ($opt_gdbbt && $Debug) {
|
} elsif ($opt_gdbbt && $Debug) {
|
||||||
# Run under GDB to get gdbbt
|
# Run under GDB to get gdbbt
|
||||||
run (ulimit_stack_unlimited()
|
run (ulimit_stack_unlimited()
|
||||||
. aslr_off()
|
. aslr(0)
|
||||||
. "gdb"
|
. "gdb"
|
||||||
. " " . verilator_bin()
|
. " " . verilator_bin()
|
||||||
. " --batch --quiet --return-child-result"
|
. " --batch --quiet --return-child-result"
|
||||||
|
|
@ -135,19 +137,19 @@ if ($opt_gdb) {
|
||||||
);
|
);
|
||||||
|
|
||||||
run (ulimit_stack_unlimited()
|
run (ulimit_stack_unlimited()
|
||||||
. aslr_off()
|
. aslr(0)
|
||||||
. $valgrind_bin
|
. $valgrind_bin
|
||||||
. " " . verilator_bin()
|
. " " . verilator_bin()
|
||||||
. " " . join(' ', @quoted_sw));
|
. " " . join(' ', @quoted_sw));
|
||||||
} elsif ($Debug) {
|
} elsif ($Debug) {
|
||||||
# Debug
|
# Debug
|
||||||
run(ulimit_stack_unlimited()
|
run(ulimit_stack_unlimited()
|
||||||
. aslr_off()
|
. aslr(0)
|
||||||
. verilator_bin()
|
. verilator_bin()
|
||||||
. " " . join(' ', @quoted_sw));
|
. " " . join(' ', @quoted_sw));
|
||||||
} else {
|
} else {
|
||||||
# Normal, non gdb
|
# Normal, non gdb
|
||||||
run(ulimit_stack_unlimited() . verilator_bin() . " " . join(' ', @quoted_sw));
|
run(ulimit_stack_unlimited() . aslr(1) . verilator_bin() . " " . join(' ', @quoted_sw));
|
||||||
}
|
}
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
|
|
@ -192,13 +194,16 @@ sub gdb_works {
|
||||||
return $status == 0;
|
return $status == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub aslr_off {
|
sub aslr {
|
||||||
my $ok = `setarch --addr-no-randomize echo ok 2>/dev/null` || "";
|
my $want_on = shift;
|
||||||
if ($ok =~ /ok/) {
|
$want_on = $opt_aslr if defined $opt_aslr;
|
||||||
return "setarch --addr-no-randomize ";
|
if (!$want_on) {
|
||||||
} else {
|
my $ok = `setarch --addr-no-randomize echo ok 2>/dev/null` || "";
|
||||||
return "";
|
if ($ok =~ /ok/) {
|
||||||
|
return "setarch --addr-no-randomize ";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
sub ulimit_stack_unlimited {
|
sub ulimit_stack_unlimited {
|
||||||
|
|
@ -325,6 +330,7 @@ detailed descriptions of these arguments.
|
||||||
+1800-2012ext+<ext> Use SystemVerilog 2012 with file extension <ext>
|
+1800-2012ext+<ext> Use SystemVerilog 2012 with file extension <ext>
|
||||||
+1800-2017ext+<ext> Use SystemVerilog 2017 with file extension <ext>
|
+1800-2017ext+<ext> Use SystemVerilog 2017 with file extension <ext>
|
||||||
+1800-2023ext+<ext> Use SystemVerilog 2023 with file extension <ext>
|
+1800-2023ext+<ext> Use SystemVerilog 2023 with file extension <ext>
|
||||||
|
--no-aslr Disable address space layout randomization
|
||||||
--no-assert Disable all assertions
|
--no-assert Disable all assertions
|
||||||
--no-assert-case Disable unique/unique0/priority-case assertions
|
--no-assert-case Disable unique/unique0/priority-case assertions
|
||||||
--autoflush Flush streams after all $displays
|
--autoflush Flush streams after all $displays
|
||||||
|
|
|
||||||
|
|
@ -88,12 +88,23 @@ Summary:
|
||||||
grammar and other semantic extensions which might not be legal when
|
grammar and other semantic extensions which might not be legal when
|
||||||
set to an older standard.
|
set to an older standard.
|
||||||
|
|
||||||
|
.. option:: --aslr
|
||||||
|
|
||||||
|
.. option:: --no-aslr
|
||||||
|
|
||||||
|
Rarely needed - for developer use. With `--aslr`, do not change the
|
||||||
|
system default as to using Linux address space layout randomization
|
||||||
|
(ASLR). With `--no-aslr` attempt to disable ASLR. If not specified,
|
||||||
|
ASLR will be disabled only when using :vlopt:`--debug` (or similar
|
||||||
|
debug-related options), so that pointers have more deterministic values,
|
||||||
|
aiding repeatability.
|
||||||
|
|
||||||
.. option:: --no-assert
|
.. option:: --no-assert
|
||||||
|
|
||||||
Disable all assertions. Implies :vlopt:`--no-assert-case`.
|
Disable all assertions. Implies :vlopt:`--no-assert-case`.
|
||||||
|
|
||||||
In versions before 5.038, these were disabled by default, and `--assert`
|
In versions before 5.038, assertions were disabled by default, and
|
||||||
was required to enable assertions.
|
`--assert` was required to enable assertions.
|
||||||
|
|
||||||
.. option:: --no-assert-case
|
.. option:: --no-assert-case
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -531,6 +531,7 @@ architected
|
||||||
args
|
args
|
||||||
arrarys
|
arrarys
|
||||||
asan
|
asan
|
||||||
|
aslr
|
||||||
assertOn
|
assertOn
|
||||||
assertcontrol
|
assertcontrol
|
||||||
astgen
|
astgen
|
||||||
|
|
|
||||||
|
|
@ -1237,6 +1237,7 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc,
|
||||||
[this](const char* optp) { addLangExt(optp, V3LangCode::L1800_2023); });
|
[this](const char* optp) { addLangExt(optp, V3LangCode::L1800_2023); });
|
||||||
|
|
||||||
// Minus options
|
// Minus options
|
||||||
|
DECL_OPTION("-aslr", CbOnOff, [](bool) {}); // Processed only in bin/verilator shell
|
||||||
DECL_OPTION("-assert", CbOnOff, [this](bool flag) {
|
DECL_OPTION("-assert", CbOnOff, [this](bool flag) {
|
||||||
m_assert = flag;
|
m_assert = flag;
|
||||||
m_assertCase = flag;
|
m_assertCase = flag;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
|
||||||
|
#
|
||||||
|
# Copyright 2024 by Wilson Snyder. This program is free software; you
|
||||||
|
# can redistribute it and/or modify it under the terms of either the GNU
|
||||||
|
# Lesser General Public License Version 3 or the Perl Artistic License
|
||||||
|
# Version 2.0.
|
||||||
|
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||||
|
|
||||||
|
import vltest_bootstrap
|
||||||
|
|
||||||
|
test.scenarios('vlt')
|
||||||
|
test.top_filename = 't/t_EXAMPLE.v'
|
||||||
|
|
||||||
|
test.lint(v_flags2=["--aslr"])
|
||||||
|
|
||||||
|
test.passes()
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
|
||||||
|
#
|
||||||
|
# Copyright 2024 by Wilson Snyder. This program is free software; you
|
||||||
|
# can redistribute it and/or modify it under the terms of either the GNU
|
||||||
|
# Lesser General Public License Version 3 or the Perl Artistic License
|
||||||
|
# Version 2.0.
|
||||||
|
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
||||||
|
|
||||||
|
import vltest_bootstrap
|
||||||
|
|
||||||
|
test.scenarios('vlt')
|
||||||
|
test.top_filename = 't/t_EXAMPLE.v'
|
||||||
|
|
||||||
|
test.lint(v_flags2=["--no-aslr"])
|
||||||
|
|
||||||
|
test.passes()
|
||||||
Loading…
Reference in New Issue