Am Sun, 05 Jan 2014 08:26:16 +0000 schrieb "Timo Sintonen" <t.sinto...@luukku.com>:
> On Thursday, 2 January 2014 at 06:54:18 UTC, Timo Sintonen wrote: > > I have fond one thing that confuses me. I have defined > > ARM_EABI_UNWINDER but gcc/deh.d has checks for > > GNU_ARM_EABI_Unwinder. Is this what I should have? When using > > this I get an error in line 116: static assert ( 8 == 4 ) is > > false. > > I think that this code in gcc/deh.d line 105 may not get it right > > // To place 'obj' behing unwindHeader. > enum UNWIND_PAD = (Phase1Info.sizeof + Object.sizeof) > % _Unwind_Exception.alignof; > > static if (UNWIND_PAD > 0) > byte[UNWIND_PAD] _pad; > > Object obj; > > // The exception object must be directly behind unwindHeader. > // (See build_exception_object.) > static assert(unwindHeader.offsetof - obj.offsetof == > obj.sizeof); > > // The generic exception header > _Unwind_Exception unwindHeader; > > > Its purpose seems to add padding so that obj is aligned at the > end of align block just before unwindHeader. > > Fitst, if I uderstand correct, the amount to pad should be align > - modulo, not modulo. The current code happens to work anyway if > align is 8 and modulo is 0 or 4 which is usually the case. > > Second, When I define GNU_ARM_EABI_Unwinder, the assertion fails. > Nothing changes in calculation of UNWIND_PAD but the alignment is > not correct and the assert fails. With this define the whole size > of struct if 96 bytes and 40 bytes without. Something is aligned > differently such a way that this calculation cannot find it. I > can not print offsetof with pragma msg so I do not know what > happens. > I should really start pushing my local ARM changes upstream. Here's a fix for the EABI unwinder: https://github.com/jpf91/GDC/commit/262e432e95cbe31a6764cd337f64022a56011eda IIRC I also thought the code in gcc/deh.d wasn't correct. As it wouldn't work for the eabi unwinder anyway (no Phase1Info member) I didn't investigate that though.