Skip to content
  • Philippe Gerum's avatar
    lib/cobalt: modechk: switch to shared object, drop cxa wrappers · 8c82454c
    Philippe Gerum authored
    Dynamically linked code from shared libraries which may reference mode
    checking wrappers cannot depend on symbols which are only visible from
    the static link phase, such as those defined by the libmodechk.a
    library. Otherwise, unresolved references to symbols from libmodechk.a
    may exist in shared objects such as libcopperplate.so.
    
    Unfortunately, we can't interpose on the cxa* API from a dynamic
    library, since the latter would create references to "real"
    __cxa_acquire/release/abort() routines, which are not available from
    plain C builds since only libstdc++ defines them.
    
    Providing placeholders for the cxa* API calls in a dynamic object is
    not an option either, since that would create a dependency on the link
    order between libmodechk and libstdc++ for pulling the actual symbols
    instead of the dummy ones, which is not acceptable. Besides, relying
    on LD_DYNAMIC_WEAK is fragile, unpractical, and won't work in secured
    execution mode.
    
    To work around this chicken-and-egg issue, make libmodechk a shared
    object, and drop mode checking for the cxa* API for now. We'll revisit
    the issue of enabling back the cxa* API later.
    8c82454c