After I'm done with supporting Sun symbol versioning in the currently
versioned GCC runtime libraries, I've started investigating versioning
the remaining unversioned ones.

One of them is libobjc.so.4.  To start, I've looked at the global symbols
in the library with

$ nm -Pgn libobjc.so.4 | awk '$2 !~ /U/ {print $1}'

on i386-pc-solaris2.11.  Here's what I found:

__bss_start                             generated by ld
__gnu_objc_personality_v0               EH support (public)
__objc_add_class_to_hash                runtime.h (internal)
__objc_class_links_resolved             runtime.h (internal)
__objc_class_name_NXConstantString      objc-act.c (public)
__objc_class_name_Object                objc-act.c? (public)
__objc_class_name_Protocol              objc-act.c (public)
__objc_close_thread_system              thr.h (internal)
                                        __objc_fini_thread_system
__objc_condition_allocate               thr.h (internal)
__objc_condition_broadcast              thr.h (internal)
__objc_condition_deallocate             thr.h (internal)
__objc_condition_signal                 thr.h (internal)
__objc_condition_wait                   thr.h (internal)
__objc_dangling_categories              init.c (unused?)
__objc_exec_class                       objc-act.c (public?)
__objc_force_linking                    init.c (internal?)
__objc_generate_gc_type_description     runtime.h (internal)
__objc_get_forward_imp                  sendmsg.c (internal?)
__objc_init_class_tables                runtime.h (internal)
__objc_init_dispatch_tables             runtime.h (internal)
__objc_init_selector_tables             runtime.h (internal)
__objc_init_thread_system               runtime.h (internal)
                                        thr.h (internal)
__objc_install_premature_dtable         runtime.h (internal)
__objc_is_multi_threaded                thr.c (internal)
__objc_linking                          linking.m (internal)
__objc_msg_forward                      objc-api.h (public)
__objc_msg_forward2                     objc-api.h (public)
__objc_mutex_allocate                   thr.h (internal)
__objc_mutex_deallocate                 thr.h (internal)
__objc_mutex_lock                       thr.h (internal)
__objc_mutex_trylock                    thr.h (internal)
__objc_mutex_unlock                     thr.h (internal)
__objc_object_alloc                     objects.c (internal)
__objc_object_copy                      objects.c (internal)
__objc_object_dispose                   objects.c (internal)
__objc_print_dtable_stats               runtime.h (internal)
__objc_read_nbyte_uint                  archive.c (internal)
__objc_read_nbyte_ulong                 archive.c (internal)
__objc_register_instance_methods_to_class runtime.h (internal)
__objc_register_selectors_from_class    runtime.h (internal)
__objc_register_selectors_from_list     runtime.h (internal)
__objc_resolve_class_links              runtime.h (internal)
__objc_responds_to                      runtime.h (internal)
__objc_runtime_mutex                    runtime.h (internal)
__objc_runtime_threads_alive            runtime.h (internal)
__objc_selector_max_index               runtime.h (internal)
__objc_sparse2_id                       sarray.h (internal)
__objc_thread_detach                    thr.h (internal)
__objc_thread_exit                      thr.h (internal)
__objc_thread_exit_status               thr.h (internal)
__objc_thread_get_data                  thr.h (internal)
__objc_thread_get_priority              thr.h (internal)
__objc_thread_id                        thr.h (internal)
__objc_thread_set_data                  thr.h (internal)
__objc_thread_set_priority              thr.h (internal)
__objc_thread_yield                     thr.h (internal)
__objc_uninstalled_dtable               sendmsg.c (internal)
__objc_update_dispatch_table_for_class  sendmsg.c (internal)
__objc_write_class                      archive.c (internal)
__objc_write_object                     archive.c (internal)
__objc_write_selector                   archive.c (internal)
__sel_register_typed_name               selector.c (internal)
_edata                                  generated by ld
_end                                    generated by ld
_etext                                  generated by ld
_fini                                   generated by ld
_init                                   generated by ld
_lib_version                            imported from values-*.o
_objc_atomic_malloc                     objc-api.h (public)
_objc_became_multi_threaded             thr.c (public, but undeclared)
_objc_calloc                            objc-api.h (public)
_objc_free                              objc-api.h (public)
_objc_load_callback                     objc-api.h (public)
_objc_lookup_class                      objc-api.h (public)
_objc_malloc                            objc-api.h (public)
_objc_object_alloc                      objc-api.h (public)
_objc_object_copy                       objc-api.h (public)
_objc_object_dispose                    objc-api.h (public)
_objc_realloc                           objc-api.h (public)
_objc_unexpected_exception              objc-api.h (public)
_objc_valloc                            objc-api.h (public)
class_add_method_list                   runtime.h (internal)
class_create_instance                   objc-api.h (public)
class_get_class_method                  objc-api.h (public)
class_get_instance_method               objc-api.h (public)
class_ivar_set_gcinvisible              objc-api.h (public)
class_pose_as                           objc-api.h (public)
get_imp                                 objc-api.h (public)
idxsize                                 sarray.c (internal)
method_get_first_argument               encoding.h (public)
method_get_next_argument                encoding.h (public)
method_get_nth_argument                 encoding.h (public)
method_get_number_of_arguments          encoding.h (public)
method_get_sizeof_arguments             encoding.h (public)
narrays                                 sarray.c (internal)
nbuckets                                sarray.c (internal)
nil_method                              nil_method.c (internal?)
nindices                                sarray.c (internal)
objc_aligned_size                       encoding.h (public)
objc_alignof_type                       encoding.h (public)
objc_atomic_malloc                      objc-api.h (public)
objc_calloc                             objc-api.h (public)
objc_close_typed_stream                 typedstream.h (public)
objc_condition_allocate                 thr.h (public)
objc_condition_broadcast                thr.h (public)
objc_condition_deallocate               thr.h (public)
objc_condition_signal                   thr.h (public)
objc_condition_wait                     thr.h (public)
objc_end_of_typed_stream                typedstream.h (public)
objc_error                              objc-api.h (public)
objc_exception_throw                    exception.c (public)
                                        objc-act.c (public?)
