Skip to content

Commit ebce02c

Browse files
authored
Update stub.h
1 parent 49b4802 commit ebce02c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/stub.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@
206206
#define REPLACE_NEAR(t, fn, fn_stub) REPLACE_FAR(t, fn, fn_stub)
207207
#elif defined(__powerpc64__) && __LITTLE_ENDIAN__
208208
// For ppc64le (ELFv2 ABI with function descriptors)
209+
// https://llvm.org/devmtg/2014-04/PDFs/Talks/Euro-LLVM-2014-Weigand.pdf
209210
#define CODESIZE 36U
210211
#define CODESIZE_MIN 36U
211212
#define CODESIZE_MAX CODESIZE
@@ -237,7 +238,8 @@
237238
/* Load 64-bit descriptor address into r11 */ \
238239
p[0] = 0x3d600000 | (uint32_t)(desc_addr >> 48);\
239240
p[1] = 0x616b0000 | (uint32_t)((desc_addr >> 32) & 0xFFFF);\
240-
p[2] = 0x796b07c6 | (uint32_t)(32 << 21) | (31 << 16);\
241+
/* rldicr r11, r11, 32, 31 (Rotate Left Doubleword Immediate then Clear Right) */ \
242+
p[2] = 0x796b07c6; \
241243
p[3] = 0x616b0000 | (uint32_t)((desc_addr >> 16) & 0xFFFF);\
242244
p[4] = 0x616b0000 | (uint32_t)(desc_addr & 0xFFFF);\
243245
/* ld r12, 0(r11) */ \
@@ -251,8 +253,8 @@
251253
CACHEFLUSH((char *)fn, CODESIZE);\
252254
} while(0)
253255
#define REPLACE_NEAR(t, fn, fn_stub) REPLACE_FAR(t, fn, fn_stub)
254-
255256
#elif defined(__powerpc64__)
257+
// For ppc64be (Big Endian, ELFv1 ABI)
256258
#define CODESIZE 28U
257259
#define CODESIZE_MIN 28U
258260
#define CODESIZE_MAX CODESIZE

0 commit comments

Comments
 (0)