mirror of
https://github.com/dynup/kpatch
synced 2025-01-18 11:00:44 +00:00
create-diff-object: Fix -Wconversion warnings
Fix warnings reported by -Wconversion,-Wno-sign-conversion flags. Signed-off-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>
This commit is contained in:
parent
a0c608de70
commit
5f68db22e5
@ -178,7 +178,8 @@ static struct rela *toc_rela(const struct rela *rela)
|
||||
return (struct rela *)rela;
|
||||
|
||||
/* Will return NULL for .toc constant entries */
|
||||
return find_rela_by_offset(rela->sym->sec->rela, rela->addend);
|
||||
return find_rela_by_offset(rela->sym->sec->rela,
|
||||
(unsigned int)rela->addend);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1262,7 +1263,7 @@ static void kpatch_replace_sections_syms(struct kpatch_elf *kelf)
|
||||
struct section *sec;
|
||||
struct rela *rela;
|
||||
struct symbol *sym;
|
||||
int add_off;
|
||||
unsigned int add_off;
|
||||
|
||||
log_debug("\n");
|
||||
|
||||
@ -1304,9 +1305,9 @@ static void kpatch_replace_sections_syms(struct kpatch_elf *kelf)
|
||||
rela->type == R_X86_64_PLT32) {
|
||||
struct insn insn;
|
||||
rela_insn(sec, rela, &insn);
|
||||
add_off = (long)insn.next_byte -
|
||||
add_off = (unsigned int)((long)insn.next_byte -
|
||||
(long)sec->base->data->d_buf -
|
||||
rela->offset;
|
||||
rela->offset);
|
||||
} else if (rela->type == R_X86_64_64 ||
|
||||
rela->type == R_X86_64_32S)
|
||||
add_off = 0;
|
||||
@ -1319,7 +1320,7 @@ static void kpatch_replace_sections_syms(struct kpatch_elf *kelf)
|
||||
* with their symbols.
|
||||
*/
|
||||
list_for_each_entry(sym, &kelf->symbols, list) {
|
||||
int start, end;
|
||||
long start, end;
|
||||
|
||||
if (sym->type == STT_SECTION ||
|
||||
sym->sec != rela->sym->sec)
|
||||
@ -1330,8 +1331,8 @@ static void kpatch_replace_sections_syms(struct kpatch_elf *kelf)
|
||||
|
||||
if (!is_text_section(sym->sec) &&
|
||||
rela->type == R_X86_64_32S &&
|
||||
rela->addend == (int)sym->sec->sh.sh_size &&
|
||||
end == (int)sym->sec->sh.sh_size) {
|
||||
rela->addend == (long)sym->sec->sh.sh_size &&
|
||||
end == (long)sym->sec->sh.sh_size) {
|
||||
|
||||
/*
|
||||
* A special case where gcc needs a
|
||||
@ -1878,10 +1879,10 @@ static int fixup_group_size(struct kpatch_elf *kelf, int offset)
|
||||
fixupsec = find_section_by_name(&kelf->sections, ".fixup");
|
||||
if (!fixupsec)
|
||||
ERROR("missing .fixup section");
|
||||
return fixupsec->sh.sh_size - offset;
|
||||
return (int)(fixupsec->sh.sh_size - offset);
|
||||
}
|
||||
|
||||
return rela->addend - offset;
|
||||
return (int)(rela->addend - offset);
|
||||
}
|
||||
|
||||
static struct special_section special_sections[] = {
|
||||
@ -2026,7 +2027,7 @@ static void kpatch_regenerate_special_section(struct kpatch_elf *kelf,
|
||||
* section.
|
||||
*/
|
||||
if (src_offset + group_size > sec->base->sh.sh_size)
|
||||
group_size = sec->base->sh.sh_size - src_offset;
|
||||
group_size = (unsigned int)(sec->base->sh.sh_size - src_offset);
|
||||
|
||||
include = should_keep_rela_group(sec, src_offset, group_size);
|
||||
|
||||
@ -2415,16 +2416,16 @@ static void kpatch_create_kpatch_arch_section(struct kpatch_elf *kelf, char *obj
|
||||
rela->sym = sec->secsym;
|
||||
rela->type = ABSOLUTE_RELA_TYPE;
|
||||
rela->addend = 0;
|
||||
rela->offset = index * sizeof(struct kpatch_arch) + \
|
||||
offsetof(struct kpatch_arch, sec);
|
||||
rela->offset = (unsigned int)(index * sizeof(struct kpatch_arch) + \
|
||||
offsetof(struct kpatch_arch, sec));
|
||||
|
||||
/* entries[index].objname */
|
||||
ALLOC_LINK(rela, &karch_sec->rela->relas);
|
||||
rela->sym = strsym;
|
||||
rela->type = ABSOLUTE_RELA_TYPE;
|
||||
rela->addend = offset_of_string(&kelf->strings, objname);
|
||||
rela->offset = index * sizeof(struct kpatch_arch) + \
|
||||
offsetof(struct kpatch_arch, objname);
|
||||
rela->offset = (unsigned int)(index * sizeof(struct kpatch_arch) + \
|
||||
offsetof(struct kpatch_arch, objname));
|
||||
|
||||
index++;
|
||||
}
|
||||
@ -2604,7 +2605,8 @@ static void kpatch_create_patches_sections(struct kpatch_elf *kelf,
|
||||
* its relocations have been applied.
|
||||
*/
|
||||
sym->bind = STB_LOCAL;
|
||||
sym->sym.st_info = GELF_ST_INFO(sym->bind, sym->type);
|
||||
sym->sym.st_info = (unsigned char)
|
||||
GELF_ST_INFO(sym->bind, sym->type);
|
||||
|
||||
/* add entry in text section */
|
||||
funcs[index].old_addr = result.value;
|
||||
@ -2621,7 +2623,7 @@ static void kpatch_create_patches_sections(struct kpatch_elf *kelf,
|
||||
rela->sym = sym;
|
||||
rela->type = ABSOLUTE_RELA_TYPE;
|
||||
rela->addend = 0;
|
||||
rela->offset = index * sizeof(*funcs);
|
||||
rela->offset = (unsigned int)(index * sizeof(*funcs));
|
||||
|
||||
/*
|
||||
* Add a relocation that will populate
|
||||
@ -2631,8 +2633,8 @@ static void kpatch_create_patches_sections(struct kpatch_elf *kelf,
|
||||
rela->sym = strsym;
|
||||
rela->type = ABSOLUTE_RELA_TYPE;
|
||||
rela->addend = offset_of_string(&kelf->strings, sym->name);
|
||||
rela->offset = index * sizeof(*funcs) +
|
||||
offsetof(struct kpatch_patch_func, name);
|
||||
rela->offset = (unsigned int)(index * sizeof(*funcs) +
|
||||
offsetof(struct kpatch_patch_func, name));
|
||||
|
||||
/*
|
||||
* Add a relocation that will populate
|
||||
@ -2642,8 +2644,8 @@ static void kpatch_create_patches_sections(struct kpatch_elf *kelf,
|
||||
rela->sym = strsym;
|
||||
rela->type = ABSOLUTE_RELA_TYPE;
|
||||
rela->addend = objname_offset;
|
||||
rela->offset = index * sizeof(*funcs) +
|
||||
offsetof(struct kpatch_patch_func,objname);
|
||||
rela->offset = (unsigned int)(index * sizeof(*funcs) +
|
||||
offsetof(struct kpatch_patch_func,objname));
|
||||
|
||||
index++;
|
||||
}
|
||||
@ -2954,16 +2956,16 @@ static void kpatch_create_intermediate_sections(struct kpatch_elf *kelf,
|
||||
rela2->sym = strsym;
|
||||
rela2->type = ABSOLUTE_RELA_TYPE;
|
||||
rela2->addend = offset_of_string(&kelf->strings, rela->sym->name);
|
||||
rela2->offset = index * sizeof(*ksyms) + \
|
||||
offsetof(struct kpatch_symbol, name);
|
||||
rela2->offset = (unsigned int)(index * sizeof(*ksyms) + \
|
||||
offsetof(struct kpatch_symbol, name));
|
||||
|
||||
/* add rela to fill in ksyms[index].objname field */
|
||||
ALLOC_LINK(rela2, &ksym_sec->rela->relas);
|
||||
rela2->sym = strsym;
|
||||
rela2->type = ABSOLUTE_RELA_TYPE;
|
||||
rela2->addend = offset_of_string(&kelf->strings, sym_objname);
|
||||
rela2->offset = index * sizeof(*ksyms) + \
|
||||
offsetof(struct kpatch_symbol, objname);
|
||||
rela2->offset = (unsigned int)(index * sizeof(*ksyms) + \
|
||||
offsetof(struct kpatch_symbol, objname));
|
||||
|
||||
/* Fill in krelas[index] */
|
||||
if (is_gcc6_localentry_bundled_sym(rela->sym) &&
|
||||
@ -2983,24 +2985,24 @@ static void kpatch_create_intermediate_sections(struct kpatch_elf *kelf,
|
||||
|
||||
rela2->type = ABSOLUTE_RELA_TYPE;
|
||||
rela2->addend = rela->offset;
|
||||
rela2->offset = index * sizeof(*krelas) + \
|
||||
offsetof(struct kpatch_relocation, dest);
|
||||
rela2->offset = (unsigned int)(index * sizeof(*krelas) + \
|
||||
offsetof(struct kpatch_relocation, dest));
|
||||
|
||||
/* add rela to fill in krelas[index].objname field */
|
||||
ALLOC_LINK(rela2, &krela_sec->rela->relas);
|
||||
rela2->sym = strsym;
|
||||
rela2->type = ABSOLUTE_RELA_TYPE;
|
||||
rela2->addend = offset_of_string(&kelf->strings, objname);
|
||||
rela2->offset = index * sizeof(*krelas) + \
|
||||
offsetof(struct kpatch_relocation, objname);
|
||||
rela2->offset = (unsigned int)(index * sizeof(*krelas) + \
|
||||
offsetof(struct kpatch_relocation, objname));
|
||||
|
||||
/* add rela to fill in krelas[index].ksym field */
|
||||
ALLOC_LINK(rela2, &krela_sec->rela->relas);
|
||||
rela2->sym = ksym_sec_sym;
|
||||
rela2->type = ABSOLUTE_RELA_TYPE;
|
||||
rela2->addend = index * sizeof(*ksyms);
|
||||
rela2->offset = index * sizeof(*krelas) + \
|
||||
offsetof(struct kpatch_relocation, ksym);
|
||||
rela2->addend = (unsigned int)(index * sizeof(*ksyms));
|
||||
rela2->offset = (unsigned int)(index * sizeof(*krelas) + \
|
||||
offsetof(struct kpatch_relocation, ksym));
|
||||
|
||||
/*
|
||||
* Mark the referred to symbol for removal but
|
||||
@ -3115,7 +3117,7 @@ static void kpatch_create_mcount_sections(struct kpatch_elf *kelf)
|
||||
rela->sym = sym;
|
||||
rela->type = R_X86_64_64;
|
||||
rela->addend = 0;
|
||||
rela->offset = index * sizeof(void*);
|
||||
rela->offset = (unsigned int)(index * sizeof(void*));
|
||||
|
||||
/*
|
||||
* Modify the first instruction of the function to "callq
|
||||
@ -3213,7 +3215,7 @@ static void kpatch_build_strings_section_data(struct kpatch_elf *kelf)
|
||||
{
|
||||
struct string *string;
|
||||
struct section *sec;
|
||||
int size;
|
||||
size_t size;
|
||||
char *strtab;
|
||||
|
||||
sec = find_section_by_name(&kelf->sections, ".kpatch.strings");
|
||||
@ -3256,7 +3258,7 @@ static void kpatch_no_sibling_calls_ppc64le(struct kpatch_elf *kelf)
|
||||
#ifdef __powerpc64__
|
||||
struct symbol *sym;
|
||||
unsigned int insn;
|
||||
unsigned long offset;
|
||||
unsigned int offset;
|
||||
|
||||
list_for_each_entry(sym, &kelf->symbols, list) {
|
||||
if (sym->type != STT_FUNC || sym->status != CHANGED)
|
||||
|
@ -35,8 +35,8 @@ struct kpatch_symbol {
|
||||
struct kpatch_relocation {
|
||||
unsigned long dest;
|
||||
unsigned int type;
|
||||
int addend;
|
||||
int external;
|
||||
long addend;
|
||||
char *objname; /* object to which this rela applies to */
|
||||
struct kpatch_symbol *ksym;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user