put the embedded blob code to the .openbsd.mutable section and

mprotect it RX to support x-only

idea from deraadt@, diff from kettenis@
This commit is contained in:
robert 2023-01-28 13:39:20 +00:00
parent ed20f890af
commit 4bc85882f4
26 changed files with 465 additions and 54 deletions

View File

@ -1,14 +1,13 @@
BROKEN-powerpc64 = Check failed: false. OS architecture not handled. (powerpc64)
USE_WXNEEDED= Yes
USE_NOEXECONLY= Yes
DPB_PROPERTIES= parallel parallel2
COMMENT= Chromium browser
V= 109.0.5414.119
REVISION= 0
REVISION= 1
DISTNAME= chromium-${V}

View File

@ -19,19 +19,18 @@ Index: build/config/compiler/BUILD.gn
}
# compiler ---------------------------------------------------------------------
@@ -454,6 +457,11 @@ config("compiler") {
@@ -454,6 +457,10 @@ config("compiler") {
}
}
+ if (is_openbsd) {
+ ldflags += [ "-Wl,-z,wxneeded" ]
+ ldflags += [ "-Wl,--no-execute-only" ]
+ }
+
# Linux-specific compiler flags setup.
# ------------------------------------
if (use_gold) {
@@ -529,7 +537,7 @@ config("compiler") {
@@ -529,7 +536,7 @@ config("compiler") {
ldflags += [ "-Wl,-z,keep-text-section-prefix" ]
}
@ -40,7 +39,7 @@ Index: build/config/compiler/BUILD.gn
cflags += [ "-fcrash-diagnostics-dir=" + clang_diagnostic_dir ]
if (save_reproducers_on_lld_crash && use_lld) {
ldflags += [
@@ -808,7 +816,7 @@ config("compiler") {
@@ -808,7 +815,7 @@ config("compiler") {
# lldb doesn't have the needed changes yet.
# * Fuchsia isn't supported as zxdb doesn't support simple template names yet.
# TODO(crbug.com/1379070): Remove if the upstream default ever changes.
@ -49,7 +48,7 @@ Index: build/config/compiler/BUILD.gn
cflags_cc += [ "-gsimple-template-names" ]
}
@@ -958,7 +966,7 @@ config("compiler_cpu_abi") {
@@ -958,7 +965,7 @@ config("compiler_cpu_abi") {
]
}
} else if (current_cpu == "arm") {
@ -58,7 +57,7 @@ Index: build/config/compiler/BUILD.gn
!(is_chromeos_lacros && is_chromeos_device)) {
cflags += [ "--target=arm-linux-gnueabihf" ]
ldflags += [ "--target=arm-linux-gnueabihf" ]
@@ -973,7 +981,7 @@ config("compiler_cpu_abi") {
@@ -973,7 +980,7 @@ config("compiler_cpu_abi") {
cflags += [ "-mtune=$arm_tune" ]
}
} else if (current_cpu == "arm64") {
@ -67,7 +66,7 @@ Index: build/config/compiler/BUILD.gn
!(is_chromeos_lacros && is_chromeos_device)) {
cflags += [ "--target=aarch64-linux-gnu" ]
ldflags += [ "--target=aarch64-linux-gnu" ]
@@ -1307,7 +1315,7 @@ config("compiler_deterministic") {
@@ -1307,7 +1314,7 @@ config("compiler_deterministic") {
# different build directory like "out/feature_a" and "out/feature_b" if
# we build same files with same compile flag.
# Other paths are already given in relative, no need to normalize them.
@ -76,7 +75,7 @@ Index: build/config/compiler/BUILD.gn
# TODO(https://crbug.com/1231236): Use -ffile-compilation-dir= here.
cflags += [
"-Xclang",
@@ -1359,7 +1367,7 @@ config("compiler_deterministic") {
@@ -1359,7 +1366,7 @@ config("compiler_deterministic") {
}
config("clang_revision") {
@ -85,7 +84,7 @@ Index: build/config/compiler/BUILD.gn
update_args = [
"--print-revision",
"--verify-version=$clang_version",
@@ -1600,7 +1608,7 @@ config("default_warnings") {
@@ -1600,7 +1607,7 @@ config("default_warnings") {
"-Wno-ignored-pragma-optimize",
]
@ -94,7 +93,7 @@ Index: build/config/compiler/BUILD.gn
cflags += [
# TODO(crbug.com/1343975) Evaluate and possibly enable.
"-Wno-deprecated-builtins",
@@ -1779,7 +1787,7 @@ config("no_chromium_code") {
@@ -1779,7 +1786,7 @@ config("no_chromium_code") {
# third-party libraries.
"-Wno-c++11-narrowing",
]
@ -103,7 +102,7 @@ Index: build/config/compiler/BUILD.gn
cflags += [
# Disabled for similar reasons as -Wunused-variable.
"-Wno-unused-but-set-variable",
@@ -2301,7 +2309,7 @@ config("afdo_optimize_size") {
@@ -2301,7 +2308,7 @@ config("afdo_optimize_size") {
# There are some targeted places that AFDO regresses, so we provide a separate
# config to allow AFDO to be disabled per-target.
config("afdo") {
@ -112,7 +111,7 @@ Index: build/config/compiler/BUILD.gn
cflags = []
if (clang_emit_debug_info_for_profiling) {
# Add the following flags to generate debug info for profiling.
@@ -2317,7 +2325,7 @@ config("afdo") {
@@ -2317,7 +2324,7 @@ config("afdo") {
cflags += [ "-fprofile-sample-use=${rebased_clang_sample_profile}" ]
inputs = [ _clang_sample_profile ]
}
@ -121,7 +120,7 @@ Index: build/config/compiler/BUILD.gn
cflags = [ "-fauto-profile=${auto_profile_path}" ]
inputs = [ auto_profile_path ]
}
@@ -2464,7 +2472,8 @@ config("symbols") {
@@ -2464,7 +2471,8 @@ config("symbols") {
configs += [ "//build/config:compress_debug_sections" ]
}

View File

@ -0,0 +1,26 @@
Index: v8/src/execution/isolate.cc
--- v8/src/execution/isolate.cc.orig
+++ v8/src/execution/isolate.cc
@@ -144,6 +144,10 @@
#include "src/execution/simulator-base.h"
#endif
+#if defined(V8_OS_OPENBSD)
+#include <sys/mman.h>
+#endif
+
extern "C" const uint8_t v8_Default_embedded_blob_code_[];
extern "C" uint32_t v8_Default_embedded_blob_code_size_;
extern "C" const uint8_t v8_Default_embedded_blob_data_[];
@@ -3884,6 +3888,11 @@ void Isolate::InitializeDefaultEmbeddedBlob() {
uint32_t code_size = DefaultEmbeddedBlobCodeSize();
const uint8_t* data = DefaultEmbeddedBlobData();
uint32_t data_size = DefaultEmbeddedBlobDataSize();
+
+#if defined(V8_OS_OPENBSD)
+ mprotect(reinterpret_cast<void *>(const_cast<uint8_t *>(code)),
+ code_size, PROT_READ | PROT_EXEC);
+#endif
if (StickyEmbeddedBlobCode() != nullptr) {
base::MutexGuard guard(current_embedded_blob_refcount_mutex_.Pointer());

View File

@ -0,0 +1,12 @@
Index: v8/src/snapshot/embedded/platform-embedded-file-writer-base.cc
--- v8/src/snapshot/embedded/platform-embedded-file-writer-base.cc.orig
+++ v8/src/snapshot/embedded/platform-embedded-file-writer-base.cc
@@ -142,6 +142,8 @@ EmbeddedTargetOs ToEmbeddedTargetOs(const char* s) {
return EmbeddedTargetOs::kWin;
} else if (string == "starboard") {
return EmbeddedTargetOs::kStarboard;
+ } else if (string == "openbsd") {
+ return EmbeddedTargetOs::kOpenBSD;
} else {
return EmbeddedTargetOs::kGeneric;
}

View File

@ -0,0 +1,11 @@
Index: v8/src/snapshot/embedded/platform-embedded-file-writer-base.h
--- v8/src/snapshot/embedded/platform-embedded-file-writer-base.h.orig
+++ v8/src/snapshot/embedded/platform-embedded-file-writer-base.h
@@ -31,6 +31,7 @@ enum class EmbeddedTargetOs {
kMac,
kWin,
kStarboard,
+ kOpenBSD,
kGeneric, // Everything not covered above falls in here.
};

View File

@ -0,0 +1,41 @@
Index: v8/src/snapshot/embedded/platform-embedded-file-writer-generic.cc
--- v8/src/snapshot/embedded/platform-embedded-file-writer-generic.cc.orig
+++ v8/src/snapshot/embedded/platform-embedded-file-writer-generic.cc
@@ -9,6 +9,10 @@
#include "src/objects/code.h"
+#if V8_OS_OPENBSD
+#include <sys/param.h>
+#endif
+
namespace v8 {
namespace internal {
@@ -35,6 +39,8 @@ const char* DirectiveAsString(DataDirective directive)
void PlatformEmbeddedFileWriterGeneric::SectionText() {
if (target_os_ == EmbeddedTargetOs::kChromeOS) {
fprintf(fp_, ".section .text.hot.embedded\n");
+ } else if (target_os_ == EmbeddedTargetOs::kOpenBSD) {
+ fprintf(fp_, ".section .openbsd.mutable,\"a\"\n");
} else {
fprintf(fp_, ".section .text\n");
}
@@ -66,6 +72,8 @@ void PlatformEmbeddedFileWriterGeneric::AlignToCodeAli
// On these architectures and platforms, we remap the builtins, so need these
// to be aligned on a page boundary.
fprintf(fp_, ".balign 4096\n");
+#elif V8_OS_OPENBSD
+ fprintf(fp_, ".balign %d\n", PAGE_SIZE);
#elif V8_TARGET_ARCH_X64
// On x64 use 64-bytes code alignment to allow 64-bytes loop header alignment.
static_assert(64 >= kCodeAlignment);
@@ -86,6 +94,8 @@ void PlatformEmbeddedFileWriterGeneric::AlignToPageSiz
(V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_ARM64)
// Since the builtins are remapped, need to pad until the next page boundary.
fprintf(fp_, ".balign 4096\n");
+#elif V8_OS_OPENBSD
+ fprintf(fp_, ".balign %d\n", PAGE_SIZE);
#endif
}

View File

@ -2,7 +2,6 @@ BROKEN-powerpc64 = Check failed: false. OS architecture not handled. (powerpc64)
BROKEN-riscv64 = Unknown current CPU: riscv64
USE_WXNEEDED= Yes
USE_NOEXECONLY= Yes
DPB_PROPERTIES= parallel parallel2
.if ${MACHINE_ARCH} == "i386"
@ -13,7 +12,7 @@ COMMENT= Iridium browser
V= 2023.01.109
REVISION= 4
REVISION= 5
DISTNAME= iridium-browser-${V}
PKGNAME= iridium-${V}

View File

@ -29,19 +29,18 @@ Index: build/config/compiler/BUILD.gn
":compiler_codegen",
":compiler_deterministic",
]
@@ -452,6 +457,11 @@ config("compiler") {
@@ -452,6 +457,10 @@ config("compiler") {
}
}
+ if (is_openbsd) {
+ ldflags += [ "-Wl,-z,wxneeded" ]
+ ldflags += [ "-Wl,--no-execute-only" ]
+ }
+
# Linux-specific compiler flags setup.
# ------------------------------------
if (use_gold) {
@@ -912,7 +922,7 @@ config("compiler_cpu_abi") {
@@ -912,7 +921,7 @@ config("compiler_cpu_abi") {
]
}
} else if (current_cpu == "arm") {
@ -50,7 +49,7 @@ Index: build/config/compiler/BUILD.gn
!(is_chromeos_lacros && is_chromeos_device)) {
cflags += [ "--target=arm-linux-gnueabihf" ]
ldflags += [ "--target=arm-linux-gnueabihf" ]
@@ -927,7 +937,7 @@ config("compiler_cpu_abi") {
@@ -927,7 +936,7 @@ config("compiler_cpu_abi") {
cflags += [ "-mtune=$arm_tune" ]
}
} else if (current_cpu == "arm64") {
@ -59,7 +58,7 @@ Index: build/config/compiler/BUILD.gn
!(is_chromeos_lacros && is_chromeos_device)) {
cflags += [ "--target=aarch64-linux-gnu" ]
ldflags += [ "--target=aarch64-linux-gnu" ]
@@ -1272,6 +1282,27 @@ config("compiler_deterministic") {
@@ -1272,6 +1281,27 @@ config("compiler_deterministic") {
}
}
@ -87,7 +86,7 @@ Index: build/config/compiler/BUILD.gn
config("rustc_revision") {
if (enable_rust && defined(rustc_version)) {
# Similar to the above config, this is here so that all files get
@@ -1493,7 +1524,7 @@ config("default_warnings") {
@@ -1493,7 +1523,7 @@ config("default_warnings") {
"-Wno-ignored-pragma-optimize",
]
@ -96,7 +95,7 @@ Index: build/config/compiler/BUILD.gn
cflags += [
# TODO(crbug.com/1343975) Evaluate and possibly enable.
"-Wno-deprecated-builtins",
@@ -1658,7 +1689,7 @@ config("no_chromium_code") {
@@ -1658,7 +1688,7 @@ config("no_chromium_code") {
# third-party libraries.
"-Wno-c++11-narrowing",
]
@ -105,7 +104,7 @@ Index: build/config/compiler/BUILD.gn
cflags += [
# Disabled for similar reasons as -Wunused-variable.
"-Wno-unused-but-set-variable",
@@ -1970,8 +2001,7 @@ config("default_stack_frames") {
@@ -1970,8 +2000,7 @@ config("default_stack_frames") {
}
# Default "optimization on" config.
@ -115,7 +114,7 @@ Index: build/config/compiler/BUILD.gn
if (is_win) {
if (chrome_pgo_phase != 2) {
# Favor size over speed, /O1 must be before the common flags.
@@ -2016,8 +2046,7 @@ config("xoptimize") {
@@ -2016,8 +2045,7 @@ config("xoptimize") {
}
# Turn off optimizations.
@ -125,7 +124,7 @@ Index: build/config/compiler/BUILD.gn
if (is_win) {
cflags = [
"/Od", # Disable optimization.
@@ -2057,8 +2086,7 @@ config("xno_optimize") {
@@ -2057,8 +2085,7 @@ config("xno_optimize") {
# Turns up the optimization level. On Windows, this implies whole program
# optimization and link-time code generation which is very expensive and should
# be used sparingly.
@ -135,7 +134,7 @@ Index: build/config/compiler/BUILD.gn
if (is_nacl && is_nacl_irt) {
# The NaCl IRT is a special case and always wants its own config.
# Various components do:
@@ -2091,8 +2119,7 @@ config("xoptimize_max") {
@@ -2091,8 +2118,7 @@ config("xoptimize_max") {
#
# TODO(crbug.com/621335) - rework how all of these configs are related
# so that we don't need this disclaimer.
@ -145,7 +144,7 @@ Index: build/config/compiler/BUILD.gn
if (is_nacl && is_nacl_irt) {
# The NaCl IRT is a special case and always wants its own config.
# Various components do:
@@ -2118,8 +2145,7 @@ config("xoptimize_speed") {
@@ -2118,8 +2144,7 @@ config("xoptimize_speed") {
}
}
@ -155,7 +154,7 @@ Index: build/config/compiler/BUILD.gn
cflags = [ "-O1" ] + common_optimize_on_cflags
rustflags = [ "-Copt-level=1" ]
ldflags = common_optimize_on_ldflags
@@ -2185,7 +2211,7 @@ config("afdo_optimize_size") {
@@ -2185,7 +2210,7 @@ config("afdo_optimize_size") {
# There are some targeted places that AFDO regresses, so we provide a separate
# config to allow AFDO to be disabled per-target.
config("afdo") {
@ -164,7 +163,7 @@ Index: build/config/compiler/BUILD.gn
cflags = []
if (clang_emit_debug_info_for_profiling) {
# Add the following flags to generate debug info for profiling.
@@ -2201,7 +2227,7 @@ config("afdo") {
@@ -2201,7 +2226,7 @@ config("afdo") {
cflags += [ "-fprofile-sample-use=${rebased_clang_sample_profile}" ]
inputs = [ _clang_sample_profile ]
}
@ -173,7 +172,7 @@ Index: build/config/compiler/BUILD.gn
cflags = [ "-fauto-profile=${auto_profile_path}" ]
inputs = [ auto_profile_path ]
}
@@ -2239,8 +2265,7 @@ config("win_pdbaltpath") {
@@ -2239,8 +2264,7 @@ config("win_pdbaltpath") {
}
# Full symbols.
@ -183,7 +182,7 @@ Index: build/config/compiler/BUILD.gn
if (is_win) {
if (is_clang) {
cflags = [ "/Z7" ] # Debug information in the .obj files.
@@ -2349,7 +2374,8 @@ config("xsymbols") {
@@ -2349,7 +2373,8 @@ config("xsymbols") {
configs += [ "//build/config:compress_debug_sections" ]
}
@ -193,7 +192,7 @@ Index: build/config/compiler/BUILD.gn
if (is_apple) {
# TODO(https://crbug.com/1050118): Investigate missing debug info on mac.
# Make sure we don't use constructor homing on mac.
@@ -2372,8 +2398,7 @@ config("xsymbols") {
@@ -2372,8 +2397,7 @@ config("xsymbols") {
# Minimal symbols.
# This config guarantees to hold symbol for stack trace which are shown to user
# when crash happens in unittests running on buildbot.
@ -203,7 +202,7 @@ Index: build/config/compiler/BUILD.gn
if (is_win) {
# Functions, files, and line tables only.
cflags = []
@@ -2446,8 +2471,7 @@ config("xminimal_symbols") {
@@ -2446,8 +2470,7 @@ config("xminimal_symbols") {
# This configuration contains function names only. That is, the compiler is
# told to not generate debug information and the linker then just puts function
# names in the final debug information.

View File

@ -0,0 +1,26 @@
Index: v8/src/execution/isolate.cc
--- v8/src/execution/isolate.cc.orig
+++ v8/src/execution/isolate.cc
@@ -144,6 +144,10 @@
#include "src/execution/simulator-base.h"
#endif
+#if defined(V8_OS_OPENBSD)
+#include <sys/mman.h>
+#endif
+
extern "C" const uint8_t v8_Default_embedded_blob_code_[];
extern "C" uint32_t v8_Default_embedded_blob_code_size_;
extern "C" const uint8_t v8_Default_embedded_blob_data_[];
@@ -3884,6 +3888,11 @@ void Isolate::InitializeDefaultEmbeddedBlob() {
uint32_t code_size = DefaultEmbeddedBlobCodeSize();
const uint8_t* data = DefaultEmbeddedBlobData();
uint32_t data_size = DefaultEmbeddedBlobDataSize();
+
+#if defined(V8_OS_OPENBSD)
+ mprotect(reinterpret_cast<void *>(const_cast<uint8_t *>(code)),
+ code_size, PROT_READ | PROT_EXEC);
+#endif
if (StickyEmbeddedBlobCode() != nullptr) {
base::MutexGuard guard(current_embedded_blob_refcount_mutex_.Pointer());

View File

@ -0,0 +1,12 @@
Index: v8/src/snapshot/embedded/platform-embedded-file-writer-base.cc
--- v8/src/snapshot/embedded/platform-embedded-file-writer-base.cc.orig
+++ v8/src/snapshot/embedded/platform-embedded-file-writer-base.cc
@@ -142,6 +142,8 @@ EmbeddedTargetOs ToEmbeddedTargetOs(const char* s) {
return EmbeddedTargetOs::kWin;
} else if (string == "starboard") {
return EmbeddedTargetOs::kStarboard;
+ } else if (string == "openbsd") {
+ return EmbeddedTargetOs::kOpenBSD;
} else {
return EmbeddedTargetOs::kGeneric;
}

View File

@ -0,0 +1,11 @@
Index: v8/src/snapshot/embedded/platform-embedded-file-writer-base.h
--- v8/src/snapshot/embedded/platform-embedded-file-writer-base.h.orig
+++ v8/src/snapshot/embedded/platform-embedded-file-writer-base.h
@@ -31,6 +31,7 @@ enum class EmbeddedTargetOs {
kMac,
kWin,
kStarboard,
+ kOpenBSD,
kGeneric, // Everything not covered above falls in here.
};

View File

@ -0,0 +1,41 @@
Index: v8/src/snapshot/embedded/platform-embedded-file-writer-generic.cc
--- v8/src/snapshot/embedded/platform-embedded-file-writer-generic.cc.orig
+++ v8/src/snapshot/embedded/platform-embedded-file-writer-generic.cc
@@ -9,6 +9,10 @@
#include "src/objects/code.h"
+#if V8_OS_OPENBSD
+#include <sys/param.h>
+#endif
+
namespace v8 {
namespace internal {
@@ -35,6 +39,8 @@ const char* DirectiveAsString(DataDirective directive)
void PlatformEmbeddedFileWriterGeneric::SectionText() {
if (target_os_ == EmbeddedTargetOs::kChromeOS) {
fprintf(fp_, ".section .text.hot.embedded\n");
+ } else if (target_os_ == EmbeddedTargetOs::kOpenBSD) {
+ fprintf(fp_, ".section .openbsd.mutable,\"a\"\n");
} else {
fprintf(fp_, ".section .text\n");
}
@@ -66,6 +72,8 @@ void PlatformEmbeddedFileWriterGeneric::AlignToCodeAli
// On these architectures and platforms, we remap the builtins, so need these
// to be aligned on a page boundary.
fprintf(fp_, ".balign 4096\n");
+#elif V8_OS_OPENBSD
+ fprintf(fp_, ".balign %d\n", PAGE_SIZE);
#elif V8_TARGET_ARCH_X64
// On x64 use 64-bytes code alignment to allow 64-bytes loop header alignment.
static_assert(64 >= kCodeAlignment);
@@ -86,6 +94,8 @@ void PlatformEmbeddedFileWriterGeneric::AlignToPageSiz
(V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_ARM64)
// Since the builtins are remapped, need to pad until the next page boundary.
fprintf(fp_, ".balign 4096\n");
+#elif V8_OS_OPENBSD
+ fprintf(fp_, ".balign %d\n", PAGE_SIZE);
#endif
}

View File

@ -2,7 +2,6 @@ BROKEN-powerpc64 = Check failed: false. OS architecture not handled. (powerpc64)
BROKEN-riscv64 = Unknown current CPU: riscv64
USE_WXNEEDED= Yes
USE_NOEXECONLY= Yes
DPB_PROPERTIES= parallel parallel2
@ -11,7 +10,7 @@ COMMENT= Chromium browser sans integration with Google
V= 109.0.5414.119
UGV= ${V}-1
REVISION= 0
REVISION= 1
DISTNAME= ungoogled-chromium-${V}

View File

@ -19,19 +19,18 @@ Index: build/config/compiler/BUILD.gn
}
# compiler ---------------------------------------------------------------------
@@ -454,6 +457,11 @@ config("compiler") {
@@ -454,6 +457,10 @@ config("compiler") {
}
}
+ if (is_openbsd) {
+ ldflags += [ "-Wl,-z,wxneeded" ]
+ ldflags += [ "-Wl,--no-execute-only" ]
+ }
+
# Linux-specific compiler flags setup.
# ------------------------------------
if (use_gold) {
@@ -529,7 +537,7 @@ config("compiler") {
@@ -529,7 +536,7 @@ config("compiler") {
ldflags += [ "-Wl,-z,keep-text-section-prefix" ]
}
@ -40,7 +39,7 @@ Index: build/config/compiler/BUILD.gn
cflags += [ "-fcrash-diagnostics-dir=" + clang_diagnostic_dir ]
if (save_reproducers_on_lld_crash && use_lld) {
ldflags += [
@@ -808,7 +816,7 @@ config("compiler") {
@@ -808,7 +815,7 @@ config("compiler") {
# lldb doesn't have the needed changes yet.
# * Fuchsia isn't supported as zxdb doesn't support simple template names yet.
# TODO(crbug.com/1379070): Remove if the upstream default ever changes.
@ -49,7 +48,7 @@ Index: build/config/compiler/BUILD.gn
cflags_cc += [ "-gsimple-template-names" ]
}
@@ -958,7 +966,7 @@ config("compiler_cpu_abi") {
@@ -958,7 +965,7 @@ config("compiler_cpu_abi") {
]
}
} else if (current_cpu == "arm") {
@ -58,7 +57,7 @@ Index: build/config/compiler/BUILD.gn
!(is_chromeos_lacros && is_chromeos_device)) {
cflags += [ "--target=arm-linux-gnueabihf" ]
ldflags += [ "--target=arm-linux-gnueabihf" ]
@@ -973,7 +981,7 @@ config("compiler_cpu_abi") {
@@ -973,7 +980,7 @@ config("compiler_cpu_abi") {
cflags += [ "-mtune=$arm_tune" ]
}
} else if (current_cpu == "arm64") {
@ -67,7 +66,7 @@ Index: build/config/compiler/BUILD.gn
!(is_chromeos_lacros && is_chromeos_device)) {
cflags += [ "--target=aarch64-linux-gnu" ]
ldflags += [ "--target=aarch64-linux-gnu" ]
@@ -1307,7 +1315,7 @@ config("compiler_deterministic") {
@@ -1307,7 +1314,7 @@ config("compiler_deterministic") {
# different build directory like "out/feature_a" and "out/feature_b" if
# we build same files with same compile flag.
# Other paths are already given in relative, no need to normalize them.
@ -76,7 +75,7 @@ Index: build/config/compiler/BUILD.gn
# TODO(https://crbug.com/1231236): Use -ffile-compilation-dir= here.
cflags += [
"-Xclang",
@@ -1359,7 +1367,7 @@ config("compiler_deterministic") {
@@ -1359,7 +1366,7 @@ config("compiler_deterministic") {
}
config("clang_revision") {
@ -85,7 +84,7 @@ Index: build/config/compiler/BUILD.gn
update_args = [
"--print-revision",
"--verify-version=$clang_version",
@@ -1600,7 +1608,7 @@ config("default_warnings") {
@@ -1600,7 +1607,7 @@ config("default_warnings") {
"-Wno-ignored-pragma-optimize",
]
@ -94,7 +93,7 @@ Index: build/config/compiler/BUILD.gn
cflags += [
# TODO(crbug.com/1343975) Evaluate and possibly enable.
"-Wno-deprecated-builtins",
@@ -1779,7 +1787,7 @@ config("no_chromium_code") {
@@ -1779,7 +1786,7 @@ config("no_chromium_code") {
# third-party libraries.
"-Wno-c++11-narrowing",
]
@ -103,7 +102,7 @@ Index: build/config/compiler/BUILD.gn
cflags += [
# Disabled for similar reasons as -Wunused-variable.
"-Wno-unused-but-set-variable",
@@ -2301,7 +2309,7 @@ config("afdo_optimize_size") {
@@ -2301,7 +2308,7 @@ config("afdo_optimize_size") {
# There are some targeted places that AFDO regresses, so we provide a separate
# config to allow AFDO to be disabled per-target.
config("afdo") {
@ -112,7 +111,7 @@ Index: build/config/compiler/BUILD.gn
cflags = []
if (clang_emit_debug_info_for_profiling) {
# Add the following flags to generate debug info for profiling.
@@ -2317,7 +2325,7 @@ config("afdo") {
@@ -2317,7 +2324,7 @@ config("afdo") {
cflags += [ "-fprofile-sample-use=${rebased_clang_sample_profile}" ]
inputs = [ _clang_sample_profile ]
}
@ -121,7 +120,7 @@ Index: build/config/compiler/BUILD.gn
cflags = [ "-fauto-profile=${auto_profile_path}" ]
inputs = [ auto_profile_path ]
}
@@ -2464,7 +2472,8 @@ config("symbols") {
@@ -2464,7 +2471,8 @@ config("symbols") {
configs += [ "//build/config:compress_debug_sections" ]
}

View File

@ -0,0 +1,26 @@
Index: v8/src/execution/isolate.cc
--- v8/src/execution/isolate.cc.orig
+++ v8/src/execution/isolate.cc
@@ -144,6 +144,10 @@
#include "src/execution/simulator-base.h"
#endif
+#if defined(V8_OS_OPENBSD)
+#include <sys/mman.h>
+#endif
+
extern "C" const uint8_t v8_Default_embedded_blob_code_[];
extern "C" uint32_t v8_Default_embedded_blob_code_size_;
extern "C" const uint8_t v8_Default_embedded_blob_data_[];
@@ -3884,6 +3888,11 @@ void Isolate::InitializeDefaultEmbeddedBlob() {
uint32_t code_size = DefaultEmbeddedBlobCodeSize();
const uint8_t* data = DefaultEmbeddedBlobData();
uint32_t data_size = DefaultEmbeddedBlobDataSize();
+
+#if defined(V8_OS_OPENBSD)
+ mprotect(reinterpret_cast<void *>(const_cast<uint8_t *>(code)),
+ code_size, PROT_READ | PROT_EXEC);
+#endif
if (StickyEmbeddedBlobCode() != nullptr) {
base::MutexGuard guard(current_embedded_blob_refcount_mutex_.Pointer());

View File

@ -0,0 +1,12 @@
Index: v8/src/snapshot/embedded/platform-embedded-file-writer-base.cc
--- v8/src/snapshot/embedded/platform-embedded-file-writer-base.cc.orig
+++ v8/src/snapshot/embedded/platform-embedded-file-writer-base.cc
@@ -142,6 +142,8 @@ EmbeddedTargetOs ToEmbeddedTargetOs(const char* s) {
return EmbeddedTargetOs::kWin;
} else if (string == "starboard") {
return EmbeddedTargetOs::kStarboard;
+ } else if (string == "openbsd") {
+ return EmbeddedTargetOs::kOpenBSD;
} else {
return EmbeddedTargetOs::kGeneric;
}

View File

@ -0,0 +1,11 @@
Index: v8/src/snapshot/embedded/platform-embedded-file-writer-base.h
--- v8/src/snapshot/embedded/platform-embedded-file-writer-base.h.orig
+++ v8/src/snapshot/embedded/platform-embedded-file-writer-base.h
@@ -31,6 +31,7 @@ enum class EmbeddedTargetOs {
kMac,
kWin,
kStarboard,
+ kOpenBSD,
kGeneric, // Everything not covered above falls in here.
};

View File

@ -0,0 +1,41 @@
Index: v8/src/snapshot/embedded/platform-embedded-file-writer-generic.cc
--- v8/src/snapshot/embedded/platform-embedded-file-writer-generic.cc.orig
+++ v8/src/snapshot/embedded/platform-embedded-file-writer-generic.cc
@@ -9,6 +9,10 @@
#include "src/objects/code.h"
+#if V8_OS_OPENBSD
+#include <sys/param.h>
+#endif
+
namespace v8 {
namespace internal {
@@ -35,6 +39,8 @@ const char* DirectiveAsString(DataDirective directive)
void PlatformEmbeddedFileWriterGeneric::SectionText() {
if (target_os_ == EmbeddedTargetOs::kChromeOS) {
fprintf(fp_, ".section .text.hot.embedded\n");
+ } else if (target_os_ == EmbeddedTargetOs::kOpenBSD) {
+ fprintf(fp_, ".section .openbsd.mutable,\"a\"\n");
} else {
fprintf(fp_, ".section .text\n");
}
@@ -66,6 +72,8 @@ void PlatformEmbeddedFileWriterGeneric::AlignToCodeAli
// On these architectures and platforms, we remap the builtins, so need these
// to be aligned on a page boundary.
fprintf(fp_, ".balign 4096\n");
+#elif V8_OS_OPENBSD
+ fprintf(fp_, ".balign %d\n", PAGE_SIZE);
#elif V8_TARGET_ARCH_X64
// On x64 use 64-bytes code alignment to allow 64-bytes loop header alignment.
static_assert(64 >= kCodeAlignment);
@@ -86,6 +94,8 @@ void PlatformEmbeddedFileWriterGeneric::AlignToPageSiz
(V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_ARM64)
// Since the builtins are remapped, need to pad until the next page boundary.
fprintf(fp_, ".balign 4096\n");
+#elif V8_OS_OPENBSD
+ fprintf(fp_, ".balign %d\n", PAGE_SIZE);
#endif
}

View File

@ -1,7 +1,4 @@
USE_WXNEEDED = Yes
.if ${MACHINE_ARCH} != i386
USE_NOEXECONLY = Yes
.endif
ONLY_FOR_ARCHS = amd64 aarch64 i386
@ -18,7 +15,7 @@ VERSION = ${QT5_WEBENGINE_VERSION}
DIST_VERSION = ${QT5_WEBENGINE_VERSION}
DISTNAME = ${QT5NAME:L}-everywhere-src-${DIST_VERSION}
PKGNAME ?= ${DISTNAME:C/-everywhere-src//:C/-${DIST_VERSION}/-${VERSION}/}
REVISION = 9
REVISION = 10
MASTER_SITES ?= https://download.qt.io/official_releases/qt/${QT5_WEBENGINE_VERSION:R}/${QT5_WEBENGINE_VERSION}/submodules/ \
https://mirrors.ocf.berkeley.edu/qt/official_releases/qt/${QT5_WEBENGINE_VERSION:R}/${QT5_WEBENGINE_VERSION}/submodules/

View File

@ -0,0 +1,26 @@
Index: src/3rdparty/chromium/v8/src/execution/isolate.cc
--- src/3rdparty/chromium/v8/src/execution/isolate.cc.orig
+++ src/3rdparty/chromium/v8/src/execution/isolate.cc
@@ -93,6 +93,10 @@
#include "src/diagnostics/unwinding-info-win64.h"
#endif // V8_OS_WIN64
+#if defined(V8_OS_OPENBSD)
+#include <sys/mman.h>
+#endif
+
extern "C" const uint8_t* v8_Default_embedded_blob_;
extern "C" uint32_t v8_Default_embedded_blob_size_;
@@ -3220,6 +3224,11 @@ void Isolate::InitializeDefaultEmbeddedBlob() {
blob = TrustedEmbeddedBlob();
size = TrustedEmbeddedBlobSize();
}
+#endif
+
+#if defined(V8_OS_OPENBSD)
+ mprotect(reinterpret_cast<void *>(const_cast<uint8_t *>(blob)),
+ size, PROT_READ | PROT_EXEC);
#endif
if (StickyEmbeddedBlob() != nullptr) {

View File

@ -0,0 +1,11 @@
Index: src/3rdparty/chromium/v8/src/snapshot/embedded/embedded-file-writer.h
--- src/3rdparty/chromium/v8/src/snapshot/embedded/embedded-file-writer.h.orig
+++ src/3rdparty/chromium/v8/src/snapshot/embedded/embedded-file-writer.h
@@ -171,6 +171,7 @@ class EmbeddedFileWriter : public EmbeddedFileWriterIn
WriteBuiltin(w, blob, i);
}
+ w->AlignToPageSizeIfNeeded();
w->Newline();
}

View File

@ -0,0 +1,12 @@
Index: src/3rdparty/chromium/v8/src/snapshot/embedded/platform-embedded-file-writer-base.cc
--- src/3rdparty/chromium/v8/src/snapshot/embedded/platform-embedded-file-writer-base.cc.orig
+++ src/3rdparty/chromium/v8/src/snapshot/embedded/platform-embedded-file-writer-base.cc
@@ -123,6 +123,8 @@ EmbeddedTargetOs ToEmbeddedTargetOs(const char* s) {
return EmbeddedTargetOs::kMac;
} else if (string == "win") {
return EmbeddedTargetOs::kWin;
+ } else if (string == "openbsd") {
+ return EmbeddedTargetOs::kOpenBSD;
} else {
return EmbeddedTargetOs::kGeneric;
}

View File

@ -0,0 +1,19 @@
Index: src/3rdparty/chromium/v8/src/snapshot/embedded/platform-embedded-file-writer-base.h
--- src/3rdparty/chromium/v8/src/snapshot/embedded/platform-embedded-file-writer-base.h.orig
+++ src/3rdparty/chromium/v8/src/snapshot/embedded/platform-embedded-file-writer-base.h
@@ -30,6 +30,7 @@ enum class EmbeddedTargetOs {
kFuchsia,
kMac,
kWin,
+ kOpenBSD,
kGeneric, // Everything not covered above falls in here.
};
@@ -55,6 +56,7 @@ class PlatformEmbeddedFileWriterBase {
virtual void SectionRoData() = 0;
virtual void AlignToCodeAlignment() = 0;
+ virtual void AlignToPageSizeIfNeeded() {}
virtual void AlignToDataAlignment() = 0;
virtual void DeclareUint32(const char* name, uint32_t value) = 0;

View File

@ -0,0 +1,41 @@
Index: src/3rdparty/chromium/v8/src/snapshot/embedded/platform-embedded-file-writer-generic.cc
--- src/3rdparty/chromium/v8/src/snapshot/embedded/platform-embedded-file-writer-generic.cc.orig
+++ src/3rdparty/chromium/v8/src/snapshot/embedded/platform-embedded-file-writer-generic.cc
@@ -9,6 +9,10 @@
#include "src/common/globals.h"
+#if V8_OS_OPENBSD
+#include <sys/param.h>
+#endif
+
namespace v8 {
namespace internal {
@@ -35,6 +39,8 @@ const char* DirectiveAsString(DataDirective directive)
void PlatformEmbeddedFileWriterGeneric::SectionText() {
if (target_os_ == EmbeddedTargetOs::kChromeOS) {
fprintf(fp_, ".section .text.hot.embedded\n");
+ } else if (target_os_ == EmbeddedTargetOs::kOpenBSD) {
+ fprintf(fp_, ".section .openbsd.mutable,\"a\"\n");
} else {
fprintf(fp_, ".section .text\n");
}
@@ -70,7 +76,17 @@ void PlatformEmbeddedFileWriterGeneric::DeclareSymbolG
}
void PlatformEmbeddedFileWriterGeneric::AlignToCodeAlignment() {
+#if V8_OS_OPENBSD
+ fprintf(fp_, ".balign %d\n", PAGE_SIZE);
+#else
fprintf(fp_, ".balign 32\n");
+#endif
+}
+
+void PlatformEmbeddedFileWriterGeneric::AlignToPageSizeIfNeeded() {
+#if V8_OS_OPENBSD
+ fprintf(fp_, ".balign %d\n", PAGE_SIZE);
+#endif
}
void PlatformEmbeddedFileWriterGeneric::AlignToDataAlignment() {

View File

@ -0,0 +1,30 @@
Index: src/3rdparty/chromium/v8/src/snapshot/embedded/platform-embedded-file-writer-generic.cc
--- src/3rdparty/chromium/v8/src/snapshot/embedded/platform-embedded-file-writer-generic.cc.orig
+++ src/3rdparty/chromium/v8/src/snapshot/embedded/platform-embedded-file-writer-generic.cc
@@ -35,6 +35,8 @@ const char* DirectiveAsString(DataDirective directive)
void PlatformEmbeddedFileWriterGeneric::SectionText() {
if (target_os_ == EmbeddedTargetOs::kChromeOS) {
fprintf(fp_, ".section .text.hot.embedded\n");
+ } else if (target_os_ == EmbeddedTargetOs::kOpenBSD) {
+ fprintf(fp_, ".section .openbsd.mutable,\"a\"\n");
} else {
fprintf(fp_, ".section .text\n");
}
@@ -70,7 +72,17 @@ void PlatformEmbeddedFileWriterGeneric::DeclareSymbolG
}
void PlatformEmbeddedFileWriterGeneric::AlignToCodeAlignment() {
+#if V8_OS_OPENBSD
+ fprintf(fp_, ".balign 4096\n");
+#else
fprintf(fp_, ".balign 32\n");
+#endif
+}
+
+void PlatformEmbeddedFileWriterGeneric::AlignToPageSizeIfNeeded() {
+#if V8_OS_OPENBSD
+ fprintf(fp_, ".balign 4096\n");
+#endif
}
void PlatformEmbeddedFileWriterGeneric::AlignToDataAlignment() {

View File

@ -0,0 +1,11 @@
Index: src/3rdparty/chromium/v8/src/snapshot/embedded/platform-embedded-file-writer-generic.h
--- src/3rdparty/chromium/v8/src/snapshot/embedded/platform-embedded-file-writer-generic.h.orig
+++ src/3rdparty/chromium/v8/src/snapshot/embedded/platform-embedded-file-writer-generic.h
@@ -28,6 +28,7 @@ class PlatformEmbeddedFileWriterGeneric
void SectionRoData() override;
void AlignToCodeAlignment() override;
+ void AlignToPageSizeIfNeeded() override;
void AlignToDataAlignment() override;
void DeclareUint32(const char* name, uint32_t value) override;