diff options
author | Jan Beulich <jbeulich@suse.com> | 2023-09-15 09:56:02 +0200 |
---|---|---|
committer | Jan Beulich <jbeulich@suse.com> | 2023-09-15 09:56:02 +0200 |
commit | 1d07cfb4406ee1dd336dd63cd5af7e8534892be7 (patch) | |
tree | 6e89d08039e463d353c9b94403b8d87e5631ab52 | |
parent | b44fef84a9696d3e571f79aea3e0adea0b4ae02d (diff) | |
download | binutils-1d07cfb4406ee1dd336dd63cd5af7e8534892be7.zip binutils-1d07cfb4406ee1dd336dd63cd5af7e8534892be7.tar.gz binutils-1d07cfb4406ee1dd336dd63cd5af7e8534892be7.tar.bz2 |
x86: make code size vs CPU arch checking consistent
While update_code_flag() checks for LM / i386, set_cpu_arch() so far
didn't, allowing e.g. 64-bit code to be emitted after ".arch generic32".
Oddly enough a few of our testcases actually exhibit bad behavior (and
hence need minor adjustments).
-rw-r--r-- | gas/config/tc-i386.c | 18 | ||||
-rw-r--r-- | gas/testsuite/gas/i386/287.s | 2 | ||||
-rw-r--r-- | gas/testsuite/gas/i386/8087.s | 2 | ||||
-rw-r--r-- | gas/testsuite/gas/i386/att-regs.s | 2 | ||||
-rw-r--r-- | gas/testsuite/gas/i386/intel-regs.s | 2 | ||||
-rw-r--r-- | gas/testsuite/gas/i386/inval-16.l | 2 | ||||
-rw-r--r-- | gas/testsuite/gas/i386/inval-16.s | 2 | ||||
-rw-r--r-- | gas/testsuite/gas/i386/nops-5.s | 1 |
8 files changed, 25 insertions, 6 deletions
diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c index 1208e30..72e5729 100644 --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -2928,6 +2928,24 @@ set_cpu_arch (int dummy ATTRIBUTE_UNUSED) { check_cpu_arch_compatible (string, cpu_arch[j].enable); + if (flag_code == CODE_64BIT && !cpu_arch[j].enable.bitfield.cpulm ) + { + as_bad (_("64bit mode not supported on `%s'."), + cpu_arch[j].name); + (void) restore_line_pointer (e); + ignore_rest_of_line (); + return; + } + + if (flag_code == CODE_32BIT && !cpu_arch[j].enable.bitfield.cpui386) + { + as_bad (_("32bit mode not supported on `%s'."), + cpu_arch[j].name); + (void) restore_line_pointer (e); + ignore_rest_of_line (); + return; + } + cpu_arch_name = cpu_arch[j].name; free (cpu_sub_arch_name); cpu_sub_arch_name = NULL; diff --git a/gas/testsuite/gas/i386/287.s b/gas/testsuite/gas/i386/287.s index 74ad160..b0deeb8 100644 --- a/gas/testsuite/gas/i386/287.s +++ b/gas/testsuite/gas/i386/287.s @@ -1,9 +1,9 @@ # Check 287-only instructions. .text + .code16 .arch i286 .arch .287 - .code16 _8087: fnsetpm frstpm diff --git a/gas/testsuite/gas/i386/8087.s b/gas/testsuite/gas/i386/8087.s index 9149eb2..5f1e2f3 100644 --- a/gas/testsuite/gas/i386/8087.s +++ b/gas/testsuite/gas/i386/8087.s @@ -1,9 +1,9 @@ # Check 8087-only instructions. .text + .code16 .arch i8086 .arch .8087 - .code16 _8087: fdisi feni diff --git a/gas/testsuite/gas/i386/att-regs.s b/gas/testsuite/gas/i386/att-regs.s index 1001824..18509d1 100644 --- a/gas/testsuite/gas/i386/att-regs.s +++ b/gas/testsuite/gas/i386/att-regs.s @@ -1,8 +1,8 @@ .text .att_syntax noprefix - .arch i286 .code16 + .arch i286 mov eax, ax ; add al, (bx,si) mov rax, ax ; add al, (bx,si) mov axl, ax ; add al, (bx,si) diff --git a/gas/testsuite/gas/i386/intel-regs.s b/gas/testsuite/gas/i386/intel-regs.s index 44e369b..1f88881 100644 --- a/gas/testsuite/gas/i386/intel-regs.s +++ b/gas/testsuite/gas/i386/intel-regs.s @@ -3,8 +3,8 @@ mov eax, tmm1 - .arch i286 .code16 + .arch i286 mov ax, eax ; add [bx+si], al mov ax, rax ; add [bx+si], al mov ax, axl ; add [bx+si], al diff --git a/gas/testsuite/gas/i386/inval-16.l b/gas/testsuite/gas/i386/inval-16.l index bf5d4cd..13443bd 100644 --- a/gas/testsuite/gas/i386/inval-16.l +++ b/gas/testsuite/gas/i386/inval-16.l @@ -10,7 +10,7 @@ GAS LISTING .* [ ]*1[ ]+\.text -[ ]*2[ ]+\.arch i186; \.code16 +[ ]*2[ ]+\.code16; \.arch i186 [ ]*3[ ]+vmovapd %xmm0,%xmm1 [ ]*4[ ]+vaddsd %xmm4, %xmm5, %xmm6\{%k7\} [ ]*5[ ]+vfrczpd %xmm7,%xmm7 diff --git a/gas/testsuite/gas/i386/inval-16.s b/gas/testsuite/gas/i386/inval-16.s index d3966da..611115b 100644 --- a/gas/testsuite/gas/i386/inval-16.s +++ b/gas/testsuite/gas/i386/inval-16.s @@ -1,5 +1,5 @@ .text - .arch i186; .code16 + .code16; .arch i186 vmovapd %xmm0,%xmm1 vaddsd %xmm4, %xmm5, %xmm6{%k7} vfrczpd %xmm7,%xmm7 diff --git a/gas/testsuite/gas/i386/nops-5.s b/gas/testsuite/gas/i386/nops-5.s index 4536c98..a932a10 100644 --- a/gas/testsuite/gas/i386/nops-5.s +++ b/gas/testsuite/gas/i386/nops-5.s @@ -1,4 +1,5 @@ .text + .code32 .arch i386 i386: movsbl %al,%esi |