Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update all the way to version 818.2 #6

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions interposable.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_objc_release
10 changes: 2 additions & 8 deletions libobjc.order
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
__objc_init
_environ_init
_tls_init
_lock_init
_runtime_init
_recursive_mutex_init
_exception_init
_map_images
Expand All @@ -17,12 +17,8 @@ _rtp_init
_gc_fixup_barrier_stubs
__objc_update_stubs_in_mach_header
_sel_init
_sel_lock
___sel_registerName
__objc_search_builtins
__ZNK8objc_opt13objc_selopt_t3getEPKc
__ZNK8objc_opt13objc_selopt_t4hashEPKc
_sel_unlock
_sel_registerName
_arr_init
__ZN4objc8DenseMapIP11objc_objectmLb1ENS_12DenseMapInfoIS2_EENS3_ImEEE4initEj
Expand Down Expand Up @@ -98,6 +94,7 @@ __ZNSt3__122__merge_move_constructIRN8method_t16SortBySELAddressEN13method_list_
__ZNSt3__119__merge_move_assignIRN8method_t16SortBySELAddressEPS1_S4_N13method_list_t15method_iteratorEEEvT0_S7_T1_S8_T2_T_
_NXPtrIsEqual
__getObjc2CategoryList
__getObjc2CategoryList2
__Z29addUnattachedCategoryForClassP10category_tP7class_tP12_header_info
__Z16remethodizeClassP7class_t
__Z11flushCachesP7class_t
Expand Down Expand Up @@ -145,7 +142,6 @@ __objc_insert_tagged_isa
_objc_msgSend_fixup
__objc_fixupMessageRef
_objc_msgSend
__class_lookupMethodAndLoadCache3
_lookUpMethod
_prepareForMethodLookup
__class_initialize
Expand Down Expand Up @@ -332,7 +328,6 @@ _objc_atomicCompareAndSwapGlobalBarrier
_sel_getUid
__ZN12_GLOBAL__N_119AutoreleasePoolPage11tls_deallocEPv
__ZN12_GLOBAL__N_119AutoreleasePoolPage4killEv
__objc_constructOrFree
_object_cxxConstruct
_object_cxxConstructFromClass
__class_hasCxxStructors
Expand All @@ -341,7 +336,6 @@ __class_getMethodNoSuper
_object_cxxDestruct
_object_cxxDestructFromClass
_class_copyIvarList
__object_addExternalReference_rr
__objc_rootRetain_slow
__objc_rootReleaseWasZero_slow
_object_copy
Expand Down
116 changes: 49 additions & 67 deletions markgc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,11 @@
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/errno.h>
#include <os/overflow.h>
#include <mach-o/fat.h>
#include <mach-o/arch.h>
#include <mach-o/loader.h>

// from "objc-private.h"
// masks for objc_image_info.flags
#define OBJC_IMAGE_SUPPORTS_GC (1<<1)

// Some OS X SDKs don't define these.
#ifndef CPU_TYPE_ARM
#define CPU_TYPE_ARM ((cpu_type_t) 12)
Expand Down Expand Up @@ -378,58 +375,48 @@ bool sectnameEquals(const char *lhs, const char *rhs)


