Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
KPI change for GCC4.0 (was __cxa_guard_acquire / __cxa_guard_release)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

KPI change for GCC4.0 (was __cxa_guard_acquire / __cxa_guard_release)



Oh I think I know what it is. Sorry I was on the wrong track all together. This is a problem with in function static constructors. In gcc 4.0 we realised that they just don't work inside the kernel environment.

The problem is that these 2 functions are required to take and release a lock. Unfortunately it doesn't tell us what sort of lock to take and release. In the kernel that just isn't acceptable.

Hence gcc4.0 has a source incompatibility. It does not reliably implement in function static construction.

class com_somedomain_mystaticclass;

void com_somedomain_myclass::myfunc(void)
{
    static com_somedomain_mystaticclass stat;

    stat.someSideEffectFunc();
}

This code fragment will not work properly. The fix is reasonably easy. Move the static constructor to a global name space. This clarifies the odd semantic for construction. All static global constructors are run at load time, BEFORE any code in your kext could be run.

Godfrey

PS. I believe there is a release note to this effect, but it is probably buried deep in the gcc4.0 notes.

On 05/09/2005, at 10:42 , Thane Heninger wrote:

The kext is not an I/OKit kext.

Yes, it is an Xcode project.

On May 9, 2005, at 11:41 AM, Godfrey van der Linden wrote:


This means that there is something strange about your link line. Are you using an xcode project?
Is the target listed as an I/OKit kext if appropriate.


Godfrey

On 05/09/2005, at 10:26 , Thane Heninger wrote:


Trying to build our kext in Tiger, we ran into a snag with undefined symbols for ___cxa_guard_acquire and ___cxa_guard_release when we tried the kextload. Those symbols couldn't be found in any source text for the build. Searching the assembly code, we found the symbols as being near a line which had a statically included class instantiation.

That is a construction such as:

void func(void)
{
    ...
    static Class myClass;
    ...
}

Evidently the compiler generates these as a by-product of the class instantiation.

By moving the class instantiation out of the function, into global space, the symbols were not generated.

Also, the symbols weren't generated when we switched back to gcc 3.3 instead of the default 4.0.

Does this mean that we should be linking against something else, in order to include static classes inside functions and gcc 4.0?

Does it mean that we shouldn't use static classes in that manner in kext code?

Or does it mean that we should be using gcc 3.3 for our kexts?

Thanks,
Thane Heninger
Iomega

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-drivers mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40apple.com


This email sent to email@hidden





_______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-drivers mailing list (email@hidden) Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


_______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-drivers mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >__cxa_guard_acquire / __cxa_guard_release (From: Thane Heninger <email@hidden>)
 >Re: __cxa_guard_acquire / __cxa_guard_release (From: Godfrey van der Linden <email@hidden>)
 >Re: __cxa_guard_acquire / __cxa_guard_release (From: Thane Heninger <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.