qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] Some OpenBSD/amd64 build fixes
@ 2009-09-23 20:31 Laurence Tratt
  2009-09-23 20:55 ` Juergen Lock
  0 siblings, 1 reply; 5+ messages in thread
From: Laurence Tratt @ 2009-09-23 20:31 UTC (permalink / raw)
  To: qemu-devel

Dear all,

I've been trying to get the qemu in git to build on OpenBSD/amd64. It's not
there yet, but I have made some progress. The first problem encountered is
that x86_64.ld fails:

  $ gmake
    LINK  i386-bsd-user/qemu-i386
  /usr/bin/ld:/tmp/qemu/x86_64.ld:61: syntax error
  collect2: ld returned 1 exit status
  gmake[1]: *** [qemu-i386] Error 1
  gmake: *** [subdir-i386-bsd-user] Error 2
  $

One of the patches at the end of this e-mail fixes that by removing the
ONLY_IF_RO parts that make it choke [thanks to blauwirbel@gmail.com for the
hint]. I don't honestly know the precise semantic effect ONLY_IF_RO has, but
I'm assuming it's not critical.

Another problem I've patched is with signrom.sh which uses the -A option
which isn't found in OpenBSD's od. I've hacked around that (inelegantly, I
admit) in a way which I think should still preserve correct operation on
other platforms (it works OK under Linux, at least).


Unfortunately there are still a couple of places that I'm stuck. Any help
would be much appreciated, and I can provide an OpenBSD/amd64 account for
anyone who's interested in playing further.

First, if I do a plain "./configure", the build dies as follows:

  ...
    AR    i386-bsd-user/libqemu.a
    LINK  i386-bsd-user/qemu-i386
  libqemu.a(i386-dis.o)(.text+0x19af): In function `oappend':
  /home/ltratt/qemu/i386-dis.c:4656: warning: strcpy() is almost always misused, please use strlcpy()
  main.o(.text+0x5fc): In function `main':
  /home/ltratt/qemu/bsd-user/main.c:911: undefined reference to `guest_base'
  main.o(.text+0x740):/home/ltratt/qemu/bsd-user/main.c:941: undefined reference to `guest_base'
  bsdload.o(.text+0x31): In function `memcpy_to_target':
  /home/ltratt/qemu/bsd-user/qemu.h:331: undefined reference to `guest_base'
  bsdload.o(.text+0x230): In function `loader_build_argptr':
  /home/ltratt/qemu/bsd-user/qemu.h:331: undefined reference to `guest_base'
  bsdload.o(.text+0x262):/home/ltratt/qemu/bsd-user/qemu.h:331: undefined reference to `guest_base'
  bsdload.o(.text+0x2a1):/home/ltratt/qemu/bsd-user/qemu.h:331: more undefined references to `guest_base' follow
  collect2: ld returned 1 exit status
  gmake[1]: *** [qemu-i386] Error 1
  gmake: *** [subdir-i386-bsd-user] Error 2
  $

I haven't yet investigated this in depth. If I do "./configure
-disable-guest", then the above error doesn't occur, but
pc-bios/optionrom/multiboot.S dies as follows:

  $
    AS    optionrom/multiboot.o
  multiboot.S: Assembler messages:
  multiboot.S:116: Error: `%es:-4(%edi)' is not a valid 16 bit base/index
expression
  $

What little Intel assembler I ever knew has long since departed from my
brain, so I don't know why that error occurs, nor what a fix might be.


Laurie
-- 
http://tratt.net/laurie/ -- Personal
http://fetegeo.org/      -- Free text geocoding
http://convergepl.org/   -- The Converge programming language
http://www.model-transformation.org/ICMT2010/ -- ICMT 2010


diff --git a/x86_64.ld b/x86_64.ld
index 24ea77d..aeb0bce 100644
--- a/x86_64.ld
+++ b/x86_64.ld
@@ -58,8 +58,8 @@ SECTIONS
   .rodata         : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
   .rodata1        : { *(.rodata1) }
   .eh_frame_hdr : { *(.eh_frame_hdr) }
-  .eh_frame       : ONLY_IF_RO { KEEP (*(.eh_frame)) }
-  .gcc_except_table   : ONLY_IF_RO { *(.gcc_except_table) }
+  .eh_frame       : { KEEP (*(.eh_frame)) }
+  .gcc_except_table   : { *(.gcc_except_table) }
   /* Adjust the address for the data segment.  We want to adjust up to
      the same address within the page on the next page up.  */
   . = ALIGN (0x100000) - ((0x100000 - .) & (0x100000 - 1)); . = DATA_SEGMENT_ALIGN (0x100000, 0x1000);
