From a578ef7ed49b677ecb16a709f70c7349bdefb319 Mon Sep 17 00:00:00 2001 From: Jiong Wang Date: Tue, 10 Mar 2015 11:20:57 +0000 Subject: [PATCH] [AArch64] Set the minimum alignment on code segments gas/ 2015-03-10 Matthew Wahab * config/tc-aarch64.c (mapping_state): Set minimum alignment for code sections. gas/testsuite 2015-03-10 Matthew Wahab * gas/aarch64/codealign.d: Add test for code section alignment. * gas/aarch64/codealign.s: New file. --- gas/ChangeLog | 5 +++++ gas/config/tc-aarch64.c | 9 ++++++++- gas/testsuite/ChangeLog | 5 +++++ gas/testsuite/gas/aarch64/codealign.d | 16 ++++++++++++++++ gas/testsuite/gas/aarch64/codealign.s | 2 ++ 5 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 gas/testsuite/gas/aarch64/codealign.d create mode 100644 gas/testsuite/gas/aarch64/codealign.s diff --git a/gas/ChangeLog b/gas/ChangeLog index 6738d51c2ba..e52702cdf84 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,8 @@ +2015-03-10 Matthew Wahab + + * config/tc-aarch64.c (mapping_state): Set minimum alignment for + code sections. + 2015-03-10 Nick Clifton PR gas/17852 diff --git a/gas/config/tc-aarch64.c b/gas/config/tc-aarch64.c index 9179fc617f4..77701c6d1df 100644 --- a/gas/config/tc-aarch64.c +++ b/gas/config/tc-aarch64.c @@ -1478,7 +1478,14 @@ mapping_state (enum mstate state) /* The mapping symbol has already been emitted. There is nothing else to do. */ return; - else if (TRANSITION (MAP_UNDEFINED, MAP_DATA)) + + if (state == MAP_INSN) + /* AArch64 instructions require 4-byte alignment. When emitting + instructions into any section, record the appropriate section + alignment. */ + record_alignment (now_seg, 2); + + if (TRANSITION (MAP_UNDEFINED, MAP_DATA)) /* This case will be evaluated later in the next else. */ return; else if (TRANSITION (MAP_UNDEFINED, MAP_INSN)) diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog index fb6e5920ed9..004c6423f2a 100644 --- a/gas/testsuite/ChangeLog +++ b/gas/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-03-10 Matthew Wahab + + * gas/aarch64/codealign.d: Add test for code section alignment. + * gas/aarch64/codealign.s: New file. + 2015-03-04 Richard Sandiford PR gas/17843 diff --git a/gas/testsuite/gas/aarch64/codealign.d b/gas/testsuite/gas/aarch64/codealign.d new file mode 100644 index 00000000000..a032b83297f --- /dev/null +++ b/gas/testsuite/gas/aarch64/codealign.d @@ -0,0 +1,16 @@ +#objdump: --section-headers +# Minimum code alignment should be set. +# This test is only valid on ELF based ports. +#not-target: *-*-*coff *-*-pe *-*-wince *-*-*aout* *-*-netbsd *-*-riscix* + +.*: +file format.*aarch64.* + +Sections: +Idx Name Size VMA LMA File off Algn + 0 \.text .* .* .* .* 2\*\*2 + .*CODE.* + 1 \.data .* .* .* .* 2\*\*0 + .*DATA.* + 2 \.bss .* .* .* .* 2\*\*0 +.* + diff --git a/gas/testsuite/gas/aarch64/codealign.s b/gas/testsuite/gas/aarch64/codealign.s new file mode 100644 index 00000000000..b80a6d9e2a0 --- /dev/null +++ b/gas/testsuite/gas/aarch64/codealign.s @@ -0,0 +1,2 @@ +.text + nop -- 2.30.2