ldid stable port information

Package: ldid
Version: 1.0.476
Revision: 2

Maintainer: Matthias Ringwald
Source: http://www.telesphoreo.org/export/613/trunk/data/ldid/ldid-%v.tgz
Source-MD5: 734bdf1ba4ddead9077e845436948df1
BuildDepends: fink (>= 0.24.12)
PatchFile: %n.patch
PatchFile-MD5: 23172db77e7158c1c36497d81d571113

CompileScript: <<
g++ -I . -o util/ldid{,.cpp} -x c util/{lookup2,sha1}.c
<<

InstallScript: <<
mkdir -p %i/bin
cp util/ldid %i/bin
mkdir -p %i/share/doc/ldid
head -n 36 util/ldid.cpp > %i/share/doc/ldid/COPYING
<<

DescPort: <<
The patch fixes the PPC version -> http://www.telesphoreo.org/ticket/158
<<

Description: Pseudo-codesign Mach-O files
License: BSD

ldid stable port .patch

Only in ldid-1.0.476-patched/util/: ldid
diff -u ldid-1.0.476/util/ldid.cpp ldid-1.0.476-patched/util/ldid.cpp
--- ldid-1.0.476/util/ldid.cpp 2008-09-15 11:12:42.000000000 +0200
+++ ldid-1.0.476-patched/util/ldid.cpp 2009-06-03 07:50:59.000000000 +0200
@@ -184,6 +184,22 @@
return Swap(static_cast(value));
}

