Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
darkstart wrote:I've heard of it, just never actually used it before.
That's a mildly ignorant remark, since everyone using a computer has used two's complement (and don't start getting smart on me about only using floats or 60 year old computers...).
I think the DWORD PTR [%esp+12] is a pointer to the cr0 register.
Err... I'm not sure whether this is another display of total ignorance of the machine you are working with, or just plain stupidity (or both). Really, a memory pointer pointing to a register???
darkstart wrote:I've heard of it, just never actually used it before.
That's a mildly ignorant remark, since everyone using a computer has used two's complement (and don't start getting smart on me about only using floats or 60 year old computers...).
I meant I haven't used it in day to day applications programming.
jal wrote:
darkstart wrote:I think the DWORD PTR [%esp+12] is a pointer to the cr0 register.
Err... I'm not sure whether this is another display of total ignorance of the machine you are working with, or just plain stupidity (or both). Really, a memory pointer pointing to a register???
JAL
My bad, my thinking sounds retarded looking at it that way. I'm just going to paste the whole function from GAS, it might help:
I'd say that is impossible. No doubt it is chocking on the ret, as you do something with page dirs, the new page dir will not have a valid page for the return address?
It will choke on the instruction after the cr0 load if paging got turned on and the tables are broken (or turned off and things aren't identity mapped) - both give undefined results on real hardware. In this case I expect it to pagefault on the page holding the code.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Combuster wrote:It will choke on the instruction after the cr0 load if paging got turned on and the tables are broken (or turned off and things aren't identity mapped) - both give undefined results on real hardware. In this case I expect it to pagefault on the page holding the code.
Yes of course, stupid me, the code itself will not be reachable anymore...
Combuster wrote:It will choke on the instruction after the cr0 load if paging got turned on and the tables are broken (or turned off and things aren't identity mapped) - both give undefined results on real hardware. In this case I expect it to pagefault on the page holding the code.
So then, would this mean that however the cross-compiler is compiling the code is doing something wrong? I'm going to try a different GCC and binutils version and see how that changes things.
The compiler is *never* wrong. All the GBs of source that is linux and its apps compiles and runs off that compiler without problems. And you really expect that you do something that causes the compiler to mess up on you?
Blaming the compiler is a way of saying "My code is wrong but I stubbornly refuse to admit that I made a mistake"
In other words: your paging code is wrong.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Combuster wrote:It will choke on the instruction after the cr0 load if paging got turned on and the tables are broken (or turned off and things aren't identity mapped) - both give undefined results on real hardware. In this case I expect it to pagefault on the page holding the code.
So then, would this mean that however the cross-compiler is compiling the code is doing something wrong? I'm going to try a different GCC and binutils version and see how that changes things.
No. Stop blaming the toolkit and blame your own code. All my code works fine on the toolchain you mentioned.
darkstart wrote:Then how does that explain the fact that my distro's compiler's code works fine and when I use the cross-compiler, it dies??
Your code relies on the behaviour of your distro's compiler. It has a bug that happens to be unmasked by whatever the cross-compiler is doing differently. For example the code could be accidentally overflowing a buffer, but because of the way compiler A orders the code it doesn't matter, but compiler B is orders the code in such a way that the overflow does matter and causes a crash.
But if you really are still convinced that it's a gcc bug (99% chance is isn't) then you should find out what the cross-compiler is doing differently, reduce it down to a simple test case and submit a bug report. Superficial changes in the way the assembly is output (like what you mentioned in the first post) won't have an effect on the problem and can be disregarded.