Mail Archives: djgpp/1995/09/29/00:56:38
>>>>> "ALAN" == ALAN L HIGHTOWER <alh AT engr DOT engr DOT uark DOT edu> writes:
ALAN> But, as pointed out, this method can fail with static
ALAN> functions and with optimizations turned on.
I maintain that it will work even with optimization turned on,
although it won't work with static functions because gcc reorders
those. So you'd have to make all locked functions be non-static to be
safe. Of course, if you throw in an assert to make sure the begin/end
sentinels really are on both sides of the locked code, then everything
should be fine.
ALAN> Would it be possible since most functions are long word
ALAN> aligned and padded with NOP's to take the associated
ALAN> function pointer and scan along long word boundaries till
ALAN> you hit an opcode for either a ret or iret?
Scanning for a "ret" opcode wouldn't work. That opcode might appear
as part of an operand for another instruction within the function.
As for alignment, functions are 16-byte aligned to make the i486
prefetch buffers happy. .align 4 means align modulo 2**4 bytes in
djgpp's gas (and align modulo 4 bytes in some other gas's, like
Linux!) However, in an older djgpp I showed that those symbols don't
end up aligned like they should when the final executable is linked!
The same problem happened under Linux...I haven't checked it recently.
-Mat
- Raw text -