Building qemu on ARM host
I'm trying to build qemu from CVS on an ARM/Xscale host (Linux 2.6.13.4, gcc 3.3.1, binutils 2.14). I had to apply the enclosed qemu-arm.patch to fix some bitrot, but now the build fails with 'relocation truncated to fit' errors. I tried building with -mlong-calls but that didn't make a difference (required qemu-cflags.patch to get the --extra-cflags/--extra-ldflags args to work in configure).
Does anyone know how to fix the relocation problem?
Build error:
gcc -mlong-calls -g -Wl,-T,/root/qemu/arm.ld -o qemu-i386 elfload.o main.o syscall.o mmap.o signal.o path.o osdep.o thunk.o vm86.o libqemu.a gdbstub.o -lm
libqemu.a(op.o)(.text+0x27e0): In function `op_jb_subb':/root/qemu/target-i386/ops_template.h:278: relocation truncated to fit: R_ARM_PC24 __op_gen_label1 libqemu.a(op.o)(.text+0x2800): In function `op_jz_subb':/root/qemu/target-i386/ops_template.h:285: relocation truncated to fit: R_ARM_PC24 __op_gen_label1 libqemu.a(op.o)(.text+0x2820): In function `op_jnz_subb':/root/qemu/target-i386/ops_template.h:292: relocation truncated to fit: R_ARM_PC24 __op_gen_label1 libqemu.a(op.o)(.text+0x2850): In function `op_jbe_subb':/root/qemu/target-i386/ops_template.h:303: relocation truncated to fit: R_ARM_PC24 __op_gen_label1 libqemu.a(op.o)(.text+0x2870): In function `op_js_subb':/root/qemu/target-i386/ops_template.h:310: relocation truncated to fit: R_ARM_PC24 __op_gen_label1 libqemu.a(op.o)(.text+0x28a0): In function `op_jl_subb':/root/qemu/target-i386/ops_template.h:321: relocation truncated to fit: R_ARM_PC24 __op_gen_label1 libqemu.a(op.o)(.text+0x28d0): In function `op_jle_subb':/root/qemu/target-i386/ops_template.h:332: relocation truncated to fit: R_ARM_PC24 __op_gen_label1 libqemu.a(op.o)(.text+0x385c): In function `op_jb_subw':/root/qemu/target-i386/ops_template.h:278: relocation truncated to fit: R_ARM_PC24 __op_gen_label1 libqemu.a(op.o)(.text+0x387c): In function `op_jz_subw':/root/qemu/target-i386/ops_template.h:285: relocation truncated to fit: R_ARM_PC24 __op_gen_label1 libqemu.a(op.o)(.text+0x389c): In function `op_jnz_subw':/root/qemu/target-i386/ops_template.h:292: relocation truncated to fit: R_ARM_PC24 __op_gen_label1 libqemu.a(op.o)(.text+0x38cc): In function `op_jbe_subw':/root/qemu/target-i386/ops_template.h:303: relocation truncated to fit: R_ARM_PC24 __op_gen_label1 libqemu.a(op.o)(.text+0x38ec): In function `op_js_subw':/root/qemu/target-i386/ops_template.h:310: relocation truncated to fit: R_ARM_PC24 __op_gen_label1 libqemu.a(op.o)(.text+0x391c): In function `op_jl_subw':/root/qemu/target-i386/ops_template.h:321: relocation truncated to fit: R_ARM_PC24 __op_gen_label1 libqemu.a(op.o)(.text+0x394c): In function `op_jle_subw':/root/qemu/target-i386/ops_template.h:332: relocation truncated to fit: R_ARM_PC24 __op_gen_label1 libqemu.a(op.o)(.text+0x3974): In function `op_loopnzw':/root/qemu/target-i386/ops_template.h:343: relocation truncated to fit: R_ARM_PC24 __op_gen_label1 libqemu.a(op.o)(.text+0x399c): In function `op_loopzw':/root/qemu/target-i386/ops_template.h:350: relocation truncated to fit: R_ARM_PC24 __op_gen_label1 libqemu.a(op.o)(.text+0x39bc): In function `op_jz_ecxw':/root/qemu/target-i386/ops_template.h:357: relocation truncated to fit: R_ARM_PC24 __op_gen_label1 libqemu.a(op.o)(.text+0x39dc): In function `op_jnz_ecxw':/root/qemu/target-i386/ops_template.h:364: relocation truncated to fit: R_ARM_PC24 __op_gen_label1 libqemu.a(op.o)(.text+0x4e08): In function `op_jb_subl':/root/qemu/target-i386/ops_template.h:278: relocation truncated to fit: R_ARM_PC24 __op_gen_label1 libqemu.a(op.o)(.text+0x4e28): In function `op_jz_subl':/root/qemu/target-i386/ops_template.h:285: relocation truncated to fit: R_ARM_PC24 __op_gen_label1 libqemu.a(op.o)(.text+0x4e48): In function `op_jnz_subl':/root/qemu/target-i386/ops_template.h:292: relocation truncated to fit: R_ARM_PC24 __op_gen_label1 libqemu.a(op.o)(.text+0x4e74): In function `op_jbe_subl':/root/qemu/target-i386/ops_template.h:303: relocation truncated to fit: R_ARM_PC24 __op_gen_label1 libqemu.a(op.o)(.text+0x4e94): In function `op_js_subl':/root/qemu/target-i386/ops_template.h:310: relocation truncated to fit: R_ARM_PC24 __op_gen_label1 libqemu.a(op.o)(.text+0x4ec0): In function `op_jl_subl':/root/qemu/target-i386/ops_template.h:321: relocation truncated to fit: R_ARM_PC24 __op_gen_label1 libqemu.a(op.o)(.text+0x4eec): In function `op_jle_subl':/root/qemu/target-i386/ops_template.h:332: relocation truncated to fit: R_ARM_PC24 __op_gen_label1 libqemu.a(op.o)(.text+0x4f14): In function `op_loopnzl':/root/qemu/target-i386/ops_template.h:343: relocation truncated to fit: R_ARM_PC24 __op_gen_label1 libqemu.a(op.o)(.text+0x4f3c): In function `op_loopzl':/root/qemu/target-i386/ops_template.h:350: relocation truncated to fit: R_ARM_PC24 __op_gen_label1 libqemu.a(op.o)(.text+0x4f5c): In function `op_jz_ecxl':/root/qemu/target-i386/ops_template.h:357: relocation truncated to fit: R_ARM_PC24 __op_gen_label1 libqemu.a(op.o)(.text+0x4f7c): In function `op_jnz_ecxl':/root/qemu/target-i386/ops_template.h:364: relocation truncated to fit: R_ARM_PC24 __op_gen_label1 libqemu.a(op.o)(.text+0x6938): In function `op_jmp_label':/root/qemu/target-i386/op.c:1311: relocation truncated to fit: R_ARM_PC24 __op_gen_label1 libqemu.a(op.o)(.text+0x6954): In function `op_jnz_T0_label':/root/qemu/target-i386/op.c:1317: relocation truncated to fit: R_ARM_PC24 __op_gen_label1 libqemu.a(op.o)(.text+0x6970): In function `op_jz_T0_label':/root/qemu/target-i386/op.c:1324: relocation truncated to fit: R_ARM_PC24 __op_gen_label1
collect2: ld returned 1 exit status
make[1]: *** [qemu-i386] Error 1
make[1]: Leaving directory `/root/qemu/i386-user'
make: *** [all] Error 1
Index: cpu-exec.c
===================================================================
RCS file: /cvsroot/qemu/qemu/cpu-exec.c,v
retrieving revision 1.71
cpu-exec.c 6 Dec 2005 02:49:23 -0000 renamed from cpu-exec.c 5 Dec 2005 20:31:52 -0000 1.71 +1 -1
@@ -1324,7 +1324,7 @@ is_write = 0; return handle_cpu_signal(pc, (unsigned long)info->si_addr, is_write, - &uc->uc_sigmask); + &uc->uc_sigmask, puc); } #elif defined(__mc68000)
Index: disas.c
===================================================================
RCS file: /cvsroot/qemu/qemu/disas.c,v
retrieving revision 1.28
disas.c 6 Dec 2005 02:49:23 -0000 renamed from disas.c 21 Nov 2005 23:25:50 -0000 1.28 +1 -3
@@ -266,9 +266,7 @@ #ifdef __arm__ /* since data are included in the code, it is better to display code data too */ - if (is_host) { - fprintf(out, "%08x ", (int)bfd_getl32((const bfd_byte *)pc)); - } + fprintf(out, "%08x ", (int)bfd_getl32((const bfd_byte *)pc)); #endif count = print_insn(pc, &disasm_info); fprintf(out, "\n");
Index: Makefile
===================================================================
RCS file: /cvsroot/qemu/qemu/Makefile,v
retrieving revision 1.90
Makefile 6 Dec 2005 02:54:10 -0000 renamed from Makefile 21 Aug 2005 09:23:39 -0000 1.90 +2 -2
@@ -1,10 +1,10 @@ -include config-host.mak -CFLAGS=-Wall -O2 -g -fno-strict-aliasing +CFLAGS+=-Wall -O2 -g -fno-strict-aliasing ifdef CONFIG_DARWIN CFLAGS+= -mdynamic-no-pic endif -LDFLAGS=-g +LDFLAGS+=-g LIBS= DEFINES+=-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE TOOLS=qemu-img$(EXESUF)
Index: Makefile.target
===================================================================
RCS file: /cvsroot/qemu/qemu/Makefile.target,v
retrieving revision 1.89
Makefile.target 6 Dec 2005 02:54:10 -0000 renamed from Makefile.target 4 Dec 2005 18:54:21 -0000 1.89 +2 -2
@@ -17,9 +17,9 @@ VPATH+=:$(SRC_PATH)/linux-user DEFINES+=-I$(SRC_PATH)/linux-user -I$(SRC_PATH)/linux-user/$(TARGET_ARCH) endif -CFLAGS=-Wall -O2 -g -fno-strict-aliasing +CFLAGS+=-Wall -O2 -g -fno-strict-aliasing #CFLAGS+=-Werror -LDFLAGS=-g +LDFLAGS+=-g LIBS= HELPER_CFLAGS=$(CFLAGS) DYNGEN=../dyngen$(EXESUF)
Thanks,
Steve
Quoted 3 lines · Steve Magoun
libqemu.a(op.o)(.text+0x27e0): In function `op_jb_subb':
/root/qemu/target-i386/ops_template.h:278: relocation truncated to fit:R_ARM_PC24__op_gen_label1libqemu.a(op.o)(.text+0x2800): In function `op_jz_subb':
My limited experience of this kind of things indicates that the resulting binary got too big for the memory model used in the link unit, but the error indicates the relocation is a 24-bit relocation (8MB signed) so I am not sure this is the case as I doubt your qemu binary is larger than 8MB.
Maybe you could try compiling op.o with -mlong-jump to solve this, but probably not given that this error is from an inline assembly instruction. The assembly instruction in question is the _arm_ GOTO_LABEL_PARAM define in dyngen-exec.h. It may also help simply rearranging the link order or code slightly moving the relocation within reach.
Regards
Henrik