Skip to content
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/handle_macho_file_parse_result.c
Original file line number Diff line number Diff line change
Expand Up @@ -553,13 +553,16 @@ handle_macho_file_for_main_error_callback(
"a platform\n",
cb_info->dir_path);
} else {
request_result =
request_platform(cb_info->orig,
if (cb_info->orig != NULL) {
request_result = request_platform(cb_info->orig,
cb_info->tbd,
false,
stderr,
"The provided mach-o file does not have a "
"platform\n");
} else {
request_result = true;
}
}

if (!request_result) {
Expand Down
4 changes: 4 additions & 0 deletions src/macho_file_parse_load_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,10 @@ handle_targets_platform_and_uuid(
return handle_uuid_result;
}
} else if (arch != NULL) {
if (platform == TBD_PLATFORM_NONE) {
platform = tbd_ci_get_single_platform(info_in);
}

if (platform == TBD_PLATFORM_NONE) {
const bool should_continue =
call_callback(callback,
Expand Down
4 changes: 4 additions & 0 deletions src/macho_file_parse_symtab.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ loop_nlist_32(struct tbd_create_info *__notnull const info_in,
bool is_undef = false;
switch (type) {
case N_SECT:
case N_ABS:
case N_INDR:
if (options.ignore_exports) {
continue;
Expand Down Expand Up @@ -211,6 +212,7 @@ loop_nlist_32(struct tbd_create_info *__notnull const info_in,
bool is_undef = false;
switch (type) {
case N_SECT:
case N_ABS:
case N_INDR:
if (options.ignore_exports) {
continue;
Expand Down Expand Up @@ -294,6 +296,7 @@ loop_nlist_64(struct tbd_create_info *__notnull const info_in,
bool is_undef = false;
switch (type) {
case N_SECT:
case N_ABS:
case N_INDR:
if (options.ignore_exports) {
continue;
Expand Down Expand Up @@ -357,6 +360,7 @@ loop_nlist_64(struct tbd_create_info *__notnull const info_in,
bool is_undef = false;
switch (type) {
case N_SECT:
case N_ABS:
case N_INDR:
if (options.ignore_exports) {
continue;
Expand Down
2 changes: 2 additions & 0 deletions src/parse_macho_for_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ parse_macho_file_for_main(const struct parse_macho_for_main_args args) {

return E_PARSE_MACHO_FOR_MAIN_OTHER_ERROR;
}

tbd_for_main_handle_post_parse(args.tbd);

if (args.options.verify_write_path) {
verify_write_path(args.tbd);
Expand Down
75 changes: 45 additions & 30 deletions src/tbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1029,21 +1029,28 @@ tbd_ci_add_symbol_with_info(struct tbd_create_info *__notnull const info_in,
return E_TBD_CI_ADD_DATA_OK;
}

string += offset;

/*
* Starting from tbd-version v3, the underscore at the front of
* the class-name is to be removed.
*/

if (vers > TBD_VERSION_V2) {
string += 1;
lnmax -= 1;
}

length = strnlen(string, lnmax - offset);
if (likely(length != 0)) {
type = TBD_SYMBOL_TYPE_OBJC_CLASS;
/* Objective-C 1.0: .objc_class_name_Foo — keep as plain symbol */
if (string[0] == '.') {
length = strnlen(string, lnmax);
if (likely(length != 0)) {
type = TBD_SYMBOL_TYPE_NORMAL;
}
} else {
string += offset;

/*
* Starting from tbd-version v3, the underscore at the front of
* the class-name is to be removed.
*/

if (vers > TBD_VERSION_V2) {
string += 1;
lnmax -= 1;
}
length = strnlen(string, lnmax - offset);
if (likely(length != 0)) {
type = TBD_SYMBOL_TYPE_OBJC_CLASS;
}
}
} else if ((offset = is_objc_ivar_symbol(str, first)) != 0) {
if (!is_exported && !options.allow_priv_objc_ivar_syms) {
Expand Down Expand Up @@ -1156,24 +1163,32 @@ tbd_ci_add_symbol_with_info_and_len(
return E_TBD_CI_ADD_DATA_OK;
}

string += offset;
len -= offset;

/*
* Starting from tbd-version v3, the underscore at the front of
* the class-name is to be removed.
*/
if (str[0] == '.') {
/* Objective-C 1.0: emit full .objc_class_name_Foo as a plain symbol */
if (unlikely(len == 0)) {
return E_TBD_CI_ADD_DATA_OK;
}
type = TBD_SYMBOL_TYPE_NORMAL;
} else {
string += offset;
len -= offset;

/*
* Starting from tbd-version v3, the underscore at the front of
* the class-name is to be removed.
*/

if (vers > TBD_VERSION_V2) {
string += 1;
len -= 1;
}

if (vers > TBD_VERSION_V2) {
string += 1;
len -= 1;
}
if (unlikely(len == 0)) {
return E_TBD_CI_ADD_DATA_OK;
}

if (unlikely(len == 0)) {
return E_TBD_CI_ADD_DATA_OK;
type = TBD_SYMBOL_TYPE_OBJC_CLASS;
}

type = TBD_SYMBOL_TYPE_OBJC_CLASS;
} else if ((offset = is_objc_ivar_symbol(str, first)) != 0) {
if (!is_exported && !options.allow_priv_objc_ivar_syms) {
return E_TBD_CI_ADD_DATA_OK;
Expand Down