objc_flush_typed_stream                 typedstream.h (public)
objc_free                               objc-api.h (public)
objc_get_class                          objc-api.h (public)
objc_get_meta_class                     class.c (public?)
objc_get_stream_class_version           typedstream.h (public)
objc_get_type_qualifiers                encoding.h (public)
objc_get_uninstalled_dtable             objc-api.h (public)
objc_hash_add                           hash.h (public)
objc_hash_delete                        hash.h (public)
objc_hash_is_key_in_hash                hash.h (public)
objc_hash_new                           hash.h (public)
objc_hash_next                          hash.h (public)
objc_hash_remove                        hash.h (public)
objc_hash_value_for_key                 hash.h (public)
objc_layout_finish_structure            encoding.h (public)
objc_layout_structure                   encoding.h (public)
objc_layout_structure_get_info          encoding.h (public)
objc_layout_structure_next_member       encoding.h (public)
objc_lookup_class                       objc-api.h (public)
objc_malloc                             objc-api.h (public)
objc_msg_lookup                         objc.h (public)
objc_msg_lookup_super                   objc-api.h (public)
objc_msg_sendv                          objc-api.h (public)
objc_mutex_allocate                     thr.h (public)
objc_mutex_deallocate                   thr.h (public)
objc_mutex_lock                         thr.h (public)
objc_mutex_trylock                      thr.h (public)
objc_mutex_unlock                       thr.h (public)
objc_next_class                         objc-api.h (public)
objc_open_typed_stream                  typedstream.h (public)
objc_open_typed_stream_for_file         typedstream.h (public)
objc_promoted_size                      encoding.h (public)
objc_read_array                         typedstream.h (public)
objc_read_char                          archive.c (public?)
objc_read_int                           archive.c (public?)
objc_read_long                          archive.c (public?)
objc_read_object                        typedstream.h (public)
objc_read_selector                      archive.c (public?)
objc_read_short                         archive.c (public?)
objc_read_string                        archive.c (public?)
objc_read_type                          typedstream.h (public)
objc_read_types                         typedstream.h (public)
objc_read_unsigned_char                 archive.c (public?)
objc_read_unsigned_int                  archive.c (public?)
objc_read_unsigned_long                 archive.c (public?)
objc_read_unsigned_short                archive.c (public?)
objc_realloc                            objc-api.h (public)
objc_set_error_handler                  objc-api.h (public)
objc_set_thread_callback                thr.h (public)
objc_sizeof_type                        encoding.h (public)
objc_skip_argspec                       encoding.h (public)
objc_skip_offset                        encoding.h (public)
objc_skip_type_qualifiers               encoding.h (public)
objc_skip_typespec                      encoding.h (public)
objc_thread_add                         thr.h (public)
objc_thread_detach                      thr.h (public)
objc_thread_exit                        thr.h (public)
objc_thread_get_data                    thr.h (public)
objc_thread_get_priority                thr.h (public)
objc_thread_id                          thr.h (public)
objc_thread_remove                      thr.h (public)
objc_thread_set_data                    thr.h (public)
objc_thread_set_priority                thr.h (public)
objc_thread_yield                       thr.h (public)
objc_valloc                             objc-api.h (public)
objc_verror                             objc-api.h (public)
objc_write_array                        typedstream.h (public)
objc_write_char                         archive.c (public?)
objc_write_int                          archive.c (public?)
objc_write_long                         archive.c (public?)
objc_write_object                       typedstream.h (public)
objc_write_object_reference             typedstream.h (public)
objc_write_root_object                  typedstream.h (public)
objc_write_selector                     archive.c (public?)
objc_write_short                        archive.c (public?)
objc_write_string                       archive.c (public?)
objc_write_string_atomic                archive.c (public?)
objc_write_type                         typedstream.h (public)
objc_write_types                        typedstream.h (public)
objc_write_unsigned_char                archive.c (public?)
objc_write_unsigned_int                 archive.c (public?)
objc_write_unsigned_long                archive.c (public?)
objc_write_unsigned_short               archive.c (public?)
object_copy                             objc-api.h (public)
object_dispose                          objc-api.h (public)
sarray_at_put                           sarray.h (public)
sarray_at_put_safe                      sarray.h (public)
sarray_free                             sarray.h (public)
sarray_lazy_copy                        sarray.h (public)
sarray_new                              sarray.h (public)
sarray_realloc                          sarray.h (public)
sarray_remove_garbage                   sarray.h (public)
search_for_method_in_list               runtime.h (internal)
sel_get_any_typed_uid                   objc-api.h (public)
sel_get_any_uid                         objc-api.h (public)
sel_get_name                            objc-api.h (public)
sel_get_type                            objc-api.h (public)
sel_get_typed_uid                       objc-api.h (public)
sel_get_uid                             objc-api.h (public)
sel_is_mapped                           objc-api.h (public)
sel_register_name                       objc-api.h (public)
sel_register_typed_name                 objc-api.h (public)
sel_types_match                         selector.c (private?)

