qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] MINGW: Unable to link multiboot.img + strnlen missing
@ 2009-07-01 13:04 Bartlomiej Celary
  2009-07-01 13:24 ` Anthony Liguori
  0 siblings, 1 reply; 10+ messages in thread
From: Bartlomiej Celary @ 2009-07-01 13:04 UTC (permalink / raw)
  To: qemu-devel

Hi,
I have recently updated my git snapshot and had 2 problems:

1. There is no strnlen function in MINGW (not sure if it has been
added recently as I might be using an outdated version...)

2. I was not able to link multiboot.bin using mingw:

for d in pc-bios/optionrom; do \
make -C $d || exit 1 ; \
        done
make[1]: Entering directory `/home/abc024/work/qemu/pc-bios/optionrom'
gcc -o signrom -g -Wall signrom.c
gcc -Wall -Wstrict-prototypes -Werror -fomit-frame-pointer
-fno-builtin -I/home/abc024/work/qemu -o multiboot.o -c multiboot.S
ld --oformat binary -Ttext 0 -o multiboot.img multiboot.o
D:\mingw\bin\ld.exe: cannot perform PE operations on non PE output
file 'multiboot.img'.
make[1]: *** [multiboot.img] Error 1
rm multiboot.o
make[1]: Leaving directory `/home/abc024/work/qemu/pc-bios/optionrom'
make: *** [roms] Error 1

And it looks that this workaround did the trick:

diff --git a/pc-bios/optionrom/Makefile b/pc-bios/optionrom/Makefile
old mode 100644
new mode 100755
index c4a6f42..f414eba
--- a/pc-bios/optionrom/Makefile
+++ b/pc-bios/optionrom/Makefile
@@ -34,8 +34,14 @@ build-all: multiboot.bin
 %.o: %.S
        $(CC) $(CFLAGS) -o $@ -c $<

-%.img: %.o
-       $(LD) --oformat binary -Ttext 0 -o $@ $<
+%.img: %.out
+       $(OBJCOPY) -O binary -j .text $< $@
+
+%.out: %.o
+       $(LD) -Ttext 0 -e _start -s -o $@ $<

 %.bin: %.img signrom
        ./signrom $< $@

Obviously objcopy needs to be defined in the config.mak file.

Regards,
Bartek Celary

^ permalink raw reply related	[flat|nested] 10+ messages in thread
* [Qemu-devel] (no subject)
@ 2009-07-01 21:26 G 3
  2009-07-01 21:29 ` [Qemu-devel] Re: [PATCH] Win32: Fix build (no strnlen) G 3
  0 siblings, 1 reply; 10+ messages in thread
From: G 3 @ 2009-07-01 21:26 UTC (permalink / raw)
  To: qemu-devel

> Stefan Weil wrote:
>
>     strnlen is a GNU extension which is missing in mingw32
>     and perhaps other build environments.
>
>
>     So we should avoid it and replace it by standard functions.
>
>
>     Signed-off-by: Stefan Weil <address@hidden>
>     ---
>      block.c |    7 ++++++-
>      1 files changed, 6 insertions(+), 1 deletions(-)
>
>
>     diff --git a/block.c b/block.c
>     index c66c031..79b3313 100644
>     --- a/block.c
>     +++ b/block.c
>     @@ -225,9 +225,14 @@ static BlockDriver *find_protocol(const char 
> *filename)
>     {
>     BlockDriver *drv1;
>     char protocol[128];
>     - int len = strnlen(filename, 127)+1;
>     + int len;
>     const char *p;
>     + len = strlen(filename) + 1;
>     + if (len > sizeof(protocol)) {
>     + len = sizeof(protocol);
>     + }
>     +
>     #ifdef _WIN32
>     if (is_windows_drive(filename) ||
>     is_windows_drive_prefix(filename))
>
>
> Or something like this?
> #ifdef __MINGW32__
> size_t strnlen (const char *string, size_t maxlen)
> {
>   const char *end = memchr (string, '\0', maxlen);
>   return end ? (size_t) (end - string) : maxlen;
> };
> #endif

block.c doesn't compile on Mac OS 10.3. I second the notion of removing 
strnlen.

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

end of thread, other threads:[~2009-07-10 16:03 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-01 13:04 [Qemu-devel] MINGW: Unable to link multiboot.img + strnlen missing Bartlomiej Celary
2009-07-01 13:24 ` Anthony Liguori
2009-07-01 14:35   ` Alexander Graf
2009-07-01 15:52     ` Anthony Liguori
2009-07-01 15:55       ` Alexander Graf
2009-07-10 15:36         ` Bartlomiej Celary
2009-07-10 16:03           ` Anthony Liguori
2009-07-01 18:01   ` [Qemu-devel] [PATCH] Win32: Fix build (no strnlen) Stefan Weil
2009-07-01 18:44     ` [Qemu-devel] " Consul
  -- strict thread matches above, loose matches on Subject: below --
2009-07-01 21:26 [Qemu-devel] (no subject) G 3
2009-07-01 21:29 ` [Qemu-devel] Re: [PATCH] Win32: Fix build (no strnlen) G 3

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).