File 0002-PPC64-Add-method-for-external-branch-by-using-got-fo.patch of Package lua51-luajit

From 3a13a0544b77753b66846079ce0a4afb37d6cc43 Mon Sep 17 00:00:00 2001
From: Gustavo Serra Scalet <gsscalet@gmail.com>
Date: Tue, 2 Jun 2015 15:54:46 -0300
Subject: [PATCH 02/15] PPC64: Add method for external branch by using @got for
 PIC

---
 src/host/buildvm_asm.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/host/buildvm_asm.c b/src/host/buildvm_asm.c
index ffd14903c64c..7b6c8b2dff2f 100644
--- a/src/host/buildvm_asm.c
+++ b/src/host/buildvm_asm.c
@@ -145,11 +145,9 @@ static void emit_asm_wordreloc(BuildCtx *ctx, uint8_t *p, int n,
 	    (ins & 1) ? "bcl" : "bc", (ins >> 21) & 31, (ins >> 16) & 31, sym);
   } else if ((ins >> 26) == 18) {
 #if LJ_ARCH_PPC64
-    const char *suffix = strchr(sym, '@');
-    if (suffix && suffix[1] == 'h') {
-      fprintf(ctx->fp, "\taddis 11, 2, %s\n", sym);
-    } else if (suffix && suffix[1] == 'l') {
-      fprintf(ctx->fp, "\tld 12, %s\n", sym);
+    char *suffix = strchr(sym, '@');
+    if (suffix) {
+      fprintf(ctx->fp, "\tld 12, %s(2)\n", sym);
     } else
 #endif
     fprintf(ctx->fp, "\t%s " TOCPREFIX "%s\n", (ins & 1) ? "bl" : "b", sym);
@@ -252,6 +250,7 @@ void emit_asm(BuildCtx *ctx)
   fprintf(ctx->fp, "\t.file \"buildvm_%s.dasc\"\n", ctx->dasm_arch);
 #if LJ_ARCH_PPC64
   fprintf(ctx->fp, "\t.abiversion 2\n");
+  fprintf(ctx->fp, "\t.section\t\t\".toc\",\"aw\"\n");
 #endif
   fprintf(ctx->fp, "\t.text\n");
   emit_asm_align(ctx, 4);
-- 
2.20.1