Skip to content

[MC] Set SHF_EXCLUDE for AArch64 (and other) build attributes sections #125824

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion llvm/lib/MC/MCELFStreamer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,8 @@ void MCELFStreamer::createAttributesWithSubsection(
if (AttributeSection) {
switchSection(AttributeSection);
} else {
AttributeSection = getContext().getELFSection(Section, Type, 0);
AttributeSection =
getContext().getELFSection(Section, Type, ELF::SHF_EXCLUDE);
switchSection(AttributeSection);

// Format version
Expand Down
7 changes: 6 additions & 1 deletion llvm/test/CodeGen/AArch64/aarch64-build-attributes-all.ll
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
; RUN: llc %s -o - | FileCheck %s --check-prefix=ASM
; RUN: llc %s -filetype=obj -o - | llvm-readelf --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF
; RUN: llc %s -filetype=obj -o - | llvm-readelf --section-details --hex-dump=.ARM.attributes - | FileCheck %s --check-prefix=ELF

; ASM: .aeabi_subsection aeabi_feature_and_bits, optional, uleb128
; ASM-NEXT: .aeabi_attribute Tag_Feature_BTI, 1
; ASM-NEXT: .aeabi_attribute Tag_Feature_PAC, 1
; ASM-NEXT: .aeabi_attribute Tag_Feature_GCS, 1

; ELF: Section Headers:
; ELF: .ARM.attributes
; ELF-NEXT: 0000000000000000
; ELF-NEXT: EXCLUDE

; ELF: Hex dump of section '.ARM.attributes':
; ELF-NEXT: 0x00000000 41230000 00616561 62695f66 65617475 A#...aeabi_featu
; ELF-NEXT: 0x00000010 72655f61 6e645f62 69747300 01000001 re_and_bits.....
Expand Down