@@ -85,8 +85,8 @@ SECTIONS
   .data1          : { *(.data1) }
   .tdata	  : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
   .tbss		  : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
-  .eh_frame       : ONLY_IF_RW { KEEP (*(.eh_frame)) }
-  .gcc_except_table   : ONLY_IF_RW { *(.gcc_except_table) }
+  .eh_frame       : { KEEP (*(.eh_frame)) }
+  .gcc_except_table   : { *(.gcc_except_table) }
   .dynamic        : { *(.dynamic) }
   .ctors          :
   {
--- a/pc-bios/optionrom/signrom.sh
+++ b/pc-bios/optionrom/signrom.sh
@@ -26,12 +26,16 @@ test "$1" -a "$2" || exit 1
 sum=0
 
 # find out the file size
-x=`dd if="$1" bs=1 count=1 skip=2 2>/dev/null | od -t u1 -A n`
+tmp=`mktemp`
+dd if="$1" bs=1 count=1 skip=2 2>/dev/null > $tmp
+x=`od -v -t u1 $tmp | head -n 1 | cut -d " " -f 2- | sed "s/ //g" | sed "s/^0*//g"`
+rm $tmp
 #size=`expr $x \* 512 - 1`
 size=$(( $x * 512 - 1 ))
 
 # now get the checksum
-nums=`od -A n -t u1 -v "$1"`
+num_lines=`od -v -t u1 "$1" | wc -l`
+nums=`od -v -t u1 "$1" | head -n $(( num_lines - 1 ))  | cut -d " " -f 2-`
 for i in ${nums}; do
     # add each byte's value to sum
     sum=`expr $sum + $i`
diff --git a/x86_64.ld b/x86_64.ld
index 24ea77d..aeb0bce 100644

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] Some OpenBSD/amd64 build fixes
  2009-09-23 20:31 [Qemu-devel] Some OpenBSD/amd64 build fixes Laurence Tratt
@ 2009-09-23 20:55 ` Juergen Lock
  2009-10-13 21:29   ` [PATCH] multiboot.S patch for old as(1) (was: Re: [Qemu-devel] Some OpenBSD/amd64 build fixes) Juergen Lock
  0 siblings, 1 reply; 5+ messages in thread
From: Juergen Lock @ 2009-09-23 20:55 UTC (permalink / raw)
  To: Laurence Tratt; +Cc: qemu-devel

On Wed, Sep 23, 2009 at 09:31:16PM +0100, Laurence Tratt wrote:
> Dear all,
> 
> I've been trying to get the qemu in git to build on OpenBSD/amd64. It's not
> there yet, but I have made some progress. The first problem encountered is
> that x86_64.ld fails:
> 
>   $ gmake
>     LINK  i386-bsd-user/qemu-i386
>   /usr/bin/ld:/tmp/qemu/x86_64.ld:61: syntax error
>   collect2: ld returned 1 exit status
>   gmake[1]: *** [qemu-i386] Error 1
>   gmake: *** [subdir-i386-bsd-user] Error 2
>   $
> 
> One of the patches at the end of this e-mail fixes that by removing the
> ONLY_IF_RO parts that make it choke [thanks to blauwirbel@gmail.com for the
> hint]. I don't honestly know the precise semantic effect ONLY_IF_RO has, but
> I'm assuming it's not critical.
> 
Yup, I've had this on FreeBSD as well (and came up with practically the
same workaround.)

