diff options
author | Rich Felker <dalias@aerifal.cx> | 2019-05-10 20:56:19 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2019-05-10 20:56:19 -0400 |
commit | c8798ef974d21c338a7d8d874a402978ffc6168e (patch) | |
tree | 29598a3b6acda4e3f7b4ea4f94fa20233ade1738 /src/ipc/msgget.c | |
parent | 511d70738bce11a67219d0132ce725c323d00e4e (diff) | |
download | musl-c8798ef974d21c338a7d8d874a402978ffc6168e.tar.gz musl-c8798ef974d21c338a7d8d874a402978ffc6168e.tar.xz musl-c8798ef974d21c338a7d8d874a402978ffc6168e.zip |
fix regression in i386 inline syscall asm producing invalid code
commit 22e5bbd0deadcbd767864bd714e890b70e1fe1df inlined the i386 syscall mechanism, but wrongly assumed memory operands to the 5- and 6-argument syscall asm would be esp-based. however, nothing in the constraints prevented them from being ebx- or ebp-based, and in those cases, ebx and ebp could be clobbered before use of the memory operand was complete. in the 6-argument case, this prevented restoration of the original register values before the end of the asm block, breaking the asm contract since ebx and ebp are not marked as clobbered. (they can't be, because lots of compilers don't accept these registers in constraints or clobbers if PIC or frame pointer is enabled). doing this right is complicated by the fact that, after a single push, no operands which might be memory operands are usable. if they are esp-based, the value of esp has changed, rendering them invalid. introduce some new dances to load the registers. for the 5-arg case, push the operand that may be a memory operand first, and after that, it doesn't matter if the operand is invalid, since we'll just use the newly pushed value. for the 6-arg case, we need to put both operands in memory to begin with, like the old non-inline code prior to commit 22e5bbd0deadcbd767864bd714e890b70e1fe1df accepted, so that there's only one potentially memory-based operand to the asm. this can then be saved with a single push, and after that the values can be read off into the registers they're needed in. there's some size overhead, but still a lot less execution overhead than the old out-of-line code. doing it better depends on a modern compiler that lets you use ebx and ebp in asm constraints without restriction. the failure modes on compilers where this doesn't work are inconsistent and dangerous (on at least some gcc versions 4.x and earlier, wrong codegen!), so this is a delicate matter. it can be addressed later if needed.
Diffstat (limited to 'src/ipc/msgget.c')
0 files changed, 0 insertions, 0 deletions