x86/ELF: fix .tfloat output with hex input
authorJan Beulich <jbeulich@suse.com>
Wed, 11 Aug 2021 06:31:41 +0000 (08:31 +0200)
committerJan Beulich <jbeulich@suse.com>
Wed, 11 Aug 2021 06:31:41 +0000 (08:31 +0200)
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 hex_float() capable of
handling such padding.

Note that this brings the emitted data size of .dc.x / .dcb.x in line
also for non-ELF targets; so far they were different depending on input
format (dec vs hex).

Extend the existing x86 testcases.

gas/read.c
gas/testsuite/gas/i386/fp-elf32.d
gas/testsuite/gas/i386/fp-elf64.d
gas/testsuite/gas/i386/fp.d
gas/testsuite/gas/i386/fp.s

index 6bba696cebca1ba38f61ae627e7bd5d76034f585..b8e845dd569f64edc906419c5fc5c2f08a80ad85 100644 (file)
@@ -4847,7 +4847,7 @@ parse_repeat_cons (expressionS *exp, unsigned int nbytes)
 static int
 hex_float (int float_type, char *bytes)
 {
-  int length;
+  int length, pad = 0;
   int i;
 
   switch (float_type)
@@ -4868,12 +4868,22 @@ hex_float (int float_type, char *bytes)
 
     case 'x':
     case 'X':
-      length = 12;
+#ifdef X_PRECISION
+      length = X_PRECISION * sizeof (LITTLENUM_TYPE);
+      pad = X_PRECISION_PAD * sizeof (LITTLENUM_TYPE);
+      if (!length)
+#endif
+       length = 12;
       break;
 
     case 'p':
     case 'P':
-      length = 12;
+#ifdef P_PRECISION
+      length = P_PRECISION * sizeof (LITTLENUM_TYPE);
+      pad = P_PRECISION_PAD * sizeof (LITTLENUM_TYPE);
+      if (!length)
+#endif
+       length = 12;
       break;
 
     default:
@@ -4926,7 +4936,9 @@ hex_float (int float_type, char *bytes)
        memset (bytes, 0, length - i);
     }
 
-  return length;
+  memset (bytes + length, 0, pad);
+
+  return length + pad;
 }
 
 /*                     float_cons()
index 9e1254615ecab975a01c2d830ea663c24418e971..eefe84db310de6bb793236509aa31545500a916c 100644 (file)
@@ -11,3 +11,6 @@ Contents of section .data:
  0030 00000000 0000a044 01000000 0000a044  .*
  0040 00000000 0000f03f 00000000 00000000  .*
  0050 ffffffff ffffffff ffffffff cccccccc  .*
+ 0060 00000000 00000080 fe3f0000 00000000  .*
+ 0070 00000080 fdbf0000 00000000 00000080  .*
+ 0080 ff030000 aaaaaaaa aaaaaaaa aaaaaaaa  .*
index 0314929cf9c72aae7b32af5e18686c7b98f6a9a5..0756aa1e36a32811c191a4661a6b9e0a325ab1b0 100644 (file)
@@ -11,3 +11,6 @@ Contents of section .data:
  0030 00000000 0000a044 01000000 0000a044  .*
  0040 00000000 0000f03f 00000000 00000000  .*
  0050 ffffffff ffffffff ffffffff ffffffff  .*
+ 0060 00000000 00000080 fe3f0000 00000000  .*
+ 0070 00000000 00000080 fdbf0000 00000000  .*
+ 0080 00000000 00000080 ff030000 00000000  .*
index dd7e028b44bc35481078d4798aa6426fc862642d..b93595ac8c3e8b971a7e0a7a636e5601c5057783 100644 (file)
@@ -10,3 +10,5 @@ Contents of section .data:
  0030 00000000 0000a044 01000000 0000a044  .*
  0040 00000000 0000f03f 00000000 00000000  .*
  0050 ffffffff ffffffff ffffcccc cccccccc  .*
+ 0060 00000000 00000080 fe3f0000 00000000  .*
+ 0070 0080fdbf 00000000 00000080 ff03aaaa  .*
index 601709c219695d733cbecd2c2346fc3c71279820..7fe642e5180ddd8333487b0e2789e3ee8df29291 100644 (file)
@@ -24,3 +24,8 @@
 
        .ds.x 1, -1
        .p2align 4,0xcc
+
+       .tfloat 0x:3ffe80
+       .dc.x 0x:bffd80
+       .dcb.x 1, 0x:03ff80
+       .p2align 4,0xaa