1 From 4a4286465b5d6c28968bc2b29ae08daca7f219a3 Mon Sep 17 00:00:00 2001
2 From: Nick Clifton <nickc@redhat.com>
3 Date: Fri, 18 Nov 2016 11:42:48 -0800
4 Subject: [PATCH] Fix the generation of alignment frags in code sections for AArch64.
7 * config/tc-aarch64.c (s_ltorg): Change the mapping state after
9 (aarch64_init): Treat rs_align frags in code sections as
10 containing code, not data.
11 * testsuite/gas/aarch64/pr20364.s: New test.
12 * testsuite/gas/aarch64/pr20364.d: New test driver.
14 Backporting the patch from binutils mainline
15 https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=7ea12e5c3ad54da440c08f32da09534e63e515ca
17 Upstream-Status: Backport
19 Signed-off-by: Manjukumar Matha <manjukumar.harthikote-matha@xilinx.com>
21 gas/ChangeLog | 10 ++++++++++
22 gas/config/tc-aarch64.c | 10 +++++++---
23 gas/testsuite/gas/aarch64/pr20364.d | 13 +++++++++++++
24 gas/testsuite/gas/aarch64/pr20364.s | 28 ++++++++++++++++++++++++++++
25 4 files changed, 58 insertions(+), 3 deletions(-)
26 create mode 100644 gas/testsuite/gas/aarch64/pr20364.d
27 create mode 100644 gas/testsuite/gas/aarch64/pr20364.s
29 diff --git a/gas/ChangeLog b/gas/ChangeLog
30 index a39895a..fad06dc 100644
34 +2016-08-05 Nick Clifton <nickc@redhat.com>
37 + * config/tc-aarch64.c (s_ltorg): Change the mapping state after
39 + (aarch64_init): Treat rs_align frags in code sections as
40 + containing code, not data.
41 + * testsuite/gas/aarch64/pr20364.s: New test.
42 + * testsuite/gas/aarch64/pr20364.d: New test driver.
44 2016-08-03 Tristan Gingold <gingold@adacore.com>
46 * configure: Regenerate.
47 diff --git a/gas/config/tc-aarch64.c b/gas/config/tc-aarch64.c
48 index ddc40f2..74933cb 100644
49 --- a/gas/config/tc-aarch64.c
50 +++ b/gas/config/tc-aarch64.c
51 @@ -1736,13 +1736,13 @@ s_ltorg (int ignored ATTRIBUTE_UNUSED)
52 if (pool == NULL || pool->symbol == NULL || pool->next_free_entry == 0)
55 - mapping_state (MAP_DATA);
57 /* Align pool as you have word accesses.
58 Only make a frag if we have to. */
60 frag_align (align, 0, 0);
62 + mapping_state (MAP_DATA);
64 record_alignment (now_seg, align);
66 sprintf (sym_name, "$$lit_\002%x", pool->id);
67 @@ -6373,11 +6373,15 @@ aarch64_init_frag (fragS * fragP, int max_chars)
69 switch (fragP->fr_type)
74 mapping_state_2 (MAP_DATA, max_chars);
77 + /* PR 20364: We can get alignment frags in code sections,
78 + so do not just assume that we should use the MAP_DATA state. */
79 + mapping_state_2 (subseg_text_p (now_seg) ? MAP_INSN : MAP_DATA, max_chars);
82 mapping_state_2 (MAP_INSN, max_chars);
84 diff --git a/gas/testsuite/gas/aarch64/pr20364.d b/gas/testsuite/gas/aarch64/pr20364.d
86 index 0000000..babcff1
88 +++ b/gas/testsuite/gas/aarch64/pr20364.d
90 +# Check that ".align <size>, <fill>" does not set the mapping state to DATA, causing unnecessary frag generation.
96 +Disassembly of section \.vectors:
99 + 0: d2800000 mov x0, #0x0 // #0
100 + 4: 94000000 bl 0 <plat_report_exception>
101 + 8: 17fffffe b 0 <bl1_exceptions>
103 diff --git a/gas/testsuite/gas/aarch64/pr20364.s b/gas/testsuite/gas/aarch64/pr20364.s
105 index 0000000..594ad7c
107 +++ b/gas/testsuite/gas/aarch64/pr20364.s
109 + .macro vector_base label
110 + .section .vectors, "ax"
115 + .macro vector_entry label
116 + .section .vectors, "ax"
121 + .macro check_vector_size since
122 + .if (. - \since) > (32 * 4)
123 + .error "Vector exceeds 32 instructions"
127 + .globl bl1_exceptions
129 +vector_base bl1_exceptions
131 +vector_entry SynchronousExceptionSP0
133 + bl plat_report_exception
134 + b SynchronousExceptionSP0
135 + check_vector_size SynchronousExceptionSP0