Skip to content

Commit 8514d20

Browse files
author
esmeyi
committed
[AIX] Handle ReadOnlyWithRel kind on AIX.
Summary: This patch handles the SectionKind of ReadOnlyWithRel on AIX. The failure was discovered during sanitizer enablement and occured with `-fsanitize-coverage` option. Reviewed By: hubert.reinterpretcast Differential Revision: https://reviews.llvm.org/D157483
1 parent 9d9c25f commit 8514d20

File tree

2 files changed

+116
-2
lines changed

2 files changed

+116
-2
lines changed

llvm/lib/MC/MCSectionXCOFF.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,16 @@ void MCSectionXCOFF::printSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
4242
return;
4343
}
4444

45+
if (getKind().isReadOnlyWithRel()) {
46+
if (getMappingClass() != XCOFF::XMC_RW &&
47+
getMappingClass() != XCOFF::XMC_RO &&
48+
getMappingClass() != XCOFF::XMC_TD)
49+
report_fatal_error(
50+
"Unexepected storage-mapping class for ReadOnlyWithRel kind");
51+
printCsectDirective(OS);
52+
return;
53+
}
54+
4555
// Initialized TLS data.
4656
if (getKind().isThreadData()) {
4757
// We only expect XMC_TL here for initialized TLS data.
@@ -72,8 +82,7 @@ void MCSectionXCOFF::printSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
7282
}
7383