> Another problem I've patched is with signrom.sh which uses the -A option
> which isn't found in OpenBSD's od. I've hacked around that (inelegantly, I
> admit) in a way which I think should still preserve correct operation on
> other platforms (it works OK under Linux, at least).
> 
> 
> Unfortunately there are still a couple of places that I'm stuck. Any help
> would be much appreciated, and I can provide an OpenBSD/amd64 account for
> anyone who's interested in playing further.
> 
> First, if I do a plain "./configure", the build dies as follows:
> 
>   ...
>     AR    i386-bsd-user/libqemu.a
>     LINK  i386-bsd-user/qemu-i386
>   libqemu.a(i386-dis.o)(.text+0x19af): In function `oappend':
>   /home/ltratt/qemu/i386-dis.c:4656: warning: strcpy() is almost always misused, please use strlcpy()
>   main.o(.text+0x5fc): In function `main':
>   /home/ltratt/qemu/bsd-user/main.c:911: undefined reference to `guest_base'
>   main.o(.text+0x740):/home/ltratt/qemu/bsd-user/main.c:941: undefined reference to `guest_base'
>   bsdload.o(.text+0x31): In function `memcpy_to_target':
>   /home/ltratt/qemu/bsd-user/qemu.h:331: undefined reference to `guest_base'
>   bsdload.o(.text+0x230): In function `loader_build_argptr':
>   /home/ltratt/qemu/bsd-user/qemu.h:331: undefined reference to `guest_base'
>   bsdload.o(.text+0x262):/home/ltratt/qemu/bsd-user/qemu.h:331: undefined reference to `guest_base'
>   bsdload.o(.text+0x2a1):/home/ltratt/qemu/bsd-user/qemu.h:331: more undefined references to `guest_base' follow
>   collect2: ld returned 1 exit status
>   gmake[1]: *** [qemu-i386] Error 1
>   gmake: *** [subdir-i386-bsd-user] Error 2
>   $
> 
> I haven't yet investigated this in depth. If I do "./configure
> -disable-guest",

 You mean --disable-bsd-user?

>  then the above error doesn't occur, but
> pc-bios/optionrom/multiboot.S dies as follows:
> 
>   $
>     AS    optionrom/multiboot.o
>   multiboot.S: Assembler messages:
>   multiboot.S:116: Error: `%es:-4(%edi)' is not a valid 16 bit base/index
> expression
>   $
> 
> What little Intel assembler I ever knew has long since departed from my
> brain, so I don't know why that error occurs, nor what a fix might be.
> 
 It occurs because of too old binutils (as(1) in this case), on FreeBSD
we now have a port for newer ones,
	http://www.freshports.org/devel/binutils
so I depend on that and have the optionrom Makefile use the new as
like this: (the first change wrt CFLAGS is unrelated and has probably
been fixed in the meantime; it caused gmake to complain about
recursive use of CFLAGS.)

Index: qemu/pc-bios/optionrom/Makefile
@@ -9,10 +9,13 @@
 
 CFLAGS = -Wall -Wstrict-prototypes -Werror -fomit-frame-pointer -fno-builtin
 CFLAGS += -I$(SRC_PATH)
-CFLAGS += $(call cc-option, $(CFLAGS), -fno-stack-protector,"")
+CFLAGS := $(CFLAGS) $(call cc-option, $(CFLAGS), -fno-stack-protector,"")
 
 build-all: multiboot.bin
 
+%.o: %.S
+	$(CC) -E $(CFLAGS) -o - -c $< |${LOCALBASE}/bin/as -V -Qy -o $@
+
 %.img: %.o
 	$(call quiet-command,$(LD) -Ttext 0 -e _start -s -o $@ $<,"  Building $(TARGET_DIR)$@")
 
 HTH,
	Juergen

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] multiboot.S patch for old as(1) (was: Re: [Qemu-devel] Some OpenBSD/amd64 build fixes)
  2009-09-23 20:55 ` Juergen Lock
@ 2009-10-13 21:29   ` Juergen Lock
  2009-10-14 14:29     ` [Qemu-devel] Re: [PATCH] multiboot.S patch for old as(1) Paolo Bonzini
  0 siblings, 1 reply; 5+ messages in thread
From: Juergen Lock @ 2009-10-13 21:29 UTC (permalink / raw)
  To: Juergen Lock; +Cc: qemu-devel, Laurence Tratt

