35 * to {@code .got} and {@code .got} to {@code .plt}. |
35 * to {@code .got} and {@code .got} to {@code .plt}. |
36 */ |
36 */ |
37 final class JavaCallSiteRelocationSymbol extends CallSiteRelocationSymbol { |
37 final class JavaCallSiteRelocationSymbol extends CallSiteRelocationSymbol { |
38 |
38 |
39 private static final byte[] zeroSlot = new byte[8]; |
39 private static final byte[] zeroSlot = new byte[8]; |
|
40 // -1 represents Universe::non_oop_word() value |
40 private static final byte[] minusOneSlot = {-1, -1, -1, -1, -1, -1, -1, -1}; |
41 private static final byte[] minusOneSlot = {-1, -1, -1, -1, -1, -1, -1, -1}; |
41 |
42 |
42 public JavaCallSiteRelocationSymbol(CompiledMethodInfo mi, Call call, CallSiteRelocationInfo callSiteRelocation, BinaryContainer binaryContainer) { |
43 public JavaCallSiteRelocationSymbol(CompiledMethodInfo mi, Call call, CallSiteRelocationInfo callSiteRelocation, BinaryContainer binaryContainer) { |
43 super(createPltEntrySymbol(binaryContainer, mi, call, callSiteRelocation)); |
44 super(createPltEntrySymbol(binaryContainer, mi, call, callSiteRelocation)); |
44 StubInformation stub = getStub(mi, call); |
45 StubInformation stub = getStub(mi, call); |
77 // For c2i stub we need slot with -1 value. |
78 // For c2i stub we need slot with -1 value. |
78 binaryContainer.appendExtLinkageGotBytes(minusOneSlot, 0, minusOneSlot.length); |
79 binaryContainer.appendExtLinkageGotBytes(minusOneSlot, 0, minusOneSlot.length); |
79 } |
80 } |
80 |
81 |
81 // Add relocation to GOT cell for call resolution jump. |
82 // Add relocation to GOT cell for call resolution jump. |
|
83 // This GOT cell will be initialized during JVM startup with address |
|
84 // of JVM runtime call resolution function. |
82 String gotSymbolName = "got." + getResolveSymbolName(binaryContainer, mi, call); |
85 String gotSymbolName = "got." + getResolveSymbolName(binaryContainer, mi, call); |
83 Symbol gotSymbol = binaryContainer.getGotSymbol(gotSymbolName); |
86 Symbol gotSymbol = binaryContainer.getGotSymbol(gotSymbolName); |
84 addExternalPltToGotRelocation(binaryContainer, gotSymbol, stub.getResolveJumpOffset()); |
87 addExternalPltToGotRelocation(binaryContainer, gotSymbol, stub.getResolveJumpOffset()); |
85 |
88 |
86 // Add relocation to resolve call jump instruction address for GOT cell. |
89 // Add relocation to resolve call jump instruction address for GOT cell. |
|
90 // This GOT cell will be initialized with address of resolution jump instruction and |
|
91 // will be updated with call destination address by JVM runtime call resolution code. |
87 String pltJmpSymbolName = relocationSymbolName("plt.jmp", mi, call, callSiteRelocation); |
92 String pltJmpSymbolName = relocationSymbolName("plt.jmp", mi, call, callSiteRelocation); |
88 addCodeContainerRelocation(binaryContainer, pltJmpSymbolName, stub.getResolveJumpStart(), gotStartOffset); |
93 addCodeContainerRelocation(binaryContainer, pltJmpSymbolName, stub.getResolveJumpStart(), gotStartOffset); |
89 |
94 |
90 // Add relocation to GOT cell for dispatch jump. |
95 // Add relocation to GOT cell for dispatch jump. |
|
96 // The dispatch jump loads destination address from this GOT cell. |
91 String gotEntrySymbolName = relocationSymbolName("got.entry", mi, call, callSiteRelocation); |
97 String gotEntrySymbolName = relocationSymbolName("got.entry", mi, call, callSiteRelocation); |
92 addExtLinkageGotContainerRelocation(binaryContainer, gotEntrySymbolName, gotStartOffset, stub.getDispatchJumpOffset()); |
98 addExtLinkageGotContainerRelocation(binaryContainer, gotEntrySymbolName, gotStartOffset, stub.getDispatchJumpOffset()); |
93 |
99 |
94 // Virtual call needs initial -1 value. |
100 // Virtual call needs initial -1 value for Klass pointer. |
|
101 // Non virtual call needs initial 0 value for Method pointer to call c2i adapter. |
95 byte[] slot = isVirtualCall ? minusOneSlot : zeroSlot; |
102 byte[] slot = isVirtualCall ? minusOneSlot : zeroSlot; |
96 final int gotMetaOffset = binaryContainer.appendMetaspaceGotBytes(slot, 0, slot.length); |
103 final int gotMetaOffset = binaryContainer.appendExtLinkageGotBytes(slot, 0, slot.length); |
97 |
104 |
98 // Add relocation to GOT cell for move instruction (Klass* for virtual, Method* otherwise). |
105 // Add relocation to GOT cell for move instruction (Klass* for virtual, Method* otherwise). |
99 String gotMoveSymbolName = relocationSymbolName("got.move", mi, call, callSiteRelocation); |
106 String gotMoveSymbolName = relocationSymbolName("got.move", mi, call, callSiteRelocation); |
100 addMetaspaceGotRelocation(binaryContainer, gotMoveSymbolName, gotMetaOffset, stub.getMovOffset()); |
107 addExtLinkageGotContainerRelocation(binaryContainer, gotMoveSymbolName, gotMetaOffset, stub.getMovOffset()); |
101 |
108 |
102 if (isVirtualCall) { |
109 if (isVirtualCall) { |
103 // Nothing. |
110 // Nothing. |
104 } else { |
111 } else { |
105 // Add relocation to GOT cell for c2i adapter jump. |
112 // Add relocation to GOT cell for c2i adapter jump. |
|
113 // The c2i jump instruction loads destination address from this GOT cell. |
|
114 // This GOT cell is initialized with -1 and will be updated |
|
115 // by JVM runtime call resolution code. |
106 String gotC2ISymbolName = relocationSymbolName("got.c2i", mi, call, callSiteRelocation); |
116 String gotC2ISymbolName = relocationSymbolName("got.c2i", mi, call, callSiteRelocation); |
107 addExtLinkageGotContainerRelocation(binaryContainer, gotC2ISymbolName, gotStartOffset + 8, stub.getC2IJumpOffset()); |
117 addExtLinkageGotContainerRelocation(binaryContainer, gotC2ISymbolName, gotStartOffset + 8, stub.getC2IJumpOffset()); |
108 } |
118 } |
109 } |
119 } |
110 |
120 |