diff options
author | Bernhard Schommer <bernhardschommer@gmail.com> | 2019-05-06 17:26:08 +0200 |
---|---|---|
committer | Xavier Leroy <xavierleroy@users.noreply.github.com> | 2019-05-10 14:27:22 +0200 |
commit | 47c86d46a329ee2c4c26a82b29edd40bb4b4c35c (patch) | |
tree | 54877aacf7effd308faab225320bfcfc9ecd3af3 /driver | |
parent | 46e5d165e6277d7502fe4a45e8765526a1117414 (diff) | |
download | compcert-47c86d46a329ee2c4c26a82b29edd40bb4b4c35c.tar.gz compcert-47c86d46a329ee2c4c26a82b29edd40bb4b4c35c.zip |
Check for alignment of command-line switches.
Add a check for alignment on command-line switches `-falign-*`.
The check is similar to the one for the alignment attribute and
ensures that only powers of two can be specified.
Diffstat (limited to 'driver')
-rw-r--r-- | driver/Driver.ml | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/driver/Driver.ml b/driver/Driver.ml index 8ab8557c..5f7d0b20 100644 --- a/driver/Driver.ml +++ b/driver/Driver.ml @@ -262,6 +262,10 @@ let num_input_files = ref 0 let cmdline_actions = let f_opt name ref = [Exact("-f" ^ name), Set ref; Exact("-fno-" ^ name), Unset ref] in + let check_align n = + if n <= 0 || ((n land (n - 1)) <> 0) then + error no_loc "requested alignment %d is not a power of 2" n + in [ (* Getting help *) Exact "-help", Unit print_usage_and_exit; @@ -297,9 +301,9 @@ let cmdline_actions = Exact "-fsmall-data", Integer(fun n -> option_small_data := n); Exact "-fsmall-const", Integer(fun n -> option_small_const := n); Exact "-ffloat-const-prop", Integer(fun n -> option_ffloatconstprop := n); - Exact "-falign-functions", Integer(fun n -> option_falignfunctions := Some n); - Exact "-falign-branch-targets", Integer(fun n -> option_falignbranchtargets := n); - Exact "-falign-cond-branches", Integer(fun n -> option_faligncondbranchs := n);] @ + Exact "-falign-functions", Integer(fun n -> check_align n; option_falignfunctions := Some n); + Exact "-falign-branch-targets", Integer(fun n -> check_align n; option_falignbranchtargets := n); + Exact "-falign-cond-branches", Integer(fun n -> check_align n; option_faligncondbranchs := n);] @ (* Target processor options *) (if Configuration.arch = "arm" then if Configuration.model = "armv6" then |