Fixed crash in MemoryUtils::ResolveSymbol() on OS X Lion (10.7) (bug 4951, r=dvander).
This commit is contained in:
parent
e8fbe0f36c
commit
4c878c4963
@ -12,6 +12,8 @@ compiler['CDEFINES'].append('SM_LOGIC')
|
|||||||
|
|
||||||
if AMBuild.target['platform'] == 'linux':
|
if AMBuild.target['platform'] == 'linux':
|
||||||
compiler['POSTLINKFLAGS'].append('-lpthread')
|
compiler['POSTLINKFLAGS'].append('-lpthread')
|
||||||
|
if AMBuild.target['platform'] == 'darwin':
|
||||||
|
compiler['POSTLINKFLAGS'].extend(['-framework', 'CoreServices'])
|
||||||
|
|
||||||
extension = AMBuild.AddJob('sourcemod.logic')
|
extension = AMBuild.AddJob('sourcemod.logic')
|
||||||
binary = Cpp.LibraryBuilder('sourcemod.logic', AMBuild, extension, compiler)
|
binary = Cpp.LibraryBuilder('sourcemod.logic', AMBuild, extension, compiler)
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* vim: set ts=4 sw=4 tw=99 noet :
|
* vim: set ts=4 sw=4 tw=99 noet :
|
||||||
* =============================================================================
|
* =============================================================================
|
||||||
* SourceMod
|
* SourceMod
|
||||||
* Copyright (C) 2004-2010 AlliedModders LLC. All rights reserved.
|
* Copyright (C) 2004-2011 AlliedModders LLC. All rights reserved.
|
||||||
* =============================================================================
|
* =============================================================================
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it under
|
* This program is free software; you can redistribute it and/or modify it under
|
||||||
@ -36,11 +36,26 @@
|
|||||||
#define PAGE_SIZE 4096
|
#define PAGE_SIZE 4096
|
||||||
#define PAGE_ALIGN_UP(x) ((x + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1))
|
#define PAGE_ALIGN_UP(x) ((x + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PLATFORM_APPLE
|
#ifdef PLATFORM_APPLE
|
||||||
|
#include <AvailabilityMacros.h>
|
||||||
|
#include <mach/task.h>
|
||||||
#include <mach-o/dyld_images.h>
|
#include <mach-o/dyld_images.h>
|
||||||
#include <mach-o/loader.h>
|
#include <mach-o/loader.h>
|
||||||
#include <mach-o/nlist.h>
|
#include <mach-o/nlist.h>
|
||||||
#endif
|
|
||||||
|
/* Define things from 10.6 SDK for older SDKs */
|
||||||
|
#ifndef MAC_OS_X_VERSION_10_6
|
||||||
|
struct task_dyld_info
|
||||||
|
{
|
||||||
|
mach_vm_address_t all_image_info_addr;
|
||||||
|
mach_vm_size_t all_image_info_size;
|
||||||
|
};
|
||||||
|
typedef struct task_dyld_info task_dyld_info_data_t;
|
||||||
|
#define TASK_DYLD_INFO 17
|
||||||
|
#define TASK_DYLD_INFO_COUNT (sizeof(task_dyld_info_data_t) / sizeof(natural_t))
|
||||||
|
#endif // MAC_OS_X_VERSION_10_6
|
||||||
|
#endif // PLATFORM_APPLE
|
||||||
|
|
||||||
MemoryUtils g_MemUtils;
|
MemoryUtils g_MemUtils;
|
||||||
|
|
||||||
@ -48,12 +63,25 @@ MemoryUtils::MemoryUtils()
|
|||||||
{
|
{
|
||||||
#ifdef PLATFORM_APPLE
|
#ifdef PLATFORM_APPLE
|
||||||
|
|
||||||
|
Gestalt(gestaltSystemVersionMajor, &m_OSXMajor);
|
||||||
|
Gestalt(gestaltSystemVersionMinor, &m_OSXMinor);
|
||||||
|
|
||||||
/* Get pointer to struct that describes all loaded mach-o images in process */
|
/* Get pointer to struct that describes all loaded mach-o images in process */
|
||||||
|
if (m_OSXMajor == 10 && m_OSXMinor >= 6 || m_OSXMajor > 10)
|
||||||
|
{
|
||||||
|
task_dyld_info_data_t dyld_info;
|
||||||
|
mach_msg_type_number_t count = TASK_DYLD_INFO_COUNT;
|
||||||
|
task_info(mach_task_self(), TASK_DYLD_INFO, (task_info_t)&dyld_info, &count);
|
||||||
|
m_ImageList = (struct dyld_all_image_infos *)dyld_info.all_image_info_addr;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
struct nlist list[2];
|
struct nlist list[2];
|
||||||
memset(list, 0, sizeof(list));
|
memset(list, 0, sizeof(list));
|
||||||
list[0].n_un.n_name = (char *)"_dyld_all_image_infos";
|
list[0].n_un.n_name = (char *)"_dyld_all_image_infos";
|
||||||
nlist("/usr/lib/dyld", list);
|
nlist("/usr/lib/dyld", list);
|
||||||
m_ImageList = (struct dyld_all_image_infos *)list[0].n_value;
|
m_ImageList = (struct dyld_all_image_infos *)list[0].n_value;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* vim: set ts=4 sw=4 tw=99 noet :
|
* vim: set ts=4 sw=4 tw=99 noet :
|
||||||
* =============================================================================
|
* =============================================================================
|
||||||
* SourceMod
|
* SourceMod
|
||||||
* Copyright (C) 2004-2010 AlliedModders LLC. All rights reserved.
|
* Copyright (C) 2004-2011 AlliedModders LLC. All rights reserved.
|
||||||
* =============================================================================
|
* =============================================================================
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it under
|
* This program is free software; you can redistribute it and/or modify it under
|
||||||
@ -41,6 +41,10 @@ using namespace SourceHook;
|
|||||||
|
|
||||||
using namespace SourceMod;
|
using namespace SourceMod;
|
||||||
|
|
||||||
|
#ifdef PLATFORM_APPLE
|
||||||
|
#include <CoreServices/CoreServices.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
struct DynLibInfo
|
struct DynLibInfo
|
||||||
{
|
{
|
||||||
void *baseAddress;
|
void *baseAddress;
|
||||||
@ -75,6 +79,8 @@ private:
|
|||||||
CVector<LibSymbolTable *> m_SymTables;
|
CVector<LibSymbolTable *> m_SymTables;
|
||||||
#ifdef PLATFORM_APPLE
|
#ifdef PLATFORM_APPLE
|
||||||
struct dyld_all_image_infos *m_ImageList;
|
struct dyld_all_image_infos *m_ImageList;
|
||||||
|
SInt32 m_OSXMajor;
|
||||||
|
SInt32 m_OSXMinor;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
@ -33,12 +33,12 @@
|
|||||||
#include <sm_platform.h>
|
#include <sm_platform.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "common_logic.h"
|
#include "common_logic.h"
|
||||||
#include "ThreadSupport.h"
|
|
||||||
#include "TextParsers.h"
|
#include "TextParsers.h"
|
||||||
#include "Profiler.h"
|
#include "Profiler.h"
|
||||||
#include "sm_crc32.h"
|
#include "sm_crc32.h"
|
||||||
#include "MemoryUtils.h"
|
#include "MemoryUtils.h"
|
||||||
#include "stringutil.h"
|
#include "stringutil.h"
|
||||||
|
#include "ThreadSupport.h"
|
||||||
#include "Translator.h"
|
#include "Translator.h"
|
||||||
#include "GameConfigs.h"
|
#include "GameConfigs.h"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user