Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#15636 closed task (invalid)

Document ABI conventions

Reported by: X512 Owned by: nobody
Priority: normal Milestone: Unscheduled
Component: System Version: R1/Development
Keywords: Cc:
Blocked By: Blocking:
Platform: All

Description (last modified by X512)

ABI conventions used by Haiku for each architecture (x86 gcc2, x86 gcc4+, x86_64) should be documented in some way (in web site, HaikuBook etc.).

At least following topics should be documented:

  • Preserved registers, including SIMD registers etc.
  • FPU state.
  • Passing arguments to function and return value.
  • Stack alignment including alignment origin.
  • Exception handling and stack unwinding.
  • Executable format.

If Haiku use some existing ABI, it should be referenced in documentation with Haiku specific changes, if any.

I tried to port some non C/C++ compiler (target ABI: x86 gcc4+) and make Haiku API bindings and experience various problems such as:

  • Structs passed by value (such as pattern) are stored on stack as is, but classes such as BPoint are passed by pointer.
  • BView::StrokeLine(BPoint, BPoint, pattern) is not working if stack is not aligned.

Change History (7)

comment:1 by X512, 5 years ago

Description: modified (diff)

comment:3 by X512, 5 years ago

Description: modified (diff)

comment:4 by waddlesplash, 5 years ago

Resolution: invalid
Status: newclosed

We do not do anything special here, Haiku just uses GCC (now 8) with no particular ABI customizations, so we are following the Itanium C++ ABI, which is already well documented: https://itanium-cxx-abi.github.io/cxx-abi/abi.html

Structs passed by value (such as pattern) are stored on stack as is, but classes such as BPoint are passed by pointer.

Yes, this is because BPoint is somehow not trivially copyable (I think it has an explicit copy constructor), so as per the Itanium ABI, it cannot be passed in registers.

BView::StrokeLine(BPoint, BPoint, pattern) is not working if stack is not aligned.

GCC assumes the stack is aligned as per the architecture's general requirements. This is also not Haiku specific at all.

in reply to:  4 comment:5 by X512, 5 years ago

Replying to waddlesplash:

We do not do anything special here, Haiku just uses GCC (now 8) with no particular ABI customizations, so we are following the Itanium C++ ABI, which is already well documented: https://itanium-cxx-abi.github.io/cxx-abi/abi.html

This should be mentioned in documentation.

in reply to:  4 comment:6 by X512, 5 years ago

Replying to waddlesplash:

GCC assumes the stack is aligned as per the architecture's general requirements. This is also not Haiku specific at all.

GCC2 seems to have different stack alignment.

comment:7 by pulkomandy, 5 years ago

Yes, gcc2 has smaller alignment because sse2 didn't exist back then.

Note: See TracTickets for help on using tickets.