From 42b1063146566519fef7a8589e3fd82b7240ae0f Mon Sep 17 00:00:00 2001 From: marxin Date: Tue, 20 Feb 2018 10:04:13 +0000 Subject: Add limit for maximal alignment options (PR c/84310). 2018-02-20 Martin Liska PR c/84310 PR target/79747 * final.c (shorten_branches): Build align_tab array with one more element. * opts.c (finish_options): Add alignment option limit check. (MAX_CODE_ALIGN): Likewise. (MAX_CODE_ALIGN_VALUE): Likewise. * doc/invoke.texi: Document maximum allowed option value for all -falign-* options. 2018-02-20 Martin Liska PR c/84310 PR target/79747 * gcc.target/i386/pr84310.c: New test. * gcc.target/i386/pr84310-2.c: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@257842 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/opts.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'gcc/opts.c') diff --git a/gcc/opts.c b/gcc/opts.c index f2795f98bf4..33efcc0d6e7 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -1039,6 +1039,26 @@ finish_options (struct gcc_options *opts, struct gcc_options *opts_set, if ((opts->x_flag_sanitize & SANITIZE_KERNEL_ADDRESS) && opts->x_flag_tm) sorry ("transactional memory is not supported with " "%<-fsanitize=kernel-address%>"); + + /* Comes from final.c -- no real reason to change it. */ +#define MAX_CODE_ALIGN 16 +#define MAX_CODE_ALIGN_VALUE (1 << MAX_CODE_ALIGN) + + if (opts->x_align_loops > MAX_CODE_ALIGN_VALUE) + error_at (loc, "-falign-loops=%d is not between 0 and %d", + opts->x_align_loops, MAX_CODE_ALIGN_VALUE); + + if (opts->x_align_jumps > MAX_CODE_ALIGN_VALUE) + error_at (loc, "-falign-jumps=%d is not between 0 and %d", + opts->x_align_jumps, MAX_CODE_ALIGN_VALUE); + + if (opts->x_align_functions > MAX_CODE_ALIGN_VALUE) + error_at (loc, "-falign-functions=%d is not between 0 and %d", + opts->x_align_functions, MAX_CODE_ALIGN_VALUE); + + if (opts->x_align_labels > MAX_CODE_ALIGN_VALUE) + error_at (loc, "-falign-labels=%d is not between 0 and %d", + opts->x_align_labels, MAX_CODE_ALIGN_VALUE); } #define LEFT_COLUMN 27 -- cgit v1.2.1