kit

kit
git clone https://git.ryansepassi.com/git/kit.git
Log | Files | Refs | README

objedit.c (1158B)


      1 #include "objedit.h"
      2 
      3 int driver_name_in_list(KitSlice name, const char* const* list, uint32_t n) {
      4   uint32_t i;
      5   if (!name.len) return 0;
      6   for (i = 0; i < n; ++i) {
      7     if (list[i] && kit_slice_eq_cstr(name, list[i])) return 1;
      8   }
      9   return 0;
     10 }
     11 
     12 int driver_obj_id_in_set(KitObjSymbol id, const KitObjSymbol* arr, uint32_t n) {
     13   uint32_t i;
     14   for (i = 0; i < n; ++i) {
     15     if (arr[i] == id) return 1;
     16   }
     17   return 0;
     18 }
     19 
     20 /* Thin wrapper over kit_obj_reloc_live_symbols (the debug-aware reloc-target
     21  * scan now lives in libkit). libkit returns an exactly-sized array from the
     22  * same heap driver_free uses, so *cap_out is reported as *n_out to keep the
     23  * caller's driver_free(arr, cap * sizeof) contract valid. */
     24 int driver_obj_collect_reloc_target_syms(DriverEnv* env, const char* tool,
     25                                          KitObjFile* of, KitObjSymbol** out,
     26                                          uint32_t* n_out, uint32_t* cap_out) {
     27   KitContext ctx = driver_env_to_context(env);
     28   if (kit_obj_reloc_live_symbols(&ctx, of, out, n_out) != KIT_OK) {
     29     driver_errf(tool, "out of memory");
     30     return 1;
     31   }
     32   *cap_out = *n_out;
     33   return 0;
     34 }