@@ -21,11 +21,11 @@ along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
2121#include " parsedef.h"
2222#include " filedefs.h"
2323
24-
2524#include " handler.h"
2625#include " scriptpt.h"
2726#include " variable.h"
2827#include " statemnt.h"
28+ #include " uuid.h"
2929
3030#include " deploy.h"
3131
@@ -894,6 +894,16 @@ struct version_min_command {
894894 uint32_t sdk; /* X.Y.Z is encoded in nibbles xxxx.yy.zz */
895895};
896896
897+ /*
898+ * The uuid load command contains a single 128-bit unique random number that
899+ * identifies an object produced by the static link editor.
900+ */
901+ struct uuid_command {
902+ uint32_t cmd; /* LC_UUID */
903+ uint32_t cmdsize; /* sizeof(struct uuid_command) */
904+ uint8_t uuid[16 ]; /* the 128-bit uuid */
905+ };
906+
897907// //////////////////////////////////////////////////////////////////////////////
898908
899909struct mach_32bit
@@ -1333,7 +1343,8 @@ template<typename T> bool MCDeployToMacOSXMainBody(const MCDeployParameters& p_p
13331343 t_old_linkedit_offset = t_misc_segment -> fileoff;
13341344
13351345 // Now go through, updating the offsets for all load commands after
1336- // and including linkedit.
1346+ // and including linkedit. We also update the uuid load command here,
1347+ // if one has been provided.
13371348 typename T::sfield t_file_delta, t_address_delta;
13381349 t_file_delta = (t_project_segment -> fileoff + t_project_size) - t_old_linkedit_offset;
13391350 t_address_delta = t_file_delta;
@@ -1369,9 +1380,25 @@ template<typename T> bool MCDeployToMacOSXMainBody(const MCDeployParameters& p_p
13691380 case LC_DATA_IN_CODE :
13701381 relocate_function_starts_command ((linkedit_data_command *)t_commands[i], t_file_delta, t_address_delta);
13711382 break ;
1372-
1373- // These commands have no file offsets
1383+
1384+ // Update the uuid, if one has been provided.
13741385 case LC_UUID :
1386+ if (!MCStringIsEmpty (p_params.uuid ))
1387+ {
1388+ MCAutoStringRefAsCString t_uuid_cstring;
1389+ MCUuid t_uuid;
1390+ if (t_uuid_cstring.Lock (p_params.uuid ) &&
1391+ MCUuidFromCString (*t_uuid_cstring, t_uuid))
1392+ {
1393+ uuid_command *t_uuid_cmd = (uuid_command *)t_commands[i];
1394+ MCUuidToBytes (t_uuid, t_uuid_cmd->uuid );
1395+ }
1396+ else
1397+ t_success = MCDeployThrow (kMCDeployErrorInvalidUuid );
1398+ }
1399+ break ;
1400+
1401+ // These commands have no file offsets
13751402 case LC_THREAD :
13761403 case LC_UNIXTHREAD :
13771404 case LC_LOAD_DYLIB :
0 commit comments