Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

objtool: Clean up compiler flag usage

KBUILD_HOSTCFLAGS and KBUILD_HOSTLDFLAGS aren't defined when objtool is
built standalone. Also, the EXTRA_WARNINGS flags are rather arbitrary.

Make things simpler and more consistent by specifying compiler flags
explicitly and tweaking the warnings. Also make a few code tweaks to
make the new warnings happy.

Acked-by: Petr Mladek <pmladek@suse.com>
Tested-by: Joe Lawrence <joe.lawrence@redhat.com>
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>

+13 -8
+10 -5
tools/objtool/Makefile
··· 23 23 24 24 all: $(OBJTOOL) 25 25 26 + WARNINGS := -Werror -Wall -Wextra -Wmissing-prototypes \ 27 + -Wmissing-declarations -Wwrite-strings \ 28 + -Wno-implicit-fallthrough -Wno-sign-compare \ 29 + -Wno-unused-parameter 30 + 26 31 INCLUDES := -I$(srctree)/tools/include \ 27 32 -I$(srctree)/tools/include/uapi \ 28 33 -I$(srctree)/tools/arch/$(HOSTARCH)/include/uapi \ ··· 35 30 -I$(srctree)/tools/objtool/include \ 36 31 -I$(srctree)/tools/objtool/arch/$(SRCARCH)/include \ 37 32 -I$(LIBSUBCMD_OUTPUT)/include 38 - # Note, EXTRA_WARNINGS here was determined for CC and not HOSTCC, it 39 - # is passed here to match a legacy behavior. 40 - WARNINGS := $(EXTRA_WARNINGS) -Wno-switch-default -Wno-switch-enum -Wno-packed -Wno-nested-externs 41 - OBJTOOL_CFLAGS := -Werror $(WARNINGS) $(KBUILD_HOSTCFLAGS) -g $(INCLUDES) $(LIBELF_FLAGS) 42 - OBJTOOL_LDFLAGS := $(LIBELF_LIBS) $(LIBSUBCMD) $(KBUILD_HOSTLDFLAGS) 33 + 34 + OBJTOOL_CFLAGS := -std=gnu11 -fomit-frame-pointer -O2 -g \ 35 + $(WARNINGS) $(INCLUDES) $(LIBELF_FLAGS) $(HOSTCFLAGS) 36 + 37 + OBJTOOL_LDFLAGS := $(LIBSUBCMD) $(LIBELF_LIBS) $(HOSTLDFLAGS) 43 38 44 39 # Allow old libelf to be used: 45 40 elfshdr := $(shell echo '$(pound)include <libelf.h>' | $(HOSTCC) $(OBJTOOL_CFLAGS) -x c -E - 2>/dev/null | grep elf_getshdr)
+2 -2
tools/objtool/check.c
··· 461 461 462 462 for (offset = 0; offset < sec->sh.sh_size; offset += insn->len) { 463 463 if (!insns || idx == INSN_CHUNK_MAX) { 464 - insns = calloc(sizeof(*insn), INSN_CHUNK_SIZE); 464 + insns = calloc(INSN_CHUNK_SIZE, sizeof(*insn)); 465 465 if (!insns) { 466 466 ERROR_GLIBC("calloc"); 467 467 return -1; ··· 607 607 return 0; 608 608 609 609 nr = sym->len / sizeof(unsigned long); 610 - file->pv_ops = calloc(sizeof(struct pv_state), nr); 610 + file->pv_ops = calloc(nr, sizeof(struct pv_state)); 611 611 if (!file->pv_ops) { 612 612 ERROR_GLIBC("calloc"); 613 613 return -1;
+1 -1
tools/objtool/elf.c
··· 736 736 } 737 737 738 738 /* setup extended section index magic and write the symbol */ 739 - if ((shndx >= SHN_UNDEF && shndx < SHN_LORESERVE) || is_special_shndx) { 739 + if (shndx < SHN_LORESERVE || is_special_shndx) { 740 740 sym->sym.st_shndx = shndx; 741 741 if (!shndx_data) 742 742 shndx = 0;