Merge pull request #829 from sm00th/sign-compare

Sign compare fixes
This commit is contained in:
Joe Lawrence 2018-04-13 15:21:07 -04:00 committed by GitHub
commit 88241ef8e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 17 additions and 16 deletions

View File

@ -1,6 +1,6 @@
include ../Makefile.inc
CFLAGS += -MMD -MP -I../kmod/patch -Iinsn -Wall -g -Werror
CFLAGS += -MMD -MP -I../kmod/patch -Iinsn -Wall -Wsign-compare -g -Werror
LDLIBS = -lelf
TARGETS = create-diff-object create-klp-module create-kpatch-module

View File

@ -1162,8 +1162,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 == sym->sec->sh.sh_size &&
end == sym->sec->sh.sh_size) {
rela->addend == (int)sym->sec->sh.sh_size &&
end == (int)sym->sec->sh.sh_size) {
/*
* A special case where gcc needs a
@ -1773,7 +1773,8 @@ static struct special_section special_sections[] = {
{},
};
static int should_keep_rela_group(struct section *sec, int start, int size)
static int should_keep_rela_group(struct section *sec, unsigned int start,
unsigned int size)
{
struct rela *rela;
int found = 0;
@ -1824,7 +1825,7 @@ static void kpatch_regenerate_special_section(struct kpatch_elf *kelf,
{
struct rela *rela, *safe;
char *src, *dest;
int group_size, src_offset, dest_offset, include;
unsigned int group_size, src_offset, dest_offset, include;
LIST_HEAD(newrelas);
@ -2387,7 +2388,7 @@ static int function_ptr_rela(const struct rela *rela)
return (rela_toc && rela_toc->sym->type == STT_FUNC &&
/* skip switch table on PowerPC */
rela_toc->addend == rela_toc->sym->sym.st_value &&
rela_toc->addend == (int)rela_toc->sym->sym.st_value &&
(rela->type == R_X86_64_32S ||
rela->type == R_PPC64_TOC16_HA ||
rela->type == R_PPC64_TOC16_LO_DS));
@ -2648,7 +2649,7 @@ static void kpatch_create_intermediate_sections(struct kpatch_elf *kelf,
/* Fill in krelas[index] */
if (is_gcc6_localentry_bundled_sym(rela->sym) &&
rela->addend == rela->sym->sym.st_value)
rela->addend == (int)rela->sym->sym.st_value)
rela->addend -= rela->sym->sym.st_value;
krelas[index].addend = rela->addend;
krelas[index].type = rela->type;

View File

@ -316,7 +316,7 @@ static void create_klp_arch_sections(struct kpatch_elf *kelf, char *strings)
*/
static void remove_arch_sections(struct kpatch_elf *kelf)
{
int i;
size_t i;
char *arch_sections[] = {
".parainstructions",
".rela.parainstructions",
@ -331,7 +331,7 @@ static void remove_arch_sections(struct kpatch_elf *kelf)
static void remove_intermediate_sections(struct kpatch_elf *kelf)
{
int i;
size_t i;
char *intermediate_sections[] = {
".kpatch.symbols",
".rela.kpatch.symbols",

View File

@ -126,7 +126,7 @@ static void create_dynamic_rela_sections(struct kpatch_elf *kelf, struct section
static void remove_intermediate_sections(struct kpatch_elf *kelf)
{
int i;
size_t i;
char *intermediate_sections[] = {
".kpatch.symbols",
".rela.kpatch.symbols",

View File

@ -263,7 +263,7 @@ void kpatch_create_symbol_list(struct kpatch_elf *kelf)
{
struct section *symtab;
struct symbol *sym;
int symbols_nr, index = 0;
unsigned int symbols_nr, index = 0;
symtab = find_section_by_name(&kelf->sections, ".symtab");
if (!symtab)
@ -452,7 +452,7 @@ int is_local_sym(struct symbol *sym)
void print_strtab(char *buf, size_t size)
{
int i;
size_t i;
for (i = 0; i < size; i++) {
if (buf[i] == 0)
@ -697,7 +697,7 @@ void kpatch_reindex_elements(struct kpatch_elf *kelf)
{
struct section *sec;
struct symbol *sym;
int index;
unsigned int index;
index = 1; /* elf write function handles NULL section 0 */
list_for_each_entry(sec, &kelf->sections, list)

View File

@ -50,7 +50,7 @@ struct section {
GElf_Shdr sh;
Elf_Data *data;
char *name;
int index;
unsigned int index;
enum status status;
int include;
int ignore;
@ -73,7 +73,7 @@ struct symbol {
struct section *sec;
GElf_Sym sym;
char *name;
int index;
unsigned int index;
unsigned char bind, type;
enum status status;
union {
@ -89,7 +89,7 @@ struct rela {
struct symbol *sym;
unsigned int type;
int addend;
int offset;
unsigned int offset;
char *string;
bool need_dynrela;
};