Skip to contentSkip to conversation

Many syntax errors in op.h

Qemu-devel Dave Feustel 4 participants 6 messages Nov 15, 2005

lore
Share & tools
lore
#0 lore raw

I am making progress as I modify the Qemu source code to work around a number of OpenBSD deficiencies. I don't yet know how to fix the following problem which occurs about 25 times in op.h:

C statements of the form

   *(uint32_t *)(gen_code_ptr + 210) = (long)(&) + 14;

generate syntax errors (apparently because of the use of "(&)") with the c compiler used in OpenBSD 3.7 (gcc (GCC) 3.3.5 (propolice)).

Similar statements with a symbol following the "&" (eg "(&xyz)") do not generate syntax errors. Has this been seen before? Is there a fix?

Thanks,
Dave Feustel

Signature · 3 lines
Switch to Secure OpenBSD with a KDE desktop!!!
NOW with Virtual PC OS support via QEMU and
Beowulf clustering using PETSc and MPICH2!
#1 lore raw
Quoted 6 lines · Dave Feustel

I am making progress as I modify the Qemu source code to work around a number of OpenBSD deficiencies. I don't yet know how to fix the following problem which occurs about 25 times in op.h:

C statements of the form

Quoted 7 lines
   *(uint32_t *)(gen_code_ptr + 210) = (long)(&) + 14;

generate syntax errors (apparently because of the use of "(&)") with the c compiler used in OpenBSD 3.7 (gcc (GCC) 3.3.5 (propolice)).

Similar statements with a symbol following the "&" (eg "(&xyz)") do not generate syntax errors. Has this been seen before? Is there a fix?

Make sure you disable any stack protection systems (ProPolice, SSP, etc) when compiling op.c.

Paul

#2 lore raw
In reply to Dave Feustel

Hi,

Quoted 1 line · Dave Feustel
   *(uint32_t *)(gen_code_ptr + 210) = (long)(&) + 14;

This is usually a problem with dyngen extracting meaningless relocations from the object file.

It happened to me when I was working on the MIPS (host) support, and a lot of these relocations were relative to some global offset table (GOT). The names were missing, and I got lines like these.

Hth,
Dscho

#3 lore raw
In reply to Dave Feustel
Quoted 10 lines · Dave Feustel

I am making progress as I modify the Qemu source code to work around a number of OpenBSD deficiencies. I don't yet know how to fix the following problem which occurs about 25 times in op.h:

C statements of the form

   *(uint32_t *)(gen_code_ptr + 210) = (long)(&) + 14;

generate syntax errors (apparently because of the use of "(&)") with the c compiler used in OpenBSD 3.7 (gcc (GCC) 3.3.5 (propolice)).

"(&)" is not valid C.

Quoted 2 lines

Similar statements with a symbol following the "&" (eg "(&xyz)") do not generate syntax errors.

Because that is valid C.

-- Jamie

#4 lore raw
Quoted 5 lines · Jamie Lokier
Quoted 4 lines · Dave Feustel

I am making progress as I modify the Qemu source code to work around a number of OpenBSD deficiencies. I don't yet know how to fix the following problem which occurs about 25 times in op.h:

Quoted 8 lines
Quoted 6 lines

C statements of the form

   *(uint32_t *)(gen_code_ptr + 210) = (long)(&) + 14;

generate syntax errors (apparently because of the use of "(&)") with the c compiler used in OpenBSD 3.7 (gcc (GCC) 3.3.5 (propolice)).

"(&)" is not valid C.

That's what I thought too. "&" requires an operand. So why are these lines of code in op.h? Should they be commented out? Should a dummy operand be inserted? What is the fix?

Thanks.

Quoted 7 lines
Quoted 2 lines

Similar statements with a symbol following the "&" (eg "(&xyz)") do not generate syntax errors.

Because that is valid C.

-- Jamie

Signature · 3 lines
Switch to Secure OpenBSD with a KDE desktop!!!
NOW with Virtual PC OS support via QEMU and
Beowulf clustering using PETSc and MPICH2!
#5 lore raw

Hi,

Quoted 7 lines · Dave Feustel
Quoted 2 lines · Jamie Lokier

"(&)" is not valid C.

That's what I thought too. "&" requires an operand. So why are these lines of code in op.h? Should they be commented out? Should a dummy operand be inserted?

Noooo! The code inserts the actual arguments to the op directly into the machine code.

Example:

Say op_add123 implements the addition of a number to register A0. When translating the guest machine code, you not only copy the host machine code for op_add123, but you have to put the number to be added *somewhere*.

Enter relocations. The file op.h contains the code to put the number at the correct point in the machine code.

Quoted 1 line

What is the fix?

You need to know the problem first. Why does dyngen produce that code. Which relocation is responsible for that invalid statement. Why was no name provided for it?

If you just comment it out, chances are that QEmu produces invalid code.

Hth,
Dscho