Apart from the compiler/linker generated stuff, we're left with several
groups of functions:

* Those documented in public/installed header files and not mentioned as
  internal/implementation details there.  They are marked as public in
  the list above.

* Those documented in public/installed header files, but marked as
  internal/implemention details there, or only documented in runtime.h,
  which isn't installed and thus not public.  Marked as internal above.

* Some implementation details which are not user-callable, but need to
  be exported nonetheless (like the stuff from gcc/objc/objc-act.c
  above, plus __gnu_objc_personality_v0, needed for exception handling
  support).  I'm not sure about __objc_exec_class, though: it would be
  best if someone knowledgable about the GNU Objective-C implementation
  could augment the draft mapfile below with an appropriate
  documentation.  I've moved those to a separate OBJCABI_1.0 (probably
  better named GOBCJABI_1.0) version, since they are not part of the
  public interface.

* Several global variables are obviously implementation details, and
  thus not part of the ABI (e.g. idxsize, narrays, nbuckets, nindices).

* A couple of unclear cases:

** _objc_became_multi_threaded is defined in thr.c.  From the comment,
   it is intended to be public, but is missing from thr.h.  Should
   probably just be added to the header.

** nil_method is defined in nil_method.c.  I cannot say for sure if this
   should be public.

** objc_get_meta_class is defined in class.c.  Again, I don't know if
   this should be part of the ABI.

** There are a number of objc_read_* and objc_write_* functions in
   archive.c, but they are missing from typedstream.h.  I suppose they
   are just implementation details of the public functions, but would
   like to get confirmation for that.

** sel_types_matches is defined in selector.c.  I've no idea if this
   should be public.

