Remove redundant relocations by dyngen
PATCH 1/1 Remove redundant relocations by dyngen
Hello,
The attached patch removes redundant relocations generated by dyngen under Mac OS X. The patch is generic and can easily be extended for other OS'es and cpu's as well. The point is that if a relocation is absolute, it must only be adapted after copying if the original symbol has to be replaced with a reference to another symbol (like param1 or so).
This does not make the dynamically generated code any faster, but the generation of that code at run time by qemu is sped up a little (since redundant relocation calculations in op.h are removed).
Jonas
Index: dyngen.c
===================================================================
RCS file: /cvsroot/qemu/qemu/dyngen.c,v
retrieving revision 1.39
diff -r1.39 dyngen.c1186c1186
< void get_reloc_expr(char *name, int name_size, const char *sym_name)
---
Quoted 1 line
int
get_reloc_expr(char *name, int name_size, const char *sym_name)
1188a1189
Quoted 1 line
int sym_changed;
1189a1191
Quoted 1 line
sym_changed = 0;
1191a1194
Quoted 1 line
sym_changed = 1;
1193a1197
Quoted 1 line
sym_changed = 1;
1203a1208
Quoted 1 line
return sym_changed;
1852a1858
Quoted 1 line
int sym_changed;
1900,1901c1906,1907
< get_reloc_expr(final_sym_name, sizeof(final_sym_name),
< sym_name);
---
Quoted 2 lines
sym_changed = get_reloc_expr(final_sym_name, sizeof(final_sym_name),sym_name);
1904c1910
< if (!strstart(sym_name,"__op_gen_label",&p)) {
---
Quoted 1 line
if (!sym_changed) {1916,1917c1922,1925
< fprintf(outfile, " *(uint16_t *)(gen_code_ptr + %d + 2) = (%s + %d) >> 16;\n",
< slide, final_sym_name, sslide);
---
Quoted 4 lines
if (sym_changed) {
fprintf(outfile, " *(uint16_t *)(gen_code_ptr + %d + 2) = (%s + %d) >> 16;\n",
slide, final_sym_name, sslide);
}1920,1922c1928,1932
< fprintf(outfile, " *(uint16_t *)(gen_code_ptr + %d + 2) = (%s + %d);\n",
< slide, final_sym_name, sslide);
< break;
---
Quoted 5 lines
if (sym_changed) {
fprintf(outfile, " *(uint16_t *)(gen_code_ptr + %d + 2) = (%s + %d);\n",
slide, final_sym_name, sslide);
}
break;1924,1925c1934,1937
< fprintf(outfile, " *(uint16_t *)(gen_code_ptr + %d + 2) = (%s + %d + 0x8000) >> 16;\n",
< slide, final_sym_name, sslide);
---
Quoted 4 lines
if (sym_changed) {
fprintf(outfile, " *(uint16_t *)(gen_code_ptr + %d + 2) = (%s + %d + 0x8000) >> 16;\n",
slide, final_sym_name, sslide);
}