void pre(const ComponentBackReference &c) override { if (c.ref_id) { if (c.ref_id >= num_ids) { invalid_index("back reference", c.ref_id); } } else { if (!contains(names, c.name)) { invalid_label("back reference", c.name); } } }
static bfelf64_sword private_symbol_by_index(struct bfelf_file_t *ef, bfelf64_word index, struct bfelf_sym **sym) { if (index >= ef->symnum) return invalid_index("index out of bounds"); *sym = &(ef->symtab[index]); return BFELF_SUCCESS; }
bfelf64_sword bfelf_file_get_segment(struct bfelf_file_t *ef, bfelf64_word index, struct bfelf_phdr **phdr) { if (!ef) return invalid_argument("ef == NULL"); if (!phdr) return invalid_argument("phdr == NULL"); if (index >= ef->num_loadable_segments) return invalid_index("index >= number of segments"); *phdr = ef->loadable_segments[index]; return BFELF_SUCCESS; }
void pre(const ComponentCondReference &c) override { switch (c.kind) { case ComponentCondReference::CONDITION_NUMBER: if (c.ref_id >= num_ids) { invalid_index("conditional reference", c.ref_id); } break; case ComponentCondReference::CONDITION_NAME: if (c.ref_name == "DEFINE") { // The string "DEFINE" is a special "always false" condition // used to define subroutines. break; } if (!contains(names, c.ref_name)) { invalid_label("conditional reference", c.ref_name); } break; case ComponentCondReference::CONDITION_ASSERTION: break; } }