Skip to content

Commit c1f0e68

Browse files
lhamesLang Hames
authored andcommitted
[JITLink][i386] Get rid of EdgeKind_i386::None.
R_386_NONE ELF edges should be handled by skipping the relocation, rather than adding no-op edges to the LinkGraph.
1 parent 32f514c commit c1f0e68

File tree

3 files changed

+8
-15
lines changed

3 files changed

+8
-15
lines changed

llvm/include/llvm/ExecutionEngine/JITLink/i386.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ namespace llvm::jitlink::i386 {
2020
/// Represets i386 fixups
2121
enum EdgeKind_i386 : Edge::Kind {
2222

23-
/// None
24-
None = Edge::FirstRelocation,
25-
2623
/// A plain 32-bit pointer value relocation.
2724
///
2825
/// Fixup expression:
@@ -32,7 +29,7 @@ enum EdgeKind_i386 : Edge::Kind {
3229
/// - The target must reside in the low 32-bits of the address space,
3330
/// otherwise an out-of-range error will be returned.
3431
///
35-
Pointer32,
32+
Pointer32 = Edge::FirstRelocation,
3633

3734
/// A 32-bit PC-relative relocation.
3835
///
@@ -192,10 +189,6 @@ inline Error applyFixup(LinkGraph &G, Block &B, const Edge &E,
192189
auto FixupAddress = B.getAddress() + E.getOffset();
193190

194191
switch (E.getKind()) {
195-
case i386::None: {
196-
break;
197-
}
198-
199192
case i386::Pointer32: {
200193
uint32_t Value = E.getTarget().getAddress().getValue() + E.getAddend();
201194
*(ulittle32_t *)FixupPtr = Value;

llvm/lib/ExecutionEngine/JITLink/ELF_i386.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,6 @@ class ELFLinkGraphBuilder_i386 : public ELFLinkGraphBuilder<object::ELF32LE> {
117117
Expected<i386::EdgeKind_i386> getRelocationKind(const uint32_t Type) {
118118
using namespace i386;
119119
switch (Type) {
120-
case ELF::R_386_NONE:
121-
return EdgeKind_i386::None;
122120
case ELF::R_386_32:
123121
return EdgeKind_i386::Pointer32;
124122
case ELF::R_386_PC32:
@@ -170,6 +168,12 @@ class ELFLinkGraphBuilder_i386 : public ELFLinkGraphBuilder<object::ELF32LE> {
170168
Block &BlockToFix) {
171169
using Base = ELFLinkGraphBuilder<ELFT>;
172170

171+
auto ELFReloc = Rel.getType(false);
172+
173+
// R_386_NONE is a no-op.
174+
if (LLVM_UNLIKELY(ELFReloc == ELF::R_386_NONE))
175+
return Error::success();
176+
173177
uint32_t SymbolIndex = Rel.getSymbol(false);
174178
auto ObjSymbol = Base::Obj.getRelocationSymbol(Rel, Base::SymTabSec);
175179
if (!ObjSymbol)
@@ -184,16 +188,14 @@ class ELFLinkGraphBuilder_i386 : public ELFLinkGraphBuilder<object::ELF32LE> {
184188
Base::GraphSymbols.size()),
185189
inconvertibleErrorCode());
186190

187-
Expected<i386::EdgeKind_i386> Kind = getRelocationKind(Rel.getType(false));
191+
Expected<i386::EdgeKind_i386> Kind = getRelocationKind(ELFReloc);
188192
if (!Kind)
189193
return Kind.takeError();
190194

191195
auto FixupAddress = orc::ExecutorAddr(FixupSection.sh_addr) + Rel.r_offset;
192196
int64_t Addend = 0;
193197

194198
switch (*Kind) {
195-
case i386::EdgeKind_i386::None:
196-
break;
197199
case i386::EdgeKind_i386::Pointer32:
198200
case i386::EdgeKind_i386::PCRel32:
199201
case i386::EdgeKind_i386::RequestGOTAndTransformToDelta32FromGOT:

llvm/lib/ExecutionEngine/JITLink/i386.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ namespace llvm::jitlink::i386 {
1818

1919
const char *getEdgeKindName(Edge::Kind K) {
2020
switch (K) {
21-
case None:
22-
return "None";
2321
case Pointer32:
2422
return "Pointer32";
2523
case PCRel32:

0 commit comments

Comments
 (0)