Commit a4d8670ffcb1c81c386a7e1d4a60cd28221c7772
1 parent
3aba3d86
win32 fix
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3965 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
31 additions
and
11 deletions
dyngen.c
... | ... | @@ -1914,17 +1914,37 @@ void gen_code(const char *name, host_ulong offset, host_ulong size, |
1914 | 1914 | } |
1915 | 1915 | } |
1916 | 1916 | type = rel->r_type; |
1917 | - switch(type) { | |
1918 | - case DIR32: | |
1919 | - fprintf(outfile, " *(uint32_t *)(gen_code_ptr + %d) = %s + %d;\n", | |
1920 | - reloc_offset, relname, addend); | |
1921 | - break; | |
1922 | - case DISP32: | |
1923 | - fprintf(outfile, " *(uint32_t *)(gen_code_ptr + %d) = %s - (long)(gen_code_ptr + %d) + %d -4;\n", | |
1924 | - reloc_offset, relname, reloc_offset, addend); | |
1925 | - break; | |
1926 | - default: | |
1927 | - error("unsupported i386 relocation (%d)", type); | |
1917 | + if (is_label) { | |
1918 | +/* TCG uses elf relocation constants */ | |
1919 | +#define R_386_32 1 | |
1920 | +#define R_386_PC32 2 | |
1921 | + switch(type) { | |
1922 | + case DIR32: | |
1923 | + type = R_386_32; | |
1924 | + goto do_reloc; | |
1925 | + case DISP32: | |
1926 | + type = R_386_PC32; | |
1927 | + addend -= 4; | |
1928 | + do_reloc: | |
1929 | + fprintf(outfile, " tcg_out_reloc(s, gen_code_ptr + %d, %d, %s, %d);\n", | |
1930 | + reloc_offset, type, relname, addend); | |
1931 | + break; | |
1932 | + default: | |
1933 | + error("unsupported i386 relocation (%d)", type); | |
1934 | + } | |
1935 | + } else { | |
1936 | + switch(type) { | |
1937 | + case DIR32: | |
1938 | + fprintf(outfile, " *(uint32_t *)(gen_code_ptr + %d) = %s + %d;\n", | |
1939 | + reloc_offset, relname, addend); | |
1940 | + break; | |
1941 | + case DISP32: | |
1942 | + fprintf(outfile, " *(uint32_t *)(gen_code_ptr + %d) = %s - (long)(gen_code_ptr + %d) + %d -4;\n", | |
1943 | + reloc_offset, relname, reloc_offset, addend); | |
1944 | + break; | |
1945 | + default: | |
1946 | + error("unsupported i386 relocation (%d)", type); | |
1947 | + } | |
1928 | 1948 | } |
1929 | 1949 | #else |
1930 | 1950 | #error unsupport object format | ... | ... |