7484
if (isCsect() && getMappingClass() == XCOFF::XMC_TD) {
75-
assert((getKind().isBSSExtern() || getKind().isBSSLocal() ||
76-
getKind().isReadOnlyWithRel()) &&
85+
assert((getKind().isBSSExtern() || getKind().isBSSLocal()) &&
7786
"Unexepected section kind for toc-data");
7887
printCsectDirective(OS);
7988
return;
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
; RUN: llc -mtriple powerpc-ibm-aix-xcoff < %s | FileCheck %s --check-prefix CHECK
2+
; RUN: llc -mtriple powerpc64-ibm-aix-xcoff < %s | FileCheck %s --check-prefix CHECK
3+
; RUN: llc -mtriple powerpc-ibm-aix-xcoff -mxcoff-roptr < %s | FileCheck %s --check-prefix CHECK-RO
4+
; RUN: llc -mtriple powerpc64-ibm-aix-xcoff -mxcoff-roptr < %s | FileCheck %s --check-prefix CHECK-RO
5+
6+
; RUN: llc -filetype=obj -mtriple powerpc-ibm-aix-xcoff -verify-machineinstrs < %s -o %t32.o
7+
; RUN: llvm-readobj %t32.o --syms --relocs | FileCheck %s --check-prefix=OBJ32
8+
9+
; RUN: llc -filetype=obj -mtriple powerpc64-ibm-aix-xcoff -verify-machineinstrs < %s -o %t64.o
10+
; RUN: llvm-readobj %t64.o --syms --relocs | FileCheck %s --check-prefix=OBJ64
11+
12+
@var = external constant i32
13+
@ptr = private constant ptr @var, section "relro-section"
14+
15+
; CHECK: .extern var[UA]
16+
; CHECK: .csect _Renamed..2drelro_section[RW]
17+
18+
; CHECK-RO: .extern var[UA]
19+
; CHECK-RO: .csect _Renamed..2drelro_section[RO]
20+
21+
; OBJ32: Relocations [
22+
; OBJ32-NEXT: Section (index: 2) .data {
23+
; OBJ32-NEXT: 0x0 R_POS var(1) 0x1F
24+
; OBJ32-NEXT: }
25+
; OBJ32-NEXT: ]
26+
; OBJ32-NEXT: Symbols [
27+
; OBJ32: Index: 1
28+
; OBJ32-NEXT: Name: var
29+
; OBJ32-NEXT: Value (RelocatableAddress): 0x0
30+
; OBJ32-NEXT: Section: N_UNDEF
31+
; OBJ32-NEXT: Type: 0x0
32+
; OBJ32-NEXT: StorageClass: C_EXT (0x2)
33+
; OBJ32-NEXT: NumberOfAuxEntries: 1
34+
; OBJ32-NEXT: CSECT Auxiliary Entry {
35+
; OBJ32-NEXT: Index: 2
36+
; OBJ32-NEXT: SectionLen: 0
37+
; OBJ32-NEXT: ParameterHashIndex: 0x0
38+
; OBJ32-NEXT: TypeChkSectNum: 0x0
39+
; OBJ32-NEXT: SymbolAlignmentLog2: 0
40+
; OBJ32-NEXT: SymbolType: XTY_ER (0x0)
41+
; OBJ32-NEXT: StorageMappingClass: XMC_UA (0x4)
42+
; OBJ32-NEXT: StabInfoIndex: 0x0
43+
; OBJ32-NEXT: StabSectNum: 0x0
44+
; OBJ32-NEXT: }
45+
; OBJ32: Index: 5
46+
; OBJ32-NEXT: Name: relro-section
47+
; OBJ32-NEXT: Value (RelocatableAddress): 0x0
48+
; OBJ32-NEXT: Section: .data
49+
; OBJ32-NEXT: Type: 0x0
50+
; OBJ32-NEXT: StorageClass: C_HIDEXT (0x6B)
51+
; OBJ32-NEXT: NumberOfAuxEntries: 1
52+
; OBJ32-NEXT: CSECT Auxiliary Entry {
53+
; OBJ32-NEXT: Index: 6
54+
; OBJ32-NEXT: SectionLen: 4
55+
; OBJ32-NEXT: ParameterHashIndex: 0x0
56+
; OBJ32-NEXT: TypeChkSectNum: 0x0
57+
; OBJ32-NEXT: SymbolAlignmentLog2: 2
58+
; OBJ32-NEXT: SymbolType: XTY_SD (0x1)
59+
; OBJ32-NEXT: StorageMappingClass: XMC_RW (0x5)
60+
; OBJ32-NEXT: StabInfoIndex: 0x0
61+
; OBJ32-NEXT: StabSectNum: 0x0
62+
; OBJ32-NEXT: }
63+
; OBJ32: ]
64+
65+
; OBJ64: Relocations [
66+
; OBJ64-NEXT: Section (index: 2) .data {
67+
; OBJ64-NEXT: 0x0 R_POS var(1) 0x3F
68+
; OBJ64-NEXT: }
69+
; OBJ64-NEXT: ]
70+
; OBJ64-NEXT: Symbols [
71+
; OBJ64: Index: 1
72+
; OBJ64-NEXT: Name: var
73+
; OBJ64-NEXT: Value (RelocatableAddress): 0x0
74+
; OBJ64-NEXT: Section: N_UNDEF
75+
; OBJ64-NEXT: Type: 0x0
76+
; OBJ64-NEXT: StorageClass: C_EXT (0x2)
77+
; OBJ64-NEXT: NumberOfAuxEntries: 1
78+
; OBJ64-NEXT: CSECT Auxiliary Entry {
79+
; OBJ64-NEXT: Index: 2
80+
; OBJ64-NEXT: SectionLen: 0
81+
; OBJ64-NEXT: ParameterHashIndex: 0x0
82+
; OBJ64-NEXT: TypeChkSectNum: 0x0
83+
; OBJ64-NEXT: SymbolAlignmentLog2: 0
84+
; OBJ64-NEXT: SymbolType: XTY_ER (0x0)
85+
; OBJ64-NEXT: StorageMappingClass: XMC_UA (0x4)
86+
; OBJ64-NEXT: Auxiliary Type: AUX_CSECT (0xFB)
87+
; OBJ64-NEXT: }
88+
; OBJ64: Index: 5
89+
; OBJ64-NEXT: Name: relro-section
90+
; OBJ64-NEXT: Value (RelocatableAddress): 0x0
91+
; OBJ64-NEXT: Section: .data
92+
; OBJ64-NEXT: Type: 0x0
93+
; OBJ64-NEXT: StorageClass: C_HIDEXT (0x6B)
94+
; OBJ64-NEXT: NumberOfAuxEntries: 1
95+
; OBJ64-NEXT: CSECT Auxiliary Entry {
96+
; OBJ64-NEXT: Index: 6
97+
; OBJ64-NEXT: SectionLen: 8
98+
; OBJ64-NEXT: ParameterHashIndex: 0x0
99+
; OBJ64-NEXT: TypeChkSectNum: 0x0
100+
; OBJ64-NEXT: SymbolAlignmentLog2: 3
101+
; OBJ64-NEXT: SymbolType: XTY_SD (0x1)
102+
; OBJ64-NEXT: StorageMappingClass: XMC_RW (0x5)
103+
; OBJ64-NEXT: Auxiliary Type: AUX_CSECT (0xFB)
104+
; OBJ64-NEXT: }
105+
; OBJ64: ]

0 commit comments

Comments
 (0)