Hi,
I have a piece of code that results in invalid assembly. This is just an
example, as I suspect a general issue with the assembler, due to the
SIGBUS and SIGILL signals I receive in a larger codebase.
I use binutils 2.23.1 and gcc 4.7.2. The function that serves as an
example is the gcc-builtin __sync_bool_compare_and_swap. When I put a
printf statement in front of it, different assembly is generated which
works correctly. The second (normal) part of the code results in
assembly where a specific register (b2) is being reused, although it is
already overwritten by the result of a comparison. This results in an
infinite loop, as __sync_bool_compare_and_swap always returns a value
indicating that the swap failed.
In the incorrect assembly, at address 0xed0, register b2 is reused,
showing a behavior like 'return (*val == (*val == current));'.
I am not sure whether this issue should be directed to binutils or gcc;
please advice.
Hopefully this can be fixed.