Skip to content

Commit

Permalink
i#5475 A64 features: Remove variable-length array (#5502)
Browse files Browse the repository at this point in the history
Changes the size of an array added in PR #5491 to be a compile-time C
constant.

Adds -Wvla to the UNIX compile flags to enforce this everywhere.
Fixes one other instances in drfrontendlib, and relaxes for a final
instance in a test.

Issue: #5475
  • Loading branch information
derekbruening authored May 25, 2022
1 parent b9bec98 commit f21168b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,7 @@ if (UNIX)
set(ld_entry_flag "--entry")
endif ()
# there's no cmake warning control so we hardcode it
set(WARN "-Wall -Werror -Wwrite-strings")
set(WARN "-Wall -Werror -Wwrite-strings -Wvla")
if (NOT CMAKE_COMPILER_IS_CLANG)
# Old gcc's ignore unknown -W flags, but -Wall -Werror causes clang to
# complain that it doesn't recognize it.
Expand Down
6 changes: 3 additions & 3 deletions core/arch/aarch64/proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ static int num_opmask_registers;

#ifndef DR_HOST_NOT_TARGET

const static int num_feature_registers = sizeof(features_t) / sizeof(uint64);
# define NUM_FEATURE_REGISTERS (sizeof(features_t) / sizeof(uint64))

# define MRS(REG, IDX, FEATS) \
do { \
if (IDX > (num_feature_registers - 1)) \
if (IDX > (NUM_FEATURE_REGISTERS - 1)) \
CLIENT_ASSERT(false, "Reading undefined AArch64 feature register!"); \
asm("mrs %0, " #REG : "=r"(FEATS[IDX])); \
} while (0);
Expand All @@ -61,7 +61,7 @@ read_feature_regs(uint64 isa_features[])
static void
get_processor_specific_info(void)
{
uint64 isa_features[num_feature_registers];
uint64 isa_features[NUM_FEATURE_REGISTERS];

/* FIXME i#5474: Catch and handle SIGILL if MRS not supported.
* Placeholder for some older kernels on v8.0 systems which do not support
Expand Down
2 changes: 1 addition & 1 deletion libutil/dr_frontend_unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ drfront_searchenv(const char *fname, const char *env_var, OUT char *full_path,
const char *cur;
const char *next;
const char *end;
char tmp[full_path_size];
char tmp[PATH_MAX];
char realpath_buf[PATH_MAX]; /* realpath hardcodes its buffer length */
drfront_status_t status_check = DRFRONT_ERROR;
bool access_ret = false;
Expand Down
4 changes: 4 additions & 0 deletions suite/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4948,6 +4948,10 @@ if (NOT ANDROID)
set (TestMemProtChg "${TestMemProtChg}_FLAKY")
endif (UNIX)
tobuild("${TestMemProtChg}" security-common/TestMemProtChg.c)
if (UNIX)
append_property_string(SOURCE security-common/TestMemProtChg.c
COMPILE_FLAGS "-Wno-vla")
endif ()
tochcon("${TestMemProtChg}" wine_exec_t)
mark_execstack("${TestMemProtChg}")
endif ()
Expand Down

0 comments on commit f21168b

Please sign in to comment.