On 11-Oct-09, at 12:57 PM, Jean-Daniel Dupas wrote: Le 11 oct. 2009 à 17:51, Ben Haller a écrit : Hi! I'm moving an old project forward to Xcode 3.2 and building it for x86_64. I'm getting a mysterious link error:
"_vm_region", referenced from:
_SSCanWriteToAddress in SSCocoaExtra.o
Symbol(s) not found
I'm building against the 10.6 SDK with a min version of 10.6. The .m file imports <mach/mach.h>. This all used to build just fine on 10.5 (sorry, don't know what version of Xcode and what SDK exactly).
This problem is reminiscent of the problem discussed here:
http://www.mailinglistarchive.com/email@hidden/msg16823.html
But I'm just using Obj-C, no C++, and I'm on the 10.6 SDK, not the 10.4 SDK, so it's not exactly the same problem. Maybe it is again a bug in the header in the SDK, in which case a suggested workaround would be welcome; I don't understand Mach stuff very well, so I'm nervous to just go hacking my way in...
Any help? I'm happy to forward on any extra information needed, but I'm not sure what would be useful. Thanks!
vm_region() is part of the old vm API which was superseded by the mach_vm API. This function (as other vm_xxx function) is not 64 bit safe, so using it in a 64 bits code will probably failed, even if you managed to compile and link it. You will have to update this code before using it in a 64 bit product.
Aha. This is new to me. As usual with Mach-level stuff, I'm a bit mystified as to where to find documentation; all the stuff I found on vm_region did not mention that it has been superseded. Googling "mach_vm", on the other hand, mostly brings up stuff that I find very cryptic and unhelpful. Searching on such things in the ADC reference website never turns up anything useful. Where do people find out about things like this?
Anyhow, I've replaced my vm_region call with a mach_vm_region call, and made a few other changes based upon this:
My code now looks like this:
BOOL SSCanWriteToAddress(void *address) { vm_map_t task = mach_task_self(); mach_vm_address_t inOutAddress = (vm_address_t)address; mach_vm_size_t outSize = 0; vm_region_basic_info_data_64_t info; kern_return_t err; mach_port_t objectName = MACH_PORT_NULL; mach_msg_type_number_t count = VM_REGION_BASIC_INFO_COUNT_64;
err = mach_vm_region( task, &inOutAddress, &outSize, VM_REGION_BASIC_INFO_64, (vm_region_info_t)&info, &count, &objectName );
... }
It compiles and links without warnings against both the 10.4 and 10.6 SDKs, ppc through x86_64. I'm a bit worried that it may still not be correct, however, given my lack of knowledge of the new APIs. In particular, is mach_task_self() OK, or should it be changed to a new API as well?
Sorry for the clueless questions; as I say above, if someone can tell me where to find docs on these sorts of things, that would be most welcome. And thanks to Jean-Daniel for pointing me in the right direction.
Ben Haller Stick Software
|