Re: [PATCH] Fix that different function breakpoints are set at same pc address (PR gdb/12703)

Richard Earnshaw
2011-07-01T08:59:27Z

On 29/06/11 11:00, Yao Qi wrote:
> On 06/29/2011 04:47 PM, Terry Guo wrote:
>> Hi,
>>
>> First if you look at the generated binary code, I thought it is a valid case. After performing the function test, it will fall into function bar which is a normal function. At least my case can run correctly on QEMU. It is very likely for people to write program in assembly code like:
>>
>> main:
>> b test
>>
>> test:
>> movs r5, #10
>> bar:
>> push.......
>> .........
>>
>
> We are lucky here GCC places bar next to function test physically, but
> gcc may also place function test and bar in other layout, like
>
> main:
> b test
>
> bar:
> push ...
>
> test:
> moves r5, #10
>
> After test, processor will run some instructions that we don't know.
> IMO, it is incorrect.
>

Which is one of the reasons why GCC has the option -fno-toplevel-reorder
to prevent such reordering.

R.