+ uint16_t SwapToBig(uint16_t value) const {
+ return swapped_ ? value : Swap_(value);
+ }
+
+ uint32_t SwapToBig(uint32_t value) const {
+ return swapped_ ? value : Swap_(value);
+ }
+
+ int16_t SwapToBig(int16_t value) const {
+ return SwapToBig(static_cast(value));
+ }
+
+ int32_t SwapToBig(int32_t value) const {
+ return SwapToBig(static_cast(value));
+ }
+
Framework(const char *framework_path) :
swapped_(false)
{
@@ -404,8 +420,8 @@
if (size == _not(size_t))
size = framework.GetSize();

- switch (framework->cputype) {
- case 12: switch (framework->cpusubtype) {
+ switch (framework.Swap(framework->cputype)) {
+ case 12: switch (framework.Swap(framework->cpusubtype)) {
case 0: arch = "arm"; break;
case 6: arch = "armv6"; break;
default: arch = NULL; break;
@@ -488,11 +504,11 @@
uint8_t *blob = top + data;
struct SuperBlob *super = reinterpret_cast(blob);

- for (size_t index(0); index != Swap(super->count); ++index)
+ for (size_t index(0); index != framework.SwapToBig(super->count); ++index)
if (Swap(super->index[index].type) == CSSLOT_ENTITLEMENTS) {
- uint32_t begin = Swap(super->index[index].offset);
+ uint32_t begin = framework.SwapToBig(super->index[index].offset);
struct Blob *entitlements = reinterpret_cast(blob + begin);
- fwrite(entitlements + 1, 1, Swap(entitlements->length) - sizeof(struct Blob), stdout);
+ fwrite(entitlements + 1, 1, framework.SwapToBig(entitlements->length) - sizeof(struct Blob), stdout);
}
}

@@ -506,13 +522,13 @@
uint8_t *blob = top + data;
struct SuperBlob *super = reinterpret_cast(blob);

- for (size_t index(0); index != Swap(super->count); ++index)
+ for (size_t index(0); index != framework.SwapToBig(super->count); ++index)
if (Swap(super->index[index].type) == CSSLOT_CODEDIRECTORY) {
- uint32_t begin = Swap(super->index[index].offset);
+ uint32_t begin = framework.SwapToBig(super->index[index].offset);
struct CodeDirectory *directory = reinterpret_cast(blob + begin);

- uint8_t (*hashes)[20] = reinterpret_cast(blob + begin + Swap(directory->hashOffset));
- uint32_t pages = Swap(directory->nCodeSlots);
+ uint8_t (*hashes)[20] = reinterpret_cast(blob + begin + framework.SwapToBig(directory->hashOffset));
+ uint32_t pages = framework.SwapToBig(directory->nCodeSlots);

if (pages != 1)
for (size_t i = 0; i != pages - 1; ++i)
@@ -531,34 +547,34 @@
uint8_t *top = reinterpret_cast(framework.GetBase());
uint8_t *blob = top + data;
struct SuperBlob *super = reinterpret_cast(blob);
- super->blob.magic = Swap(CSMAGIC_EMBEDDED_SIGNATURE);
+ super->blob.magic = framework.SwapToBig(CSMAGIC_EMBEDDED_SIGNATURE);

uint32_t count = xmld == NULL ? 2 : 3;
uint32_t offset = sizeof(struct SuperBlob) + count * sizeof(struct BlobIndex);

- super->index[0].type = Swap(CSSLOT_CODEDIRECTORY);
- super->index[0].offset = Swap(offset);
+ super->index[0].type = framework.SwapToBig(CSSLOT_CODEDIRECTORY);
+ super->index[0].offset = framework.SwapToBig(offset);

uint32_t begin = offset;
struct CodeDirectory *directory = reinterpret_cast(blob + begin);
offset += sizeof(struct CodeDirectory);

- directory->blob.magic = Swap(CSMAGIC_CODEDIRECTORY);
- directory->version = Swap(0x00020001);
- directory->flags = Swap(0);
- directory->codeLimit = Swap(data);
+ directory->blob.magic = framework.SwapToBig(CSMAGIC_CODEDIRECTORY);
+ directory->version = framework.SwapToBig(0x00020001);
+ directory->flags = framework.SwapToBig(0);
+ directory->codeLimit = framework.SwapToBig(data);
directory->hashSize = 0x14;
directory->hashType = 0x01;
directory->spare1 = 0x00;
directory->pageSize = 0x0c;
- directory->spare2 = Swap(0);
+ directory->spare2 = framework.SwapToBig(0);

- directory->identOffset = Swap(offset - begin);
+ directory->identOffset = framework.SwapToBig(offset - begin);
strcpy(reinterpret_cast(blob + offset), base);
offset += strlen(base) + 1;

uint32_t special = xmld == NULL ? CSSLOT_REQUIREMENTS : CSSLOT_ENTITLEMENTS;
- directory->nSpecialSlots = Swap(special);
+ directory->nSpecialSlots = framework.SwapToBig(special);

uint8_t (*hashes)[20] = reinterpret_cast(blob + offset);
memset(hashes, 0, sizeof(*hashes) * special);
@@ -567,7 +583,7 @@
hashes += special;

uint32_t pages = (data + 0x1000 - 1) / 0x1000;
- directory->nCodeSlots = Swap(pages);
+ directory->nCodeSlots = framework.SwapToBig(pages);

if (pages != 1)
for (size_t i = 0; i != pages - 1; ++i)
@@ -575,19 +591,19 @@
if (pages != 0)
sha1(hashes[pages - 1], top + 0x1000 * (pages - 1), ((data - 1) % 0x1000) + 1);

- directory->hashOffset = Swap(offset - begin);
+ directory->hashOffset = framework.SwapToBig(offset - begin);
offset += sizeof(*hashes) * pages;
- directory->blob.length = Swap(offset - begin);
+ directory->blob.length = framework.SwapToBig(offset - begin);

- super->index[1].type = Swap(CSSLOT_REQUIREMENTS);
- super->index[1].offset = Swap(offset);
+ super->index[1].type = framework.SwapToBig(CSSLOT_REQUIREMENTS);
+ super->index[1].offset = framework.SwapToBig(offset);

memcpy(blob + offset, "\xfa\xde\x0c\x01\x00\x00\x00\x0c\x00\x00\x00\x00", 0xc);
offset += 0xc;

if (xmld != NULL) {
- super->index[2].type = Swap(CSSLOT_ENTITLEMENTS);
- super->index[2].offset = Swap(offset);
+ super->index[2].type = framework.SwapToBig(CSSLOT_ENTITLEMENTS);
+ super->index[2].offset = framework.SwapToBig(offset);

uint32_t begin = offset;
struct Blob *entitlements = reinterpret_cast(blob + begin);
@@ -596,21 +612,21 @@
memcpy(blob + offset, xmld, xmls);
offset += xmls;

- entitlements->magic = Swap(CSMAGIC_ENTITLEMENTS);
- entitlements->length = Swap(offset - begin);
+ entitlements->magic = framework.SwapToBig(CSMAGIC_ENTITLEMENTS);
+ entitlements->length = framework.SwapToBig(offset - begin);
}

for (size_t index(0); index != count; ++index) {
- uint32_t type = Swap(super->index[index].type);
+ uint32_t type = framework.SwapToBig(super->index[index].type);
if (type != 0 && type <= special) {
- uint32_t offset = Swap(super->index[index].offset);
+ uint32_t offset = framework.SwapToBig(super->index[index].offset);
struct Blob *local = (struct Blob *) (blob + offset);
- sha1((uint8_t *) (hashes - type), (uint8_t *) local, Swap(local->length));
+ sha1((uint8_t *) (hashes - type), (uint8_t *) local, framework.SwapToBig(local->length));
}
}

- super->count = Swap(count);
- super->blob.length = Swap(offset);
+ super->count = framework.SwapToBig(count);
+ super->blob.length = framework.SwapToBig(offset);

if (offset > size) {
fprintf(stderr, "offset (%u) > size (%u)\n", offset, size);
Only in ldid-1.0.476-patched/util/: ldid.dSYM

ldid _unstable_ port .patch