Commit 5be1676206f83dc603a8746de8026b3f966b1b97
1 parent
398ce98e
R_PPC_REL24 safety net
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4706 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
8 additions
and
0 deletions
dyngen.c
... | ... | @@ -1963,6 +1963,14 @@ void gen_code(const char *name, host_ulong offset, host_ulong size, |
1963 | 1963 | break; |
1964 | 1964 | case R_PPC_REL24: |
1965 | 1965 | /* warning: must be at 32 MB distancy */ |
1966 | + fprintf(outfile, "{\n" | |
1967 | + " long disp = (%s - (long)(gen_code_ptr + %d) + %d);\n" | |
1968 | + " if ((disp << 6) >> 6 != disp) {;\n" | |
1969 | + " fprintf(stderr, \"Branch target is too far away\\n\");" | |
1970 | + " abort();\n" | |
1971 | + " }\n" | |
1972 | + "}\n", | |
1973 | + relname, reloc_offset, addend); | |
1966 | 1974 | fprintf(outfile, " *(uint32_t *)(gen_code_ptr + %d) = (*(uint32_t *)(gen_code_ptr + %d) & ~0x03fffffc) | ((%s - (long)(gen_code_ptr + %d) + %d) & 0x03fffffc);\n", |
1967 | 1975 | reloc_offset, reloc_offset, relname, reloc_offset, addend); |
1968 | 1976 | break; | ... | ... |