Skip to contentSkip to conversation

[4706] R_PPC_REL24 safety net

Qemu-devel malc 1 participant 1 message Jun 9, 2008

lore
Share & tools
lore

malc

author
#0 lore raw

Revision: 4706

          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=4706
Author:   malc
Date:     2008-06-09 06:06:28 +0000 (Mon, 09 Jun 2008)

Log Message:
-----------
R_PPC_REL24 safety net

Modified Paths:
--------------
trunk/dyngen.c

Modified: trunk/dyngen.c
===================================================================

dyngen.c +8 -0
@@ -1963,6 +1963,14 @@
                                 break;
                             case R_PPC_REL24:
                                 /* warning: must be at 32 MB distancy */
+                                fprintf(outfile, "{\n"
+                                        "    long disp = (%s - (long)(gen_code_ptr + %d) + %d);\n"
+                                        "    if ((disp << 6) >> 6 != disp) {;\n"
+                                        "        fprintf(stderr, \"Branch target is too far away\\n\");"
+                                        "        abort();\n"
+                                        "    }\n"
+                                        "}\n",
+                                        relname, reloc_offset, addend);
                                 fprintf(outfile, "    *(uint32_t *)(gen_code_ptr + %d) = (*(uint32_t *)(gen_code_ptr + %d) & ~0x03fffffc) | ((%s - (long)(gen_code_ptr + %d) + %d) & 0x03fffffc);\n",
                                         reloc_offset, reloc_offset, relname, reloc_offset, addend);
                                 break;