]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gas: Remove requirement of getting a target symbol
authorMatthew Malcomson <matthew.malcomson@arm.com>
Tue, 10 Aug 2021 11:05:43 +0000 (12:05 +0100)
committerMatthew Malcomson <matthew.malcomson@arm.com>
Tue, 10 Aug 2021 11:05:43 +0000 (12:05 +0100)
Before this change we had a check that any capinit directive had a plain
symbol (possibly plus an addend) as an argument.
Unfortunately, the check itself is actually that GAS can identify that
the expression we have is in that category *before* applying all
adjustments after alignment etc.  Internally this not only required that
the expression was of a simple enough form, but also that if we had an
expression of the form `f+((.Ltmp+1)-f)` (which is a form that compilers
use for label addresses) this required that the `f` and `.Ltmp` labels
were in the same `frag`.

In order to be in the same `frag` there could be no alignment between
them, whether from alignment directives between the two labels, or
because we had a data directive in between them and the assembler
ensured we were aligned when re-entering code state.

This artificial requirement triggered an assembler error when running
the GCC testsuite, hence we have removed it.  This matches LLVM
behaviour.  More obvious errors like subtracting symbols from different
sections are still caught in the general expression handling code.

gas/config/tc-aarch64.c
gas/testsuite/gas/aarch64/morello-capinit.d
gas/testsuite/gas/aarch64/morello-capinit.s
gas/testsuite/gas/aarch64/morello-chericap.d
gas/testsuite/gas/aarch64/morello-chericap.s

index 765996c624f9b646317f33c7cc07d51ab359e6b4..f550d9e042f4962e0d7c23eae40978610141e77b 100644 (file)
@@ -2164,13 +2164,7 @@ static void
 s_aarch64_capinit (int ignored ATTRIBUTE_UNUSED)
 {
   expressionS exp;
-
   expression (&exp);
-  if (exp.X_op != O_symbol)
-    {
-      as_bad (_(".capinit expects a target symbol as an argument"));
-      return;
-    }
 
   /* align to 16 bytes. */
   do_align (4, (char *) NULL, 0, 0);
@@ -2186,13 +2180,7 @@ static void
 s_aarch64_chericap (int ignored ATTRIBUTE_UNUSED)
 {
   expressionS exp;
-
   expression (&exp);
-  if (exp.X_op != O_symbol)
-    {
-      as_bad (_(".chericap expects a target symbol as an argument"));
-      return;
-    }
 
 #ifdef md_flush_pending_output
   md_flush_pending_output ();
index 788449ba7daec9e4131fe6cb0cdca0eff3c94687..6567a2964beafcd8fae1297579deaf7690384139 100644 (file)
@@ -6,6 +6,10 @@
 RELOCATION RECORDS FOR \[\.text\]:
 OFFSET           TYPE              VALUE
 0000000000000000 R_AARCH64_LDST128_ABS_LO12_NC  \.data\+0x0000000000000010
+0000000000000008 R_AARCH64_LDST128_ABS_LO12_NC  \.data\+0x0000000000000010
+0000000000000010 R_MORELLO_CAPINIT  f\+0x0000000000000008
+0000000000000020 R_AARCH64_LDST128_ABS_LO12_NC  \.data\+0x0000000000000010
+0000000000000030 R_MORELLO_CAPINIT  f2\+0x000000000000000c
 
 
 RELOCATION RECORDS FOR \[\.data\]:
@@ -21,8 +25,11 @@ OFFSET           TYPE              VALUE
 0000000000000000 R_MORELLO_CAPINIT  str2
 
 
-Contents of section \.text:
- 0000 420040c2 c053c2c2                    .*
+Contents of section .text:
+ 0000 420040c2 c053c2c2 420040c2 1f2003d5  .*
+ 0010 00000000 00000000 00000000 00000000  .*
+ 0020 420040c2 00000000 00000000 1f2003d5  .*
+ 0030 00000000 00000000 00000000 00000000  .*
 Contents of section \.data:
  0000 48656c6c 6f20576f 726c6400 00000000  .*
  0010 00000000 00000000 00000000 00000000  .*
index 62b79b1b6a5e82f52384823da6069e062f606954..c3d44b9cbf31e115c5c6c0c8e8e781d81efb58f8 100644 (file)
@@ -49,3 +49,20 @@ e:
 _start:
        ldr     c2, [c2, :lo12:a]
        ret
+
+       .type f, %function
+f:
+       ldr     c2, [c2, :lo12:a]
+        .p2align 4
+.Llab:
+       .capinit f+((.Llab+1)-f)
+       .xword  0
+       .xword  0
+       .type f2, %function
+f2:
+       ldr     c2, [c2, :lo12:a]
+        .8byte 0
+.Llab2:
+       .capinit f2+((.Llab2+1)-f2)
+       .xword  0
+       .xword  0
index 2d855f283a37cd507954da6fdb2b6b7b74294a25..f8e1fe99f2edd3c7998a0367d1a4d2931297599e 100644 (file)
@@ -17,6 +17,8 @@ SYMBOL TABLE:
 0000000000000060 l       \.data        0000000000000010 d
 0000000000000000 l    d  \.data\.rel\.ro       0000000000000000 \.data\.rel\.ro
 0000000000000000 l       \.data\.rel\.ro       0000000000000010 e
+000000000000001c l     F \.text        0000000000000000 g
+0000000000000030 l     F \.text        0000000000000000 g2
 0000000000000000 g     F \.text        0000000000000013 f
 0000000000000020 g       \.data        000000000000000c str
 0000000000000000         \*UND\*       0000000000000000 foo
@@ -26,6 +28,10 @@ SYMBOL TABLE:
 RELOCATION RECORDS FOR \[\.text\]:
 OFFSET           TYPE              VALUE 
 0000000000000014 R_AARCH64_LDST128_ABS_LO12_NC  \.data\+0x0000000000000030
+000000000000001c R_AARCH64_LDST128_ABS_LO12_NC  \.data\+0x0000000000000030
+0000000000000020 R_MORELLO_CAPINIT  g\+0x0000000000000004
+0000000000000030 R_AARCH64_LDST128_ABS_LO12_NC  \.data\+0x0000000000000030
+0000000000000040 R_MORELLO_CAPINIT  g2\+0x000000000000000c
 
 
 RELOCATION RECORDS FOR \[\.data\]:
@@ -45,7 +51,10 @@ OFFSET           TYPE              VALUE
 
 Contents of section \.text:
  0000 fd7bbf62 fdd3c1c2 01000014 fd7bc122  .*
- 0010 c053c2c2 420040c2 c053c2c2           .*
+ 0010 c053c2c2 420040c2 c053c2c2 420040c2  .*
+ 0020 00000000 00000000 00000000 00000000  .*
+ 0030 420040c2 00000000 00000000 1f2003d5  .*
+ 0040 00000000 00000000 00000000 00000000  .*
 Contents of section \.data:
  0000 00000000 00000000 00000000 00000000  .*
  0010 00000000 00000000 00000000 00000000  .*
index 1d44a4ffbb952f13d9abaf4288278d3d06786083..c733bb723e58bf88450a949ff04a9910d7522a1c 100644 (file)
@@ -77,3 +77,16 @@ e:
 _start:
        ldr     c2, [c2, :lo12:a]
        ret
+
+       .type g, %function
+g:
+       ldr     c2, [c2, :lo12:a]
+        .p2align 4
+.Llab:
+       .chericap g+((.Llab+1)-g)
+       .type g2, %function
+g2:
+       ldr     c2, [c2, :lo12:a]
+        .8byte 0
+.Llab2:
+       .chericap g2+((.Llab2+1)-g2)