printf(format, ##__VA_ARGS__); \
})
-char *childobj;
+static char *childobj;
enum loglevel {
DEBUG,
* Helper functions
******************/
-char *status_str(enum status status)
+static char *status_str(enum status status)
{
switch(status) {
case NEW:
return NULL;
}
-int is_rela_section(struct section *sec)
+static int is_rela_section(struct section *sec)
{
return (sec->sh.sh_type == SHT_RELA);
}
-int is_text_section(struct section *sec)
+static int is_text_section(struct section *sec)
{
return (sec->sh.sh_type == SHT_PROGBITS &&
(sec->sh.sh_flags & SHF_EXECINSTR));
}
-int is_debug_section(struct section *sec)
+static int is_debug_section(struct section *sec)
{
char *name;
if (is_rela_section(sec))
return !strncmp(name, ".debug_", 7);
}
-struct section *find_section_by_index(struct list_head *list, unsigned int index)
+static struct section *find_section_by_index(struct list_head *list,
+ unsigned int index)
{
struct section *sec;
return NULL;
}
-struct section *find_section_by_name(struct list_head *list, const char *name)
+static struct section *find_section_by_name(struct list_head *list,
+ const char *name)
{
struct section *sec;
return NULL;
}
-struct symbol *find_symbol_by_index(struct list_head *list, size_t index)
+static struct symbol *find_symbol_by_index(struct list_head *list,
+ size_t index)
{
struct symbol *sym;
return NULL;
}
-struct symbol *find_symbol_by_name(struct list_head *list, const char *name)
+static struct symbol *find_symbol_by_name(struct list_head *list,
+ const char *name)
{
struct symbol *sym;
}
/* returns the offset of the string in the string table */
-int offset_of_string(struct list_head *list, char *name)
+static int offset_of_string(struct list_head *list, char *name)
{
struct string *string;
int index = 0;
return index;
}
-void rela_insn(struct section *sec, struct rela *rela, struct insn *insn)
+static void rela_insn(struct section *sec, struct rela *rela,
+ struct insn *insn)
{
unsigned long insn_addr, start, end, rela_addr;
/*************
* Functions
* **********/
-void xsplice_create_rela_list(struct xsplice_elf *kelf, struct section *sec)
+static void xsplice_create_rela_list(struct xsplice_elf *kelf,
+ struct section *sec)
{
int rela_nr, index = 0, skip = 0;
struct rela *rela;
/* create reverse link from base section to this rela section */
sec->base->rela = sec;
-
+
rela_nr = sec->sh.sh_size / sec->sh.sh_entsize;
log_debug("\n=== rela list for %s (%d entries) ===\n",
}
}
-void xsplice_create_section_list(struct xsplice_elf *kelf)
+static void xsplice_create_section_list(struct xsplice_elf *kelf)
{
Elf_Scn *scn = NULL;
struct section *sec;
ERROR("expected NULL");
}
-int is_bundleable(struct symbol *sym)
+static int is_bundleable(struct symbol *sym)
{
if (sym->type == STT_FUNC &&
!strncmp(sym->sec->name, ".text.",6) &&
return 0;
}
-void xsplice_create_symbol_list(struct xsplice_elf *kelf)
+static void xsplice_create_symbol_list(struct xsplice_elf *kelf)
{
struct section *symtab;
struct symbol *sym;
}
-struct xsplice_elf *xsplice_elf_open(const char *name)
+static struct xsplice_elf *xsplice_elf_open(const char *name)
{
Elf *elf;
int fd;
return kelf;
}
-void xsplice_compare_elf_headers(Elf *elf1, Elf *elf2)
+static void xsplice_compare_elf_headers(Elf *elf1, Elf *elf2)
{
GElf_Ehdr eh1, eh2;
DIFF_FATAL("ELF headers differ");
}
-void xsplice_check_program_headers(Elf *elf)
+static void xsplice_check_program_headers(Elf *elf)
{
size_t ph_nr;
DIFF_FATAL("ELF contains program header");
}
-void xsplice_mark_grouped_sections(struct xsplice_elf *kelf)
+static void xsplice_mark_grouped_sections(struct xsplice_elf *kelf)
{
struct section *groupsec, *sec;
unsigned int *data, *end;
* section symbol in this case so that the relas can be properly correlated and
* so that the existing object/function in vmlinux can be linked to.
*/
-void xsplice_replace_sections_syms(struct xsplice_elf *kelf)
+static void xsplice_replace_sections_syms(struct xsplice_elf *kelf)
{
struct section *sec;
struct rela *rela;
* with a different trailing number. Rename any mangled patched functions to
* match their base counterparts.
*/
-void xsplice_rename_mangled_functions(struct xsplice_elf *base,
- struct xsplice_elf *patched)
+static void xsplice_rename_mangled_functions(struct xsplice_elf *base,
+ struct xsplice_elf *patched)
{
struct symbol *sym, *basesym;
char name[256], *origname;
return 1;
}
-void xsplice_correlate_sections(struct list_head *seclist1, struct list_head *seclist2)
+static void xsplice_correlate_sections(struct list_head *seclist1,
+ struct list_head *seclist2)
{
struct section *sec1, *sec2;
}
}
-void xsplice_correlate_symbols(struct list_head *symlist1, struct list_head *symlist2)
+static void xsplice_correlate_symbols(struct list_head *symlist1,
+ struct list_head *symlist2)
{
struct symbol *sym1, *sym2;
}
}
-void xsplice_correlate_elfs(struct xsplice_elf *kelf1, struct xsplice_elf *kelf2)
+static void xsplice_correlate_elfs(struct xsplice_elf *kelf1,
+ struct xsplice_elf *kelf2)
{
xsplice_correlate_sections(&kelf1->sections, &kelf2->sections);
xsplice_correlate_symbols(&kelf1->symbols, &kelf2->symbols);
* in the base object.
*/
static struct symbol *xsplice_find_static_twin(struct section *sec,
- struct symbol *sym)
+ struct symbol *sym)
{
struct rela *rela;
struct symbol *basesym;
* can arbitrarily change. Try to rename the patched version of the symbol to
* match the base version and then correlate them.
*/
-void xsplice_correlate_static_local_variables(struct xsplice_elf *base,
- struct xsplice_elf *patched)
+static void xsplice_correlate_static_local_variables(struct xsplice_elf *base,
+ struct xsplice_elf *patched)
{
struct symbol *sym, *basesym, *tmpsym;
struct section *tmpsec, *sec;
}
}
-int rela_equal(struct rela *rela1, struct rela *rela2)
+static int rela_equal(struct rela *rela1, struct rela *rela2)
{
log_debug("Comparing rela %s with %s\n", rela1->sym->name, rela2->sym->name);
if (rela1->type != rela2->type ||
return !strcmp(rela1->sym->name, rela2->sym->name);
}
-void xsplice_compare_correlated_rela_section(struct section *sec)
+static void xsplice_compare_correlated_rela_section(struct section *sec)
{
struct rela *rela1, *rela2 = NULL;
sec->status = SAME;
}
-void xsplice_compare_correlated_nonrela_section(struct section *sec)
+static void xsplice_compare_correlated_nonrela_section(struct section *sec)
{
struct section *sec1 = sec, *sec2 = sec->twin;
sec->status = SAME;
}
-void xsplice_compare_correlated_section(struct section *sec)
+static void xsplice_compare_correlated_section(struct section *sec)
{
struct section *sec1 = sec, *sec2 = sec->twin;
log_debug("section %s has changed\n", sec->name);
}
-void xsplice_compare_sections(struct list_head *seclist)
+static void xsplice_compare_sections(struct list_head *seclist)
{
struct section *sec;
}
}
-void xsplice_compare_correlated_symbol(struct symbol *sym)
+static void xsplice_compare_correlated_symbol(struct symbol *sym)
{
struct symbol *sym1 = sym, *sym2 = sym->twin;
*/
}
-void xsplice_compare_symbols(struct list_head *symlist)
+static void xsplice_compare_symbols(struct list_head *symlist)
{
struct symbol *sym;
}
}
-void xsplice_compare_correlated_elements(struct xsplice_elf *kelf)
+static void xsplice_compare_correlated_elements(struct xsplice_elf *kelf)
{
/* lists are already correlated at this point */
log_debug("Compare sections\n");
* help cause an immediate and obvious issue when a logic error leads to
* accessing data that is not intended to be accessed past a particular point.
*/
-void xsplice_elf_teardown(struct xsplice_elf *kelf)
+static void xsplice_elf_teardown(struct xsplice_elf *kelf)
{
struct section *sec, *safesec;
struct symbol *sym, *safesym;
INIT_LIST_HEAD(&kelf->symbols);
}
-void xsplice_elf_free(struct xsplice_elf *kelf)
+static void xsplice_elf_free(struct xsplice_elf *kelf)
{
elf_end(kelf->elf);
close(kelf->fd);
free(kelf);
}
-void xsplice_mark_ignored_sections_same(struct xsplice_elf *kelf)
+static void xsplice_mark_ignored_sections_same(struct xsplice_elf *kelf)
{
struct section *sec;
struct symbol *sym;
}
}
-void xsplice_mark_constant_labels_same(struct xsplice_elf *kelf)
+static void xsplice_mark_constant_labels_same(struct xsplice_elf *kelf)
{
struct symbol *sym;
}
}
-int bug_frames_0_group_size(struct xsplice_elf *kelf, int offset) { return 8; }
-int bug_frames_1_group_size(struct xsplice_elf *kelf, int offset) { return 8; }
-int bug_frames_2_group_size(struct xsplice_elf *kelf, int offset) { return 8; }
-int bug_frames_3_group_size(struct xsplice_elf *kelf, int offset) { return 16; }
-int ex_table_group_size(struct xsplice_elf *kelf, int offset) { return 8; }
-int altinstructions_group_size(struct xsplice_elf *kelf, int offset) { return 12; }
+static int bug_frames_0_group_size(struct xsplice_elf *kelf, int offset) { return 8; }
+static int bug_frames_1_group_size(struct xsplice_elf *kelf, int offset) { return 8; }
+static int bug_frames_2_group_size(struct xsplice_elf *kelf, int offset) { return 8; }
+static int bug_frames_3_group_size(struct xsplice_elf *kelf, int offset) { return 16; }
+static int ex_table_group_size(struct xsplice_elf *kelf, int offset) { return 8; }
+static int altinstructions_group_size(struct xsplice_elf *kelf, int offset) { return 12; }
/*
* The rela groups in the .fixup section vary in size. The beginning of each
* .fixup rela group is referenced by the .ex_table section. To find the size
* of a .fixup rela group, we have to traverse the .ex_table relas.
*/
-int fixup_group_size(struct xsplice_elf *kelf, int offset)
+static int fixup_group_size(struct xsplice_elf *kelf, int offset)
{
struct section *sec;
struct rela *rela;
return rela->addend - offset;
}
-struct special_section special_sections[] = {
+static struct special_section special_sections[] = {
{
.name = ".bug_frames.0",
.group_size = bug_frames_0_group_size,
{},
};
-int should_keep_rela_group(struct section *sec, int start, int size)
+static int should_keep_rela_group(struct section *sec, int start, int size)
{
struct rela *rela;
int found = 0;
return found;
}
-void xsplice_regenerate_special_section(struct xsplice_elf *kelf,
- struct special_section *special,
- struct section *sec)
+static void xsplice_regenerate_special_section(struct xsplice_elf *kelf,
+ struct special_section *special,
+ struct section *sec)
{
struct rela *rela, *safe;
char *src, *dest;
sec->base->data->d_size = dest_offset;
}
-void xsplice_process_special_sections(struct xsplice_elf *kelf)
+static void xsplice_process_special_sections(struct xsplice_elf *kelf)
{
struct special_section *special;
struct section *sec;
}
}
-void xsplice_include_standard_elements(struct xsplice_elf *kelf)
+static void xsplice_include_standard_elements(struct xsplice_elf *kelf)
{
struct section *sec;
#define inc_printf(fmt, ...) \
log_debug("%*s" fmt, recurselevel, "", ##__VA_ARGS__);
-void xsplice_include_symbol(struct symbol *sym, int recurselevel)
+static void xsplice_include_symbol(struct symbol *sym, int recurselevel)
{
struct rela *rela;
struct section *sec;
return;
}
-int xsplice_include_changed_functions(struct xsplice_elf *kelf)
+static int xsplice_include_changed_functions(struct xsplice_elf *kelf)
{
struct symbol *sym;
int changed_nr = 0;
return changed_nr;
}
-void xsplice_include_debug_sections(struct xsplice_elf *kelf)
+static void xsplice_include_debug_sections(struct xsplice_elf *kelf)
{
struct section *sec;
struct rela *rela, *saferela;
}
}
-int xsplice_include_new_globals(struct xsplice_elf *kelf)
+static int xsplice_include_new_globals(struct xsplice_elf *kelf)
{
struct symbol *sym;
int nr = 0;
return nr;
}
-void xsplice_print_changes(struct xsplice_elf *kelf)
+static void xsplice_print_changes(struct xsplice_elf *kelf)
{
struct symbol *sym;
}
}
-void xsplice_dump_kelf(struct xsplice_elf *kelf)
+static void xsplice_dump_kelf(struct xsplice_elf *kelf)
{
struct section *sec;
struct symbol *sym;
}
}
-void xsplice_verify_patchability(struct xsplice_elf *kelf)
+static void xsplice_verify_patchability(struct xsplice_elf *kelf)
{
struct section *sec;
int errs = 0;
DIFF_FATAL("%d unsupported section change(s)", errs);
}
-void xsplice_migrate_included_elements(struct xsplice_elf *kelf, struct xsplice_elf **kelfout)
+static void xsplice_migrate_included_elements(struct xsplice_elf *kelf,
+ struct xsplice_elf **kelfout)
{
struct section *sec, *safesec;
struct symbol *sym, *safesym;
if (sym->sec && !sym->sec->include)
/* break link to non-included section */
sym->sec = NULL;
-
}
*kelfout = out;
}
-void xsplice_migrate_symbols(struct list_head *src,
- struct list_head *dst,
- int (*select)(struct symbol *))
+static void xsplice_migrate_symbols(struct list_head *src,
+ struct list_head *dst,
+ int (*select)(struct symbol *))
{
struct symbol *sym, *safe;
}
}
-void xsplice_create_strings_elements(struct xsplice_elf *kelf)
+static void xsplice_create_strings_elements(struct xsplice_elf *kelf)
{
struct section *sec;
struct symbol *sym;
sym->name = ".xsplice.strings";
}
-void xsplice_build_strings_section_data(struct xsplice_elf *kelf)
+static void xsplice_build_strings_section_data(struct xsplice_elf *kelf)
{
struct string *string;
struct section *sec;
}
}
-struct section *create_section_pair(struct xsplice_elf *kelf, char *name,
- int entsize, int nr)
+static struct section *create_section_pair(struct xsplice_elf *kelf,
+ char *name, int entsize, int nr)
{
char *relaname;
struct section *sec, *relasec;
return sec;
}
-void xsplice_create_patches_sections(struct xsplice_elf *kelf,
- struct lookup_table *table, char *hint)
+static void xsplice_create_patches_sections(struct xsplice_elf *kelf,
+ struct lookup_table *table,
+ char *hint)
{
int nr, index;
struct section *sec, *relasec;
}
-/* Resolve symbols using xen-syms */
-void xsplice_resolve_symbols(struct xsplice_elf *kelf,
- struct lookup_table *table, char *hint)
-{
- struct symbol *sym;
- struct lookup_result result;
-
- list_for_each_entry(sym, &kelf->symbols, list) {
- /* ignore NULL symbol */
- if (!strlen(sym->name))
- continue;
- if (sym->sec)
- continue;
- if (sym->sym.st_shndx != SHN_UNDEF)
- continue;
-
- if (sym->bind == STB_LOCAL) {
- if (lookup_local_symbol(table, sym->name,
- hint, &result))
- ERROR("lookup_local_symbol %s (%s)",
- sym->name, hint);
- } else {
- if (lookup_global_symbol(table, sym->name,
- &result))
- ERROR("lookup_global_symbol %s",
- sym->name);
- }
- log_debug("lookup for %s @ 0x%016lx len %lu\n",
- sym->name, result.value, result.size);
- sym->sym.st_value += result.value;
- sym->sym.st_shndx = SHN_ABS;
- }
-}
-
-int is_null_sym(struct symbol *sym)
+static int is_null_sym(struct symbol *sym)
{
return !strlen(sym->name);
}
-int is_file_sym(struct symbol *sym)
+static int is_file_sym(struct symbol *sym)
{
return sym->type == STT_FILE;
}
-int is_local_func_sym(struct symbol *sym)
+static int is_local_func_sym(struct symbol *sym)
{
return sym->bind == STB_LOCAL && sym->type == STT_FUNC;
}
-int is_local_sym(struct symbol *sym)
+static int is_local_sym(struct symbol *sym)
{
return sym->bind == STB_LOCAL;
}
-void xsplice_reorder_symbols(struct xsplice_elf *kelf)
+static void xsplice_reorder_symbols(struct xsplice_elf *kelf)
{
LIST_HEAD(symbols);
list_replace(&symbols, &kelf->symbols);
}
-void xsplice_reindex_elements(struct xsplice_elf *kelf)
+static void xsplice_reindex_elements(struct xsplice_elf *kelf)
{
struct section *sec;
struct symbol *sym;
}
}
-void xsplice_rebuild_rela_section_data(struct section *sec)
+static void xsplice_rebuild_rela_section_data(struct section *sec)
{
struct rela *rela;
int nr = 0, index = 0, size;
ERROR("size mismatch in rebuilt rela section");
}
-void print_strtab(char *buf, size_t size)
+static void print_strtab(char *buf, size_t size)
{
int i;
}
}
-void xsplice_create_shstrtab(struct xsplice_elf *kelf)
+static void xsplice_create_shstrtab(struct xsplice_elf *kelf)
{
struct section *shstrtab, *sec;
size_t size, offset, len;
}
}
-void xsplice_create_strtab(struct xsplice_elf *kelf)
+static void xsplice_create_strtab(struct xsplice_elf *kelf)
{
struct section *strtab;
struct symbol *sym;
}
}
-void xsplice_create_symtab(struct xsplice_elf *kelf)
+static void xsplice_create_symtab(struct xsplice_elf *kelf)
{
struct section *symtab;
struct symbol *sym;
symtab->sh.sh_info = nr_local;
}
-void xsplice_write_output_elf(struct xsplice_elf *kelf, Elf *elf, char *outfile)
+static void xsplice_write_output_elf(struct xsplice_elf *kelf,
+ Elf *elf, char *outfile)
{
int fd;
struct section *sec;
sh = sec->sh;
if (!gelf_update_shdr(scn, &sh))
- ERROR("gelf_update_shdr");
+ ERROR("gelf_update_shdr");
}
if (!gelf_update_ehdr(elfout, &ehout))
xsplice_create_strings_elements(kelf_out);
log_debug("Create patches sections\n");
xsplice_create_patches_sections(kelf_out, lookup, hint);
- /* log_debug("Resolve symbols\n"); */
- /* xsplice_resolve_symbols(kelf_out, lookup, hint); */
xsplice_build_strings_section_data(kelf_out);
/*