Skip to content

Commit 36de2d9

Browse files
committed
[MC] Set SHF_EXCLUDE for AArch64 (and other) build attributes sections
The sections are not supposed to end up in linked executables. Follow-up to llvm#123990
1 parent 439de72 commit 36de2d9

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

llvm/lib/MC/MCELFStreamer.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,8 @@ void MCELFStreamer::createAttributesWithSubsection(
800800
if (AttributeSection) {
801801
switchSection(AttributeSection);
802802
} else {
803-
AttributeSection = getContext().getELFSection(Section, Type, 0);
803+
AttributeSection =
804+
getContext().getELFSection(Section, Type, ELF::SHF_EXCLUDE);
804805
switchSection(AttributeSection);
805806

806807
// Format version

llvm/test/CodeGen/AArch64/aarch64-build-attributes-all.ll

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
; RUN: llc %s -o - | FileCheck %s --check-prefix=ASM
2-
; RUN: llc %s -filetype=obj -o - | llvm-readelf --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF
2+
; RUN: llc %s -filetype=obj -o - | llvm-readelf --section-details --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF
33

44
; ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128
55
; ASM-NEXT: .aeabi_attribute Tag_Feature_BTI, 1
66
; ASM-NEXT: .aeabi_attribute Tag_Feature_PAC, 1
77
; ASM-NEXT: .aeabi_attribute Tag_Feature_GCS, 1
88

9+
; ELF: Section Headers:
10+
; ELF: .ARM.attributes
11+
; ELF-NEXT: 0000000000000000
12+
; ELF-NEXT: EXCLUDE
13+
914
; ELF: Hex dump of section '.ARM.attributes':
1015
; ELF-NEXT: 0x00000000 41230000 00616561 62695f66 65617475 A#...aeabi_featu
1116
; ELF-NEXT: 0x00000010 72655f61 6e645f62 69747300 01000001 re_and_bits.....

0 commit comments

Comments
 (0)