From: Dave H. <dhy...@gm...> - 2010-11-01 15:21:13
|
Hi Paul, On Mon, Nov 1, 2010 at 3:29 AM, Paul Solomon <pa...@cl...> wrote: > I have done a whole lot more experimenting to try and see what is going on > here. It appears that the issue goes away if you specify the -msoft-float > option. To try and get to the bottom of this I have had a look at the > resultant assembly outputs from the same C code with different options. > > What appears to be happening is the if the code tried to dereference a float > that is not word aligned in memory then it causes an instruction error at > runtime if the code is compiled to use the hardware FPU. If it is using the > software FPU emulation then there is no such problem. The simple solution is to not use unaligned floats. Any code that relies on unaligned floats is generally buggy. It simply is not guaranteed to word on all architectures. Some architectures will cause similar behaviour for just trying to access unaligned 32-bit data. ARM also doesn't support reading unaligned 32-bit data, but because so much code is bad, they added a handler to fix things up and make it look like the the right thing happened whenever the illegal operation takes places. These fixups are extremely expensive in terms of how many cycles it takes for them to execute. In ARM land, there is a proc entry that you can use to monitor and even cause programs to abort in a similar fashion to what you're seeing. See the file "unaligned-memory-access.txt" in the linux Documentation directory, and also see arm/mem_alignment. -- Dave Hylands Shuswap, BC, Canada http://www.DaveHylands.com/ |