Skip to content

Commit 18fbf0a

Browse files
committed
[AArch64][ELF] Section alignment of 4 for AArch64 instruction
The integrated assembler sets a minimum alignment for the .text section of 4. However user defined sections get an alignment of 1. Unlike the GNU assembler which raises the section alignment to 4 if an AArch64 instruction is used, the integrated assembler leaves the alignment at 1
1 parent 471a043 commit 18fbf0a

File tree

2 files changed

+12
-29
lines changed

2 files changed

+12
-29
lines changed

llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,9 +327,8 @@ class AArch64ELFStreamer : public MCELFStreamer {
327327
MCELFStreamer::changeSection(Section, Subsection);
328328

329329
// Section alignment of 4 to match GNU Assembler
330-
if ((Section->getAlign() < 4) && Section->isText()) {
330+
if ((Section->getAlign() < 4) && Section->isText())
331331
Section->setAlignment(Align(4));
332-
}
333332
}
334333

335334
// Reset state between object emissions
Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// RUN: llvm-mc -triple=aarch64-none-linux-gnu -filetype=obj -o %t.obj %s
2-
// RUN: llvm-readobj -S --sd %t.obj | FileCheck %s --check-prefix=CHECK-OBJ
3-
// RUN: llvm-readelf -s %t.obj | FileCheck %s --check-prefix=CHECK-ELF
2+
// RUN: llvm-readobj -S --sd %t.obj | FileCheck %s
43

54
.section sec00, "ax"
65
.byte 1
@@ -17,28 +16,13 @@ nop
1716
nop
1817
nop
1918

20-
// CHECK-OBJ: Name: sec00
21-
// CHECK-OBJ-NEXT: Type: SHT_PROGBITS (0x1)
22-
// CHECK-OBJ-NEXT: Flags [ (0x6)
23-
// CHECK-OBJ: AddressAlignment: 4
24-
// CHECK-OBJ: Name: sec01
25-
// CHECK-OBJ-NEXT: Type: SHT_PROGBITS (0x1)
26-
// CHECK-OBJ-NEXT: Flags [ (0x6)
27-
// CHECK-OBJ: AddressAlignment: 4
28-
// CHECK-OBJ: Name: sec02
29-
// CHECK-OBJ-NEXT: Type: SHT_PROGBITS (0x1)
30-
// CHECK-OBJ-NEXT: Flags [ (0x6)
31-
// CHECK-OBJ: Name: sec03
32-
// CHECK-OBJ-NEXT: Type: SHT_PROGBITS (0x1)
33-
// CHECK-OBJ-NEXT: Flags [ (0x6)
34-
// CHECK-OBJ: AddressAlignment: 4
35-
// CHECK-OBJ: Name: sec04
36-
// CHECK-OBJ-NEXT: Type: SHT_PROGBITS (0x1)
37-
// CHECK-OBJ-NEXT: Flags [ (0x3)
38-
// CHECK-OBJ: AddressAlignment: 1
39-
40-
//CHECK-ELF: sec00 PROGBITS 0000000000000000 000040 000001 00 AX 0 0 4
41-
//CHECK-ELF-NEXT: sec01 PROGBITS 0000000000000000 000044 000008 00 AX 0 0 4
42-
//CHECK-ELF-NEXT: sec02 PROGBITS 0000000000000000 00004c 000008 00 AX 0 0 4
43-
//CHECK-ELF-NEXT: sec03 PROGBITS 0000000000000000 000054 000001 00 AX 0 0 4
44-
//CHECK-ELF-NEXT: sec04 PROGBITS 0000000000000000 000055 000008 00 WA 0 0 1
19+
// CHECK: Name: sec00
20+
// CHECK: AddressAlignment: 4
21+
// CHECK: Name: sec01
22+
// CHECK: AddressAlignment: 4
23+
// CHECK: Name: sec02
24+
// CHECK: AddressAlignment: 4
25+
// CHECK: Name: sec03
26+
// CHECK: AddressAlignment: 4
27+
// CHECK: Name: sec04
28+
// CHECK: AddressAlignment: 1

0 commit comments

Comments
 (0)