On Wed, Sep 23, 2009 at 10:55:02PM +0200, Juergen Lock wrote:
> On Wed, Sep 23, 2009 at 09:31:16PM +0100, Laurence Tratt wrote:
>[...]
> >  then the above error doesn't occur, but
> > pc-bios/optionrom/multiboot.S dies as follows:
> > 
> >   $
> >     AS    optionrom/multiboot.o
> >   multiboot.S: Assembler messages:
> >   multiboot.S:116: Error: `%es:-4(%edi)' is not a valid 16 bit base/index
> > expression
> >   $
> > 
> > What little Intel assembler I ever knew has long since departed from my
> > brain, so I don't know why that error occurs, nor what a fix might be.
> > 
>  It occurs because of too old binutils (as(1) in this case), on FreeBSD
> we now have a port for newer ones,
> 	http://www.freshports.org/devel/binutils
> so I depend on that and have the optionrom Makefile use the new as
> like this: (the first change wrt CFLAGS is unrelated and has probably
> been fixed in the meantime; it caused gmake to complain about
> recursive use of CFLAGS.)
> 
> Index: qemu/pc-bios/optionrom/Makefile
> @@ -9,10 +9,13 @@
>  
>  CFLAGS = -Wall -Wstrict-prototypes -Werror -fomit-frame-pointer -fno-builtin
>  CFLAGS += -I$(SRC_PATH)
> -CFLAGS += $(call cc-option, $(CFLAGS), -fno-stack-protector,"")
> +CFLAGS := $(CFLAGS) $(call cc-option, $(CFLAGS), -fno-stack-protector,"")
>  
>  build-all: multiboot.bin
>  
> +%.o: %.S
> +	$(CC) -E $(CFLAGS) -o - -c $< |${LOCALBASE}/bin/as -V -Qy -o $@
> +
>  %.img: %.o
>  	$(call quiet-command,$(LD) -Ttext 0 -e _start -s -o $@ $<,"  Building $(TARGET_DIR)$@")
>  

That patch didn't seem to help on OpenBSD so I now finally got around
making another one that just emits the bytes of the offending insn
instead so people can keep using old assemblers:

--- a/pc-bios/optionrom/multiboot.S
+++ b/pc-bios/optionrom/multiboot.S
@@ -113,7 +113,10 @@ mmap_loop:
 	/* entry size (mmap struct) & max buffer size (int15) */
 	movl		$20, %ecx
 	/* store entry size */
+	/* old as(1) doesn't like this insn so emit the bytes instead:
 	movl		%ecx, %es:-4(%edi)
+	*/
+	.dc.b		0x26,0x67,0x66,0x89,0x4f,0xfc
 	/* e820 */
 	movl		$0x0000e820, %eax
 	/* 'SMAP' magic */

 Signed-off-by: Juergen Lock <nox@jelal.kn-bremen.de>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Qemu-devel] Re: [PATCH] multiboot.S patch for old as(1)
  2009-10-13 21:29   ` [PATCH] multiboot.S patch for old as(1) (was: Re: [Qemu-devel] Some OpenBSD/amd64 build fixes) Juergen Lock
@ 2009-10-14 14:29     ` Paolo Bonzini
  2009-10-14 19:18       ` Juergen Lock
  0 siblings, 1 reply; 5+ messages in thread
From: Paolo Bonzini @ 2009-10-14 14:29 UTC (permalink / raw)
  To: Juergen Lock; +Cc: qemu-devel, Laurence Tratt

On 10/13/2009 11:29 PM, Juergen Lock wrote:
> +	.dc.b		0x26,0x67,0x66,0x89,0x4f,0xfc

If anything, this would be easier to read:

	.dc.b		0x26		/* %es: prefix for old as(1) */
	movl		%ecx, -4(%edi)

Paolo

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Qemu-devel] Re: [PATCH] multiboot.S patch for old as(1)
  2009-10-14 14:29     ` [Qemu-devel] Re: [PATCH] multiboot.S patch for old as(1) Paolo Bonzini
@ 2009-10-14 19:18       ` Juergen Lock
  0 siblings, 0 replies; 5+ messages in thread
From: Juergen Lock @ 2009-10-14 19:18 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: Juergen Lock, Laurence Tratt, qemu-devel

On Wed, Oct 14, 2009 at 04:29:32PM +0200, Paolo Bonzini wrote:
> On 10/13/2009 11:29 PM, Juergen Lock wrote:
> > +	.dc.b		0x26,0x67,0x66,0x89,0x4f,0xfc
> 
> If anything, this would be easier to read:
> 
> 	.dc.b		0x26		/* %es: prefix for old as(1) */
> 	movl		%ecx, -4(%edi)
> 
I like the idea, but unfortunately old as (2.15) doesnt, it still says:
	Error: `-4(%edi)' is not a valid 16 bit base/index expression

 :(,
	Juergen

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-10-14 19:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-23 20:31 [Qemu-devel] Some OpenBSD/amd64 build fixes Laurence Tratt
2009-09-23 20:55 ` Juergen Lock
2009-10-13 21:29   ` [PATCH] multiboot.S patch for old as(1) (was: Re: [Qemu-devel] Some OpenBSD/amd64 build fixes) Juergen Lock
2009-10-14 14:29     ` [Qemu-devel] Re: [PATCH] multiboot.S patch for old as(1) Paolo Bonzini
2009-10-14 19:18       ` Juergen Lock

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).