diff --git a/src/handle_macho_file_parse_result.c b/src/handle_macho_file_parse_result.c index 989c433..824f0de 100644 --- a/src/handle_macho_file_parse_result.c +++ b/src/handle_macho_file_parse_result.c @@ -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) { diff --git a/src/macho_file_parse_load_commands.c b/src/macho_file_parse_load_commands.c index 6ff973f..ef3a44c 100644 --- a/src/macho_file_parse_load_commands.c +++ b/src/macho_file_parse_load_commands.c @@ -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, diff --git a/src/macho_file_parse_symtab.c b/src/macho_file_parse_symtab.c index 0a77210..151c893 100644 --- a/src/macho_file_parse_symtab.c +++ b/src/macho_file_parse_symtab.c @@ -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; @@ -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; @@ -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; @@ -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; diff --git a/src/parse_macho_for_main.c b/src/parse_macho_for_main.c index d50f33b..3673133 100644 --- a/src/parse_macho_for_main.c +++ b/src/parse_macho_for_main.c @@ -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); diff --git a/src/tbd.c b/src/tbd.c index 95d5419..0969607 100644 --- a/src/tbd.c +++ b/src/tbd.c @@ -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) { @@ -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;