diff --git a/gas/config/tc-aarch64.c b/gas/config/tc-aarch64.c index 89abdc62e4e97049856d6d22966b90ae147a52bf..3d0436d538c856a418f6949fb47998f69558b6fc 100644 --- a/gas/config/tc-aarch64.c +++ b/gas/config/tc-aarch64.c @@ -2170,6 +2170,9 @@ s_aarch64_capinit (int ignored ATTRIBUTE_UNUSED) return; } + /* align to 16 bytes. */ + do_align (4, (char *) NULL, 0, 0); + frag_grow (16); fix_new_aarch64 (frag_now, frag_more (0) - frag_now->fr_literal, 16, &exp, 0, BFD_RELOC_MORELLO_CAPINIT); @@ -2193,6 +2196,9 @@ s_aarch64_chericap (int ignored ATTRIBUTE_UNUSED) md_flush_pending_output (); #endif + /* align to 16 bytes. */ + do_align (4, (char *) NULL, 0, 0); + frag_grow (16); fix_new_aarch64 (frag_now, frag_more (0) - frag_now->fr_literal, 16, &exp, 0, BFD_RELOC_MORELLO_CAPINIT); diff --git a/gas/testsuite/gas/aarch64/morello-capinit-align.d b/gas/testsuite/gas/aarch64/morello-capinit-align.d new file mode 100644 index 0000000000000000000000000000000000000000..0193bd9071d841e269a5e44168937176d13c61d2 --- /dev/null +++ b/gas/testsuite/gas/aarch64/morello-capinit-align.d @@ -0,0 +1,10 @@ +#name: capinit and chericap automatically align +#as: -march=armv8-a+c64 +#readelf: --relocs + +Relocation section '\.rela\.data' at offset 0x138 contains 4 entries: + Offset Info Type Sym\. Value Sym\. Name \+ Addend +000000000010 00040000e800 R_MORELLO_CAPINIT 0000000000000000 f \+ 0 +000000000030 00040000e800 R_MORELLO_CAPINIT 0000000000000000 f \+ 0 +000000000040 00040000e800 R_MORELLO_CAPINIT 0000000000000000 f \+ 0 +000000000050 00040000e800 R_MORELLO_CAPINIT 0000000000000000 f \+ 0 diff --git a/gas/testsuite/gas/aarch64/morello-capinit-align.s b/gas/testsuite/gas/aarch64/morello-capinit-align.s new file mode 100644 index 0000000000000000000000000000000000000000..fce807b79103c9a2b16a8734a61582eb846b19ec --- /dev/null +++ b/gas/testsuite/gas/aarch64/morello-capinit-align.s @@ -0,0 +1,16 @@ +.data +f: +// A few capability initialisation directives with a single byte to show the +// padding gets introduced when needed. +.byte 0 +.capinit f +.xword 0 +.xword 0 +.byte 0 +.chericap f +// A few directives without any bytes in between to show no extra padding gets +// added when not needed. +.chericap f +.capinit f +.xword 0 +.xword 0