diff options
author | Jan Beulich <jbeulich@suse.com> | 2021-08-11 08:30:26 +0200 |
---|---|---|
committer | Jan Beulich <jbeulich@suse.com> | 2021-08-11 08:30:26 +0200 |
commit | e2295dade838ad296e1e1cd1096177058139b6b3 (patch) | |
tree | e3a3e336bd33766ed7aea049b5b5f8ab887985e0 /gas | |
parent | e7e57d02fb51dcb1e976f1a089de3113d9aac2ba (diff) | |
download | gdb-e2295dade838ad296e1e1cd1096177058139b6b3.zip gdb-e2295dade838ad296e1e1cd1096177058139b6b3.tar.gz gdb-e2295dade838ad296e1e1cd1096177058139b6b3.tar.bz2 |
x86/ELF: fix .tfloat output
The ELF psABI-s are quite clear here: On 32-bit the data type is 12
bytes long (with 2 bytes of trailing padding), while on 64-bit it is 16
bytes long (with 6 bytes of padding). Make ieee_md_atof() capable of
handling such padding, and specify the needed padding for x86 (leaving
non-ELF targets alone for now). Split the existing x86 testcase.
Diffstat (limited to 'gas')
-rw-r--r-- | gas/config/atof-ieee.c | 15 | ||||
-rw-r--r-- | gas/config/tc-i386.c | 13 | ||||
-rw-r--r-- | gas/config/tc-i386.h | 3 | ||||
-rw-r--r-- | gas/testsuite/gas/i386/fp-elf32.d | 12 | ||||
-rw-r--r-- | gas/testsuite/gas/i386/fp-elf64.d | 12 | ||||
-rw-r--r-- | gas/testsuite/gas/i386/fp.s | 6 | ||||
-rw-r--r-- | gas/testsuite/gas/i386/i386.exp | 5 |
7 files changed, 60 insertions, 6 deletions
diff --git a/gas/config/atof-ieee.c b/gas/config/atof-ieee.c index fa988aa..e6e8879 100644 --- a/gas/config/atof-ieee.c +++ b/gas/config/atof-ieee.c @@ -30,7 +30,13 @@ extern FLONUM_TYPE generic_floating_point_number; #define F_PRECISION 2 #define D_PRECISION 4 #define X_PRECISION 5 +#ifndef X_PRECISION_PAD +#define X_PRECISION_PAD 0 +#endif #define P_PRECISION 5 +#ifndef P_PRECISION_PAD +#define P_PRECISION_PAD X_PRECISION_PAD +#endif /* Length in LittleNums of guard bits. */ #define GUARD 2 @@ -760,7 +766,7 @@ ieee_md_atof (int type, LITTLENUM_TYPE words[MAX_LITTLENUMS]; LITTLENUM_TYPE *wordP; char *t; - int prec = 0; + int prec = 0, pad = 0; if (strchr (FLT_CHARS, type) != NULL) { @@ -788,6 +794,7 @@ ieee_md_atof (int type, case 't': case 'T': prec = X_PRECISION; + pad = X_PRECISION_PAD; type = 'x'; /* This is what atof_ieee() understands. */ break; @@ -803,6 +810,7 @@ ieee_md_atof (int type, #else prec = P_PRECISION; #endif + pad = P_PRECISION_PAD; break; default: @@ -835,7 +843,7 @@ ieee_md_atof (int type, if (t) input_line_pointer = t; - *sizeP = prec * sizeof (LITTLENUM_TYPE); + *sizeP = (prec + pad) * sizeof (LITTLENUM_TYPE); if (big_wordian) { @@ -854,5 +862,8 @@ ieee_md_atof (int type, } } + memset (litP, 0, pad * sizeof (LITTLENUM_TYPE)); + litP += pad * sizeof (LITTLENUM_TYPE); + return NULL; } diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c index cdc660f..0fa8b0d 100644 --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -10229,6 +10229,19 @@ x86_cons_fix_new (fragS *frag, unsigned int off, unsigned int len, fix_new_exp (frag, off, len, exp, 0, r); } +/* Return the number of padding LITTLENUMs following a tbyte floating + point value. */ + +int +x86_tfloat_pad (void) +{ +#if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) + if (IS_ELF) + return object_64bit ? 3 : 1; +#endif + return 0; +} + /* Export the ABI address size for use by TC_ADDRESS_BYTES for the purpose of the `.dc.a' internal pseudo-op. */ diff --git a/gas/config/tc-i386.h b/gas/config/tc-i386.h index 90d23da..f94226e 100644 --- a/gas/config/tc-i386.h +++ b/gas/config/tc-i386.h @@ -134,6 +134,9 @@ extern bfd_reloc_code_real_type x86_cons (expressionS *, int); extern void x86_cons_fix_new (fragS *, unsigned int, unsigned int, expressionS *, bfd_reloc_code_real_type); +#define X_PRECISION_PAD x86_tfloat_pad () +extern int x86_tfloat_pad (void); + #define TC_ADDRESS_BYTES x86_address_bytes extern int x86_address_bytes (void); diff --git a/gas/testsuite/gas/i386/fp-elf32.d b/gas/testsuite/gas/i386/fp-elf32.d new file mode 100644 index 0000000..6ef9c83a --- /dev/null +++ b/gas/testsuite/gas/i386/fp-elf32.d @@ -0,0 +1,12 @@ +#objdump: -s -j .data +#name: i386 fp (ELF) +#source: fp.s + +.*: file format .* + +Contents of section .data: + 0000 00881bcd 4b789ad4 00400000 71a37909 .* + 0010 4f930a40 789a5440 789a5440 00000000 .* + 0020 e65e1710 20395e3b e65e1710 20395e3b .* + 0030 00000000 0000a044 01000000 0000a044 .* + 0040 00000000 0000f03f .* diff --git a/gas/testsuite/gas/i386/fp-elf64.d b/gas/testsuite/gas/i386/fp-elf64.d new file mode 100644 index 0000000..2e68ac8 --- /dev/null +++ b/gas/testsuite/gas/i386/fp-elf64.d @@ -0,0 +1,12 @@ +#objdump: -s -j .data +#name: x86-64 fp (ELF) +#source: fp.s + +.*: file format .* + +Contents of section .data: + 0000 00881bcd 4b789ad4 00400000 00000000 .* + 0010 71a37909 4f930a40 789a5440 789a5440 .* + 0020 e65e1710 20395e3b e65e1710 20395e3b .* + 0030 00000000 0000a044 01000000 0000a044 .* + 0040 00000000 0000f03f .* diff --git a/gas/testsuite/gas/i386/fp.s b/gas/testsuite/gas/i386/fp.s index 11a50cf..fca56f2 100644 --- a/gas/testsuite/gas/i386/fp.s +++ b/gas/testsuite/gas/i386/fp.s @@ -7,10 +7,10 @@ # .byte 0x71, 0xa3, 0x79, 0x09, 0x4f, 0x93, 0x0a, 0x40 # The next two are 32-bit floating point format. .float 3.32192809488736218171e0 -# .byte 0x78, 0x9a, 0x54, 0x40, 0, 0, 0, 0 +# .byte 0x78, 0x9a, 0x54, 0x40 .single 3.32192809488736218171e0 -# .byte 0x78, 0x9a, 0x54, 0x40, 0, 0, 0, 0 - .byte 0, 0, 0, 0, 0, 0 +# .byte 0x78, 0x9a, 0x54, 0x40 + .p2align 4,0 # The assembler used to treat the next value as zero instead of 1e-22. .double .0000000000000000000001 diff --git a/gas/testsuite/gas/i386/i386.exp b/gas/testsuite/gas/i386/i386.exp index 3464bc2..122da6a 100644 --- a/gas/testsuite/gas/i386/i386.exp +++ b/gas/testsuite/gas/i386/i386.exp @@ -118,7 +118,6 @@ if [gas_32_check] then { run_list_test "lockbad-1" "-al" run_dump_test "long-1" run_dump_test "long-1-intel" - run_dump_test "fp" run_dump_test "nops" run_dump_test "nops16-1" run_dump_test "nops-1" @@ -624,6 +623,7 @@ if [gas_32_check] then { run_dump_test "intel-movs16" run_dump_test "intel-cmps32" run_dump_test "intel-cmps16" + run_dump_test "fp-elf32" run_list_test "inval-equ-1" "-al" run_list_test "inval-equ-2" "-al" run_dump_test "ifunc" @@ -697,6 +697,8 @@ if [gas_32_check] then { run_dump_test "iamcu-5" run_list_test "iamcu-inval-1" "-march=iamcu -al" } + } else { + run_dump_test "fp" } # This is a PE specific test. @@ -1274,6 +1276,7 @@ if [gas_64_check] then { run_list_test "reloc64" "--defsym _bad_=1" run_dump_test "mixed-mode-reloc64" run_dump_test "rela" + run_dump_test "fp-elf64" run_dump_test "x86-64-ifunc" run_dump_test "x86-64-opcode-inval" run_dump_test "x86-64-opcode-inval-intel" |