My current findings are documented in the draft mapfile below.  I've
used this to rebuild libobjc.so.2 and rerun make check-objc successfully
on i386-pc-solaris2.11, so it seems to be basically sound.  Before
proceeding with a proper implementation within a new GCC symbol
versioning `framework', I'd like to get confirmation that this is
sensible.  Especially, I need answers to my questions about unclear
functions above.

Is there any public documentation of the libobjc API available anywhere?
libobjc/README mentions one that has never become available.

It would probably wise to check this against users of libobjc like
GNUStep.

        Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University


# FIXME:
# * Naming, as always.
# * API documentation?
# * Check users like GNUStep.

# GNU libobjc.so public interface.
OBJC_2.0 {
  global:
    # <objc/encoding.h>
    method_get_first_argument;
    method_get_next_argument;
    method_get_nth_argument;
    method_get_number_of_arguments;
    method_get_sizeof_arguments;
    objc_aligned_size;
    objc_alignof_type;
    objc_get_type_qualifiers;
    objc_layout_finish_structure;
    objc_layout_structure;
    objc_layout_structure_get_info;
    objc_layout_structure_next_member;
    objc_promoted_size;
    objc_sizeof_type;
    objc_skip_argspec;
    objc_skip_offset;
    objc_skip_type_qualifiers;
    objc_skip_typespec;

    # <objc/hash.h>
    objc_hash_add;
    objc_hash_delete;
    objc_hash_is_key_in_hash;
    objc_hash_new;
    objc_hash_next;
    objc_hash_remove;
    objc_hash_value_for_key;

    # <objc/objc-api.h>
    __objc_msg_forward;
    __objc_msg_forward2;
    _objc_atomic_malloc;
    _objc_calloc;
    _objc_free;
    _objc_load_callback;
    _objc_lookup_class;
    _objc_malloc;
    _objc_object_alloc;
    _objc_object_copy;
    _objc_object_dispose;
    _objc_realloc;
    _objc_unexpected_exception;
    _objc_valloc;
    class_create_instance;
    class_get_class_method;
    class_get_instance_method;
    class_ivar_set_gcinvisible;
    class_pose_as;
    get_imp;
    objc_atomic_malloc;
    objc_calloc;
    objc_error;
    objc_free;
    objc_get_class;
    # FIXME: Currently undeclared.
    objc_get_meta_class;
    objc_get_uninstalled_dtable;
    objc_lookup_class;
    objc_malloc;
    objc_msg_lookup_super;
    objc_msg_sendv;
    objc_next_class;
    objc_realloc;
    objc_set_error_handler;
    objc_valloc;
    objc_verror;
    object_copy;
    object_dispose;
    sel_get_any_typed_uid;
    sel_get_any_uid;
    sel_get_name;
    sel_get_type;
    sel_get_typed_uid;
    sel_get_uid;
    sel_is_mapped;
    sel_register_name;
    sel_register_typed_name;
    # FIXME: Currently undeclared, private?
    sel_types_match;

    # <objc/objc.h>
    objc_hash_add;
    objc_hash_delete;
    objc_hash_is_key_in_hash;
    objc_hash_new;
    objc_hash_next;
    objc_hash_remove;
    objc_hash_value_for_key;
    objc_msg_lookup;

    # <objc/sarray.h>
    sarray_at_put;
    sarray_at_put_safe;
    sarray_free;
    sarray_lazy_copy;
    sarray_new;
    sarray_realloc;
    sarray_remove_garbage;

    # <objc/thr.h>
    # FIXME: Currently undeclared.
    _objc_became_multi_threaded;
    objc_condition_allocate;
    objc_condition_broadcast;
    objc_condition_deallocate;
    objc_condition_signal;
    objc_condition_wait;
    objc_mutex_allocate;
    objc_mutex_deallocate;
    objc_mutex_lock;
    objc_mutex_trylock;
    objc_mutex_unlock;
    objc_set_thread_callback;
    objc_thread_add;
    objc_thread_detach;
    objc_thread_exit;
    objc_thread_get_data;
    objc_thread_get_priority;
    objc_thread_id;
    objc_thread_remove;
    objc_thread_set_data;
    objc_thread_set_priority;
    objc_thread_yield;

    # <objc/typedstream.h>
    objc_close_typed_stream;
    objc_end_of_typed_stream;
    objc_flush_typed_stream;
    objc_get_stream_class_version;
    objc_open_typed_stream;
    objc_open_typed_stream_for_file;
    objc_read_array;
    objc_read_object;
    objc_read_type;
    objc_read_types;
    objc_write_array;
    objc_write_object;
    objc_write_object_reference;
    objc_write_root_object;
    objc_write_type;
    objc_write_types;
    # FIXME: Currently undeclared to end of block.
    # Perhaps rather private?
    objc_read_char;
    objc_read_int;
    objc_read_long;
    objc_read_selector;
    objc_read_short;
    objc_read_string;
    objc_read_unsigned_char;
    objc_read_unsigned_int;
    objc_read_unsigned_long;
    objc_read_unsigned_short;
    objc_write_char;
    objc_write_int;
    objc_write_long;
    objc_write_selector;
    objc_write_short;
    objc_write_string;
    objc_write_string_atomic;
    objc_write_unsigned_char;
    objc_write_unsigned_int;
    objc_write_unsigned_long;
    objc_write_unsigned_short;
  local:
    *;
};

# Private stuff for the GNU Objective-C implementation.
# FIXME: More than this?
# FIXME: Explain uses.
OBJCABI_1.0 {
  global:
    # Objective-C  personality function for exception handling.
    __gnu_objc_personality_v0;
    # FIXME: Cf. objc/objc-act.c.
    __objc_class_name_NXConstantString;
    __objc_class_name_Object;
    __objc_class_name_Protocol;
    # FIXME: Cf. objc/objc-act.c.
    __objc_exec_class;
    # FIXME: Cf. objc/objc-act.c.
    objc_exception_throw;
};

Reply via email to