Commit 4e909124 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'x86-vdso-2020-06-01' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull x86 vdso updates from Ingo Molnar:
 "Clean up various aspects of the vDSO code, no change in functionality
  intended"

* tag 'x86-vdso-2020-06-01' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  x86/vdso/Makefile: Add vobjs32
  x86/vdso/vdso2c: Convert iterators to unsigned
  x86/vdso/vdso2c: Correct error messages on file open
parents 88bc1de1 cd2f45b7
...@@ -24,6 +24,8 @@ VDSO32-$(CONFIG_IA32_EMULATION) := y ...@@ -24,6 +24,8 @@ VDSO32-$(CONFIG_IA32_EMULATION) := y
# files to link into the vdso # files to link into the vdso
vobjs-y := vdso-note.o vclock_gettime.o vgetcpu.o vobjs-y := vdso-note.o vclock_gettime.o vgetcpu.o
vobjs32-y := vdso32/note.o vdso32/system_call.o vdso32/sigreturn.o
vobjs32-y += vdso32/vclock_gettime.o
# files to link into kernel # files to link into kernel
obj-y += vma.o obj-y += vma.o
...@@ -37,10 +39,12 @@ vdso_img-$(VDSO32-y) += 32 ...@@ -37,10 +39,12 @@ vdso_img-$(VDSO32-y) += 32
obj-$(VDSO32-y) += vdso32-setup.o obj-$(VDSO32-y) += vdso32-setup.o
vobjs := $(foreach F,$(vobjs-y),$(obj)/$F) vobjs := $(foreach F,$(vobjs-y),$(obj)/$F)
vobjs32 := $(foreach F,$(vobjs32-y),$(obj)/$F)
$(obj)/vdso.o: $(obj)/vdso.so $(obj)/vdso.o: $(obj)/vdso.so
targets += vdso.lds $(vobjs-y) targets += vdso.lds $(vobjs-y)
targets += vdso32/vdso32.lds $(vobjs32-y)
# Build the vDSO image C files and link them in. # Build the vDSO image C files and link them in.
vdso_img_objs := $(vdso_img-y:%=vdso-image-%.o) vdso_img_objs := $(vdso_img-y:%=vdso-image-%.o)
...@@ -130,10 +134,6 @@ $(obj)/vdsox32.so.dbg: $(obj)/vdsox32.lds $(vobjx32s) FORCE ...@@ -130,10 +134,6 @@ $(obj)/vdsox32.so.dbg: $(obj)/vdsox32.lds $(vobjx32s) FORCE
CPPFLAGS_vdso32/vdso32.lds = $(CPPFLAGS_vdso.lds) CPPFLAGS_vdso32/vdso32.lds = $(CPPFLAGS_vdso.lds)
VDSO_LDFLAGS_vdso32.lds = -m elf_i386 -soname linux-gate.so.1 VDSO_LDFLAGS_vdso32.lds = -m elf_i386 -soname linux-gate.so.1
targets += vdso32/vdso32.lds
targets += vdso32/note.o vdso32/system_call.o vdso32/sigreturn.o
targets += vdso32/vclock_gettime.o
KBUILD_AFLAGS_32 := $(filter-out -m64,$(KBUILD_AFLAGS)) -DBUILD_VDSO KBUILD_AFLAGS_32 := $(filter-out -m64,$(KBUILD_AFLAGS)) -DBUILD_VDSO
$(obj)/vdso32.so.dbg: KBUILD_AFLAGS = $(KBUILD_AFLAGS_32) $(obj)/vdso32.so.dbg: KBUILD_AFLAGS = $(KBUILD_AFLAGS_32)
$(obj)/vdso32.so.dbg: asflags-$(CONFIG_X86_64) += -m32 $(obj)/vdso32.so.dbg: asflags-$(CONFIG_X86_64) += -m32
...@@ -158,12 +158,7 @@ endif ...@@ -158,12 +158,7 @@ endif
$(obj)/vdso32.so.dbg: KBUILD_CFLAGS = $(KBUILD_CFLAGS_32) $(obj)/vdso32.so.dbg: KBUILD_CFLAGS = $(KBUILD_CFLAGS_32)
$(obj)/vdso32.so.dbg: FORCE \ $(obj)/vdso32.so.dbg: $(obj)/vdso32/vdso32.lds $(vobjs32) FORCE
$(obj)/vdso32/vdso32.lds \
$(obj)/vdso32/vclock_gettime.o \
$(obj)/vdso32/note.o \
$(obj)/vdso32/system_call.o \
$(obj)/vdso32/sigreturn.o
$(call if_changed,vdso_and_check) $(call if_changed,vdso_and_check)
# #
......
...@@ -187,7 +187,7 @@ static void map_input(const char *name, void **addr, size_t *len, int prot) ...@@ -187,7 +187,7 @@ static void map_input(const char *name, void **addr, size_t *len, int prot)
int fd = open(name, O_RDONLY); int fd = open(name, O_RDONLY);
if (fd == -1) if (fd == -1)
err(1, "%s", name); err(1, "open(%s)", name);
tmp_len = lseek(fd, 0, SEEK_END); tmp_len = lseek(fd, 0, SEEK_END);
if (tmp_len == (off_t)-1) if (tmp_len == (off_t)-1)
...@@ -240,7 +240,7 @@ int main(int argc, char **argv) ...@@ -240,7 +240,7 @@ int main(int argc, char **argv)
outfilename = argv[3]; outfilename = argv[3];
outfile = fopen(outfilename, "w"); outfile = fopen(outfilename, "w");
if (!outfile) if (!outfile)
err(1, "%s", argv[2]); err(1, "fopen(%s)", outfilename);
go(raw_addr, raw_len, stripped_addr, stripped_len, outfile, name); go(raw_addr, raw_len, stripped_addr, stripped_len, outfile, name);
......
...@@ -13,8 +13,7 @@ static void BITSFUNC(go)(void *raw_addr, size_t raw_len, ...@@ -13,8 +13,7 @@ static void BITSFUNC(go)(void *raw_addr, size_t raw_len,
unsigned long load_size = -1; /* Work around bogus warning */ unsigned long load_size = -1; /* Work around bogus warning */
unsigned long mapping_size; unsigned long mapping_size;
ELF(Ehdr) *hdr = (ELF(Ehdr) *)raw_addr; ELF(Ehdr) *hdr = (ELF(Ehdr) *)raw_addr;
int i; unsigned long i, syms_nr;
unsigned long j;
ELF(Shdr) *symtab_hdr = NULL, *strtab_hdr, *secstrings_hdr, ELF(Shdr) *symtab_hdr = NULL, *strtab_hdr, *secstrings_hdr,
*alt_sec = NULL; *alt_sec = NULL;
ELF(Dyn) *dyn = 0, *dyn_end = 0; ELF(Dyn) *dyn = 0, *dyn_end = 0;
...@@ -86,11 +85,10 @@ static void BITSFUNC(go)(void *raw_addr, size_t raw_len, ...@@ -86,11 +85,10 @@ static void BITSFUNC(go)(void *raw_addr, size_t raw_len,
strtab_hdr = raw_addr + GET_LE(&hdr->e_shoff) + strtab_hdr = raw_addr + GET_LE(&hdr->e_shoff) +
GET_LE(&hdr->e_shentsize) * GET_LE(&symtab_hdr->sh_link); GET_LE(&hdr->e_shentsize) * GET_LE(&symtab_hdr->sh_link);
syms_nr = GET_LE(&symtab_hdr->sh_size) / GET_LE(&symtab_hdr->sh_entsize);
/* Walk the symbol table */ /* Walk the symbol table */
for (i = 0; for (i = 0; i < syms_nr; i++) {
i < GET_LE(&symtab_hdr->sh_size) / GET_LE(&symtab_hdr->sh_entsize); unsigned int k;
i++) {
int k;
ELF(Sym) *sym = raw_addr + GET_LE(&symtab_hdr->sh_offset) + ELF(Sym) *sym = raw_addr + GET_LE(&symtab_hdr->sh_offset) +
GET_LE(&symtab_hdr->sh_entsize) * i; GET_LE(&symtab_hdr->sh_entsize) * i;
const char *sym_name = raw_addr + const char *sym_name = raw_addr +
...@@ -150,11 +148,11 @@ static void BITSFUNC(go)(void *raw_addr, size_t raw_len, ...@@ -150,11 +148,11 @@ static void BITSFUNC(go)(void *raw_addr, size_t raw_len,
fprintf(outfile, fprintf(outfile,
"static unsigned char raw_data[%lu] __ro_after_init __aligned(PAGE_SIZE) = {", "static unsigned char raw_data[%lu] __ro_after_init __aligned(PAGE_SIZE) = {",
mapping_size); mapping_size);
for (j = 0; j < stripped_len; j++) { for (i = 0; i < stripped_len; i++) {
if (j % 10 == 0) if (i % 10 == 0)
fprintf(outfile, "\n\t"); fprintf(outfile, "\n\t");
fprintf(outfile, "0x%02X, ", fprintf(outfile, "0x%02X, ",
(int)((unsigned char *)stripped_addr)[j]); (int)((unsigned char *)stripped_addr)[i]);
} }
fprintf(outfile, "\n};\n\n"); fprintf(outfile, "\n};\n\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment