2

In the x86 SYSV (linux) calling convention, the first 6 arguments are passed in 64-bit registers. If these arguments are less than 64-bits, is the top of those registers guaranteed to be zeroed, or is it undefined? Is it different for 32-bit arguments and smaller arguments?

Michael Petch
  • 46,082
  • 8
  • 107
  • 198
Gavin S. Yancey
  • 1,216
  • 1
  • 13
  • 34
  • The linked duplicate is a different question, but the answer to it very thoroughly answers this question as well. Is it still a duplicate? – Gavin S. Yancey Jun 29 '18 at 20:22
  • 2
    It is close enough as a duplicate. It really is about whether the upper bits are guaranteed to be zero. The answer gives a detailed response that effectively boils down to the upper bits of the general purpose registers should be assumed to have garbage except with a `bool` type where bit 0 is the truth value and the upper 7 bits of that byte are guaranteed to be zero. All other bits no assumptions can be made. – Michael Petch Jun 29 '18 at 20:27
  • Summary: the upper 32 bits of 64-bit integer regs can hold garbage for 32-bit and narrower args. It *is* different for args even narrower than 32, see the linked duplicate. – Peter Cordes Oct 25 '20 at 03:26

0 Answers0