File tree Expand file tree Collapse file tree 4 files changed +20
-5
lines changed
include/llvm/ExecutionEngine/JITLink
lib/ExecutionEngine/JITLink
test/ExecutionEngine/JITLink/AArch32
unittests/ExecutionEngine/JITLink Expand file tree Collapse file tree 4 files changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -135,6 +135,8 @@ enum class StubsFlavor {
135
135
struct ArmConfig {
136
136
bool J1J2BranchEncoding = false ;
137
137
StubsFlavor Stubs = StubsFlavor::Unsupported;
138
+ // In the long term, we might want a linker switch like --target1-rel
139
+ bool Target1Rel = false ;
138
140
};
139
141
140
142
// / Obtain the sub-arch configuration for a given Arm CPU model.
Original file line number Diff line number Diff line change @@ -31,7 +31,8 @@ namespace llvm {
31
31
namespace jitlink {
32
32
33
33
// / Translate from ELF relocation type to JITLink-internal edge kind.
34
- Expected<aarch32::EdgeKind_aarch32> getJITLinkEdgeKind (uint32_t ELFType) {
34
+ Expected<aarch32::EdgeKind_aarch32>
35
+ getJITLinkEdgeKind (uint32_t ELFType, const aarch32::ArmConfig &ArmCfg) {
35
36
switch (ELFType) {
36
37
case ELF::R_ARM_ABS32:
37
38
return aarch32::Data_Pointer32;
@@ -47,6 +48,9 @@ Expected<aarch32::EdgeKind_aarch32> getJITLinkEdgeKind(uint32_t ELFType) {
47
48
return aarch32::Arm_MovwAbsNC;
48
49
case ELF::R_ARM_MOVT_ABS:
49
50
return aarch32::Arm_MovtAbs;
51
+ case ELF::R_ARM_TARGET1:
52
+ return (ArmCfg.Target1Rel ) ? aarch32::Data_Delta32
53
+ : aarch32::Data_Pointer32;
50
54
case ELF::R_ARM_THM_CALL:
51
55
return aarch32::Thumb_Call;
52
56
case ELF::R_ARM_THM_JUMP24:
@@ -171,7 +175,7 @@ class ELFLinkGraphBuilder_aarch32
171
175
inconvertibleErrorCode ());
172
176
173
177
uint32_t Type = Rel.getType (false );
174
- Expected<aarch32::EdgeKind_aarch32> Kind = getJITLinkEdgeKind (Type);
178
+ Expected<aarch32::EdgeKind_aarch32> Kind = getJITLinkEdgeKind (Type, ArmCfg );
175
179
if (!Kind)
176
180
return Kind.takeError ();
177
181
Original file line number Diff line number Diff line change @@ -29,6 +29,13 @@ rel32:
29
29
.word target - .
30
30
.size rel32, .-rel32
31
31
32
+ # CHECK-TYPE: {{[0-9a-f]+}} R_ARM_TARGET1 target
33
+ # jitlink-check: *{4}(target1_abs32) = target
34
+ .global target1_abs32
35
+ target1_abs32:
36
+ .word target(target1)
37
+ .size target1_abs32, .-target1_abs32
38
+
32
39
# CHECK-TYPE: {{[0-9a-f]+}} R_ARM_GOT_PREL target
33
40
#
34
41
# The GOT entry contains the absolute address of the external:
Original file line number Diff line number Diff line change @@ -39,15 +39,17 @@ struct MutableWord {
39
39
namespace llvm {
40
40
namespace jitlink {
41
41
42
- Expected<aarch32::EdgeKind_aarch32> getJITLinkEdgeKind (uint32_t ELFType);
42
+ Expected<aarch32::EdgeKind_aarch32>
43
+ getJITLinkEdgeKind (uint32_t ELFType, const aarch32::ArmConfig &Cfg);
43
44
Expected<uint32_t > getELFRelocationType (Edge::Kind Kind);
44
45
45
46
} // namespace jitlink
46
47
} // namespace llvm
47
48
48
49
TEST (AArch32_ELF, EdgeKinds) {
49
50
// Fails: Invalid ELF type -> JITLink kind
50
- Expected<uint32_t > ErrKind = getJITLinkEdgeKind (ELF::R_ARM_NONE);
51
+ aarch32::ArmConfig Cfg;
52
+ Expected<uint32_t > ErrKind = getJITLinkEdgeKind (ELF::R_ARM_NONE, Cfg);
51
53
EXPECT_TRUE (errorToBool (ErrKind.takeError ()));
52
54
53
55
// Fails: Invalid JITLink kind -> ELF type
@@ -59,7 +61,7 @@ TEST(AArch32_ELF, EdgeKinds) {
59
61
EXPECT_FALSE (errorToBool (ELFType.takeError ()))
60
62
<< " Failed to translate JITLink kind -> ELF type" ;
61
63
62
- Expected<Edge::Kind> JITLinkKind = getJITLinkEdgeKind (*ELFType);
64
+ Expected<Edge::Kind> JITLinkKind = getJITLinkEdgeKind (*ELFType, Cfg );
63
65
EXPECT_FALSE (errorToBool (JITLinkKind.takeError ()))
64
66
<< " Failed to translate ELF type -> JITLink kind" ;
65
67
You can’t perform that action at this time.
0 commit comments