Skip to content

Commit 7d2d795

Browse files
committed
move AArch64 related code to AArch64.h
1 parent 31214b8 commit 7d2d795

File tree

3 files changed

+50
-33
lines changed

3 files changed

+50
-33
lines changed

lld/ELF/Arch/AArch64.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9+
#include "AArch64.h"
910
#include "InputFiles.h"
1011
#include "OutputSections.h"
1112
#include "Symbols.h"
@@ -1259,3 +1260,29 @@ void elf::setAArch64TargetInfo(Ctx &ctx) {
12591260
else
12601261
ctx.target.reset(new AArch64(ctx));
12611262
}
1263+
1264+
AArch64BuildAttrSubsections
1265+
extractBuildAttributesSubsections(const llvm::AArch64AttributeParser &attributes) {
1266+
1267+
AArch64BuildAttrSubsections subSections;
1268+
auto getPauthValue = [&](unsigned tag) -> unsigned {
1269+
return attributes.getAttributeValue("aeabi_pauthabi", tag).value_or(0);
1270+
};
1271+
subSections.pauth.tagPlatform =
1272+
getPauthValue(llvm::AArch64BuildAttributes::TAG_PAUTH_PLATFORM);
1273+
subSections.pauth.tagSchema =
1274+
getPauthValue(llvm::AArch64BuildAttributes::TAG_PAUTH_SCHEMA);
1275+
1276+
auto getFeatureValue = [&](unsigned tag) -> unsigned {
1277+
return attributes.getAttributeValue("aeabi_feature_and_bits", tag)
1278+
.value_or(0);
1279+
};
1280+
subSections.andFeatures |=
1281+
getFeatureValue(llvm::AArch64BuildAttributes::TAG_FEATURE_BTI);
1282+
subSections.andFeatures |=
1283+
getFeatureValue(llvm::AArch64BuildAttributes::TAG_FEATURE_PAC) << 1;
1284+
subSections.andFeatures |=
1285+
getFeatureValue(llvm::AArch64BuildAttributes::TAG_FEATURE_GCS) << 2;
1286+
1287+
return subSections;
1288+
}

lld/ELF/Arch/AArch64.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//===- AARch64.h ---------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===---------------------------------------------------------------------===//
8+
9+
#include <cstdint>
10+
#include "llvm/Support/AArch64AttributeParser.h"
11+
#include "llvm/Support/AArch64BuildAttributes.h"
12+
13+
struct AArch64BuildAttrSubsections {
14+
struct PauthSubSection {
15+
uint64_t tagPlatform = 0;
16+
uint64_t tagSchema = 0;
17+
} pauth;
18+
uint32_t andFeatures = 0;
19+
};
20+
21+
AArch64BuildAttrSubsections
22+
extractBuildAttributesSubsections(const llvm::AArch64AttributeParser&);

lld/ELF/InputFiles.cpp

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9+
#include "Arch/AArch64.h"
910
#include "InputFiles.h"
1011
#include "Config.h"
1112
#include "DWARF.h"
@@ -209,39 +210,6 @@ static void updateSupportedARMFeatures(Ctx &ctx,
209210
ctx.arg.armHasThumb2ISA |= thumb && *thumb >= ARMBuildAttrs::AllowThumb32;
210211
}
211212

212-
struct AArch64BuildAttrSubsections {
213-
struct PauthSubSection {
214-
uint64_t tagPlatform = 0;
215-
uint64_t tagSchema = 0;
216-
} pauth;
217-
uint32_t andFeatures = 0;
218-
};
219-
220-
static AArch64BuildAttrSubsections
221-
extractBuildAttributesSubsections(const AArch64AttributeParser &attributes) {
222-
223-
AArch64BuildAttrSubsections subSections;
224-
auto getPauthValue = [&](unsigned tag) -> unsigned {
225-
return attributes.getAttributeValue("aeabi_pauthabi", tag).value_or(0);
226-
};
227-
subSections.pauth.tagPlatform =
228-
getPauthValue(llvm::AArch64BuildAttributes::TAG_PAUTH_PLATFORM);
229-
subSections.pauth.tagSchema =
230-
getPauthValue(llvm::AArch64BuildAttributes::TAG_PAUTH_SCHEMA);
231-
232-
auto getFeatureValue = [&](unsigned tag) -> unsigned {
233-
return attributes.getAttributeValue("aeabi_feature_and_bits", tag)
234-
.value_or(0);
235-
};
236-
subSections.andFeatures |=
237-
getFeatureValue(llvm::AArch64BuildAttributes::TAG_FEATURE_BTI);
238-
subSections.andFeatures |=
239-
getFeatureValue(llvm::AArch64BuildAttributes::TAG_FEATURE_PAC) << 1;
240-
subSections.andFeatures |=
241-
getFeatureValue(llvm::AArch64BuildAttributes::TAG_FEATURE_GCS) << 2;
242-
243-
return subSections;
244-
}
245213

246214
InputFile::InputFile(Ctx &ctx, Kind k, MemoryBufferRef m)
247215
: ctx(ctx), mb(m), groupId(ctx.driver.nextGroupId), fileKind(k) {

0 commit comments

Comments
 (0)