template <typename P>
void dosect(uint8_t *start, macho_section<P> *sect, bool isOldABI, bool isOSX)
void dosect(uint8_t *start, macho_section<P> *sect)
{
if (debug) printf("section %.16s from segment %.16s\n",
sect->sectname(), sect->segname());

if (isOSX) {
// Add "supports GC" flag to objc image info
if ((segnameStartsWith(sect->segname(), "__DATA") &&
sectnameEquals(sect->sectname(), "__objc_imageinfo")) ||
(segnameEquals(sect->segname(), "__OBJC") &&
sectnameEquals(sect->sectname(), "__image_info")))
{
imageinfo *ii = (imageinfo*)(start + sect->offset());
P::E::set32(ii->flags, P::E::get32(ii->flags) | OBJC_IMAGE_SUPPORTS_GC);
if (debug) printf("added GC support flag\n");
}
// Strip S_MOD_INIT/TERM_FUNC_POINTERS. We don't want dyld to call
// our init funcs because it is too late, and we don't want anyone to
// call our term funcs ever.
if (segnameStartsWith(sect->segname(), "__DATA") &&
sectnameEquals(sect->sectname(), "__mod_init_func"))
{
// section type 0 is S_REGULAR
sect->set_flags(sect->flags() & ~SECTION_TYPE);
sect->set_sectname("__objc_init_func");
if (debug) printf("disabled __mod_init_func section\n");
}

if (isOldABI) {
// Keep init funcs because libSystem doesn't call _objc_init().
} else {
// Strip S_MOD_INIT/TERM_FUNC_POINTERS. We don't want dyld to call
// our init funcs because it is too late, and we don't want anyone to
// call our term funcs ever.
if (segnameStartsWith(sect->segname(), "__DATA") &&
sectnameEquals(sect->sectname(), "__mod_init_func"))
{
// section type 0 is S_REGULAR
sect->set_flags(sect->flags() & ~SECTION_TYPE);
sect->set_sectname("__objc_init_func");
if (debug) printf("disabled __mod_init_func section\n");
}
if (segnameStartsWith(sect->segname(), "__DATA") &&
sectnameEquals(sect->sectname(), "__mod_term_func"))
{
// section type 0 is S_REGULAR
sect->set_flags(sect->flags() & ~SECTION_TYPE);
sect->set_sectname("__objc_term_func");
if (debug) printf("disabled __mod_term_func section\n");
}
if (segnameStartsWith(sect->segname(), "__TEXT") &&
sectnameEquals(sect->sectname(), "__init_offsets"))
{
// section type 0 is S_REGULAR
sect->set_flags(sect->flags() & ~SECTION_TYPE);
sect->set_sectname("__objc_init_offs");
if (debug) printf("disabled __mod_init_func section\n");
}
if (segnameStartsWith(sect->segname(), "__DATA") &&
sectnameEquals(sect->sectname(), "__mod_term_func"))
{
// section type 0 is S_REGULAR
sect->set_flags(sect->flags() & ~SECTION_TYPE);
sect->set_sectname("__objc_term_func");
if (debug) printf("disabled __mod_term_func section\n");
}
}

template <typename P>
void doseg(uint8_t *start, macho_segment_command<P> *seg,
bool isOldABI, bool isOSX)
void doseg(uint8_t *start, macho_segment_command<P> *seg)
{
if (debug) printf("segment name: %.16s, nsects %u\n",
seg->segname(), seg->nsects());
macho_section<P> *sect = (macho_section<P> *)(seg + 1);
for (uint32_t i = 0; i < seg->nsects(); ++i) {
dosect(start, &sect[i], isOldABI, isOSX);
dosect(start, &sect[i]);
}
}

Expand All @@ -438,32 +425,12 @@ template<typename P>
bool parse_macho(uint8_t *buffer)
{
macho_header<P>* mh = (macho_header<P>*)buffer;
uint8_t *cmds;

bool isOldABI = false;
bool isOSX = false;
cmds = (uint8_t *)(mh + 1);
for (uint32_t c = 0; c < mh->ncmds(); c++) {
macho_load_command<P>* cmd = (macho_load_command<P>*)cmds;
cmds += cmd->cmdsize();
if (cmd->cmd() == LC_SEGMENT || cmd->cmd() == LC_SEGMENT_64) {
macho_segment_command<P>* seg = (macho_segment_command<P>*)cmd;
if (segnameEquals(seg->segname(), "__OBJC")) isOldABI = true;
}
else if (cmd->cmd() == LC_VERSION_MIN_MACOSX) {
isOSX = true;
}
}

if (debug) printf("ABI=%s, OS=%s\n",
isOldABI ? "old" : "new", isOSX ? "osx" : "ios");

cmds = (uint8_t *)(mh + 1);
uint8_t *cmds = (uint8_t *)(mh + 1);
for (uint32_t c = 0; c < mh->ncmds(); c++) {
macho_load_command<P>* cmd = (macho_load_command<P>*)cmds;
cmds += cmd->cmdsize();
if (cmd->cmd() == LC_SEGMENT || cmd->cmd() == LC_SEGMENT_64) {
doseg(buffer, (macho_segment_command<P>*)cmd, isOldABI, isOSX);
doseg(buffer, (macho_segment_command<P>*)cmd);
}
}

Expand Down Expand Up @@ -518,15 +485,30 @@ bool parse_fat(uint8_t *buffer, size_t size)
fat_magic = OSSwapBigToHostInt32(fh->magic);
fat_nfat_arch = OSSwapBigToHostInt32(fh->nfat_arch);

if (size < (sizeof(struct fat_header) + fat_nfat_arch * sizeof(struct fat_arch))) {
size_t fat_arch_size;
// fat_nfat_arch * sizeof(struct fat_arch) + sizeof(struct fat_header)
if (os_mul_and_add_overflow(fat_nfat_arch, sizeof(struct fat_arch),
sizeof(struct fat_header), &fat_arch_size))
{
printf("too many fat archs\n");
return false;
}
if (size < fat_arch_size) {
printf("file is too small\n");
return false;
}

archs = (struct fat_arch *)(buffer + sizeof(struct fat_header));

/* Special case hidden CPU_TYPE_ARM64 */
if (size >= (sizeof(struct fat_header) + (fat_nfat_arch + 1) * sizeof(struct fat_arch))) {
size_t fat_arch_plus_one_size;
if (os_add_overflow(fat_arch_size, sizeof(struct fat_arch),
&fat_arch_plus_one_size))
{
printf("too many fat archs\n");
return false;
}
if (size >= fat_arch_plus_one_size) {
if (fat_nfat_arch > 0
&& OSSwapBigToHostInt32(archs[fat_nfat_arch].cputype) == CPU_TYPE_ARM64) {
fat_nfat_arch++;
Expand All @@ -547,7 +529,7 @@ bool parse_fat(uint8_t *buffer, size_t size)
arch_cputype, arch_cpusubtype);

/* Check that slice data is after all fat headers and archs */
if (arch_offset < (sizeof(struct fat_header) + fat_nfat_arch * sizeof(struct fat_arch))) {
if (arch_offset < fat_arch_size) {
printf("file is badly formed\n");
return false;
}
Expand Down
Empty file modified objc.sln
100644 → 100755
Empty file.
Binary file removed objc.suo
Binary file not shown.
Loading