The `capinit` directive does not allocate space for the relevant
relocation, rather it creates a CAPINIT relocation on the 16 bytes
immediately following it.
Our implementation works by ensuring we can grow the existing `frag` (an
internal structure that describes known contiguous bytes) by 8 bytes
and then recording that we have an 8 byte sized CAPINIT relocation.
It should be 16 bytes, since the relocation is on a 16 byte quantity.
One symptom this problem can cause is where the section that a given
CAPINIT relocation is recorded may not have enough space for the entire
capability the CAPINIT relocation requests.
The testcase we add demonstrated this problem before the current change.
Now it errors out. Unfortunately the error is an internal one with a
error message that references internal data structures, but I believe
that is better than creating a faulty binary without complaint.
return;
}
- frag_grow (8);
- fix_new_aarch64 (frag_now, frag_more (0) - frag_now->fr_literal, 8, &exp, 0,
+ frag_grow (16);
+ fix_new_aarch64 (frag_now, frag_more (0) - frag_now->fr_literal, 16, &exp, 0,
BFD_RELOC_MORELLO_CAPINIT);
demand_empty_rest_of_line ();
--- /dev/null
+#name: Capinit Requires 16 bytes
+#as: -march=armv8-a+c64
+#error_output: morello-capinit-require-size.l
--- /dev/null
+[^:]*: Assembler messages:
+[^:]*:7: Error: internal error: fixup not contained within frag
--- /dev/null
+.data
+.align 4
+a:
+ .8byte 0
+
+d:
+ .capinit a
+ .8byte 0
+ .size d, .-d
+
+// Need to switch section so that the capinit relocation does not have enough
+// space in the relevant chunk.
+.section .data.rel.ro
+.align 4
+e:
+ .8byte 0
+ .size e, .-e