Skip to content

Commit 4e90912

Browse files
committed
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
2 parents 88bc1de + cd2f45b commit 4e90912

File tree

3 files changed

+14
-21
lines changed

3 files changed

+14
-21
lines changed

arch/x86/entry/vdso/Makefile

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ VDSO32-$(CONFIG_IA32_EMULATION) := y
2424

2525
# files to link into the vdso
2626
vobjs-y := vdso-note.o vclock_gettime.o vgetcpu.o
27+
vobjs32-y := vdso32/note.o vdso32/system_call.o vdso32/sigreturn.o
28+
vobjs32-y += vdso32/vclock_gettime.o
2729

2830
# files to link into kernel
2931
obj-y += vma.o
@@ -37,10 +39,12 @@ vdso_img-$(VDSO32-y) += 32
3739
obj-$(VDSO32-y) += vdso32-setup.o
3840

3941
vobjs := $(foreach F,$(vobjs-y),$(obj)/$F)
42+
vobjs32 := $(foreach F,$(vobjs32-y),$(obj)/$F)
4043

4144
$(obj)/vdso.o: $(obj)/vdso.so
4245

4346
targets += vdso.lds $(vobjs-y)
47+
targets += vdso32/vdso32.lds $(vobjs32-y)
4448

4549
# Build the vDSO image C files and link them in.
4650
vdso_img_objs := $(vdso_img-y:%=vdso-image-%.o)
@@ -130,10 +134,6 @@ $(obj)/vdsox32.so.dbg: $(obj)/vdsox32.lds $(vobjx32s) FORCE
130134
CPPFLAGS_vdso32/vdso32.lds = $(CPPFLAGS_vdso.lds)
131135
VDSO_LDFLAGS_vdso32.lds = -m elf_i386 -soname linux-gate.so.1
132136

133-
targets += vdso32/vdso32.lds
134-
targets += vdso32/note.o vdso32/system_call.o vdso32/sigreturn.o
135-
targets += vdso32/vclock_gettime.o
136-
137137
KBUILD_AFLAGS_32 := $(filter-out -m64,$(KBUILD_AFLAGS)) -DBUILD_VDSO
138138
$(obj)/vdso32.so.dbg: KBUILD_AFLAGS = $(KBUILD_AFLAGS_32)
139139
$(obj)/vdso32.so.dbg: asflags-$(CONFIG_X86_64) += -m32
@@ -158,12 +158,7 @@ endif
158158

159159
$(obj)/vdso32.so.dbg: KBUILD_CFLAGS = $(KBUILD_CFLAGS_32)
160160

161-
$(obj)/vdso32.so.dbg: FORCE \
162-
$(obj)/vdso32/vdso32.lds \
163-
$(obj)/vdso32/vclock_gettime.o \
164-
$(obj)/vdso32/note.o \
165-
$(obj)/vdso32/system_call.o \
166-
$(obj)/vdso32/sigreturn.o
161+
$(obj)/vdso32.so.dbg: $(obj)/vdso32/vdso32.lds $(vobjs32) FORCE
167162
$(call if_changed,vdso_and_check)
168163

169164
#

arch/x86/entry/vdso/vdso2c.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ static void map_input(const char *name, void **addr, size_t *len, int prot)
187187

188188
int fd = open(name, O_RDONLY);
189189
if (fd == -1)
190-
err(1, "%s", name);
190+
err(1, "open(%s)", name);
191191

192192
tmp_len = lseek(fd, 0, SEEK_END);
193193
if (tmp_len == (off_t)-1)
@@ -240,7 +240,7 @@ int main(int argc, char **argv)
240240
outfilename = argv[3];
241241
outfile = fopen(outfilename, "w");
242242
if (!outfile)
243-
err(1, "%s", argv[2]);
243+
err(1, "fopen(%s)", outfilename);
244244

245245
go(raw_addr, raw_len, stripped_addr, stripped_len, outfile, name);
246246

arch/x86/entry/vdso/vdso2c.h

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ static void BITSFUNC(go)(void *raw_addr, size_t raw_len,
1313
unsigned long load_size = -1; /* Work around bogus warning */
1414
unsigned long mapping_size;
1515
ELF(Ehdr) *hdr = (ELF(Ehdr) *)raw_addr;
16-
int i;
17-
unsigned long j;
16+
unsigned long i, syms_nr;
1817
ELF(Shdr) *symtab_hdr = NULL, *strtab_hdr, *secstrings_hdr,
1918
*alt_sec = NULL;
2019
ELF(Dyn) *dyn = 0, *dyn_end = 0;
@@ -86,11 +85,10 @@ static void BITSFUNC(go)(void *raw_addr, size_t raw_len,
8685
strtab_hdr = raw_addr + GET_LE(&hdr->e_shoff) +
8786
GET_LE(&hdr->e_shentsize) * GET_LE(&symtab_hdr->sh_link);
8887

88+
syms_nr = GET_LE(&symtab_hdr->sh_size) / GET_LE(&symtab_hdr->sh_entsize);
8989
/* Walk the symbol table */
90-
for (i = 0;
91-
i < GET_LE(&symtab_hdr->sh_size) / GET_LE(&symtab_hdr->sh_entsize);
92-
i++) {
93-
int k;
90+
for (i = 0; i < syms_nr; i++) {
91+
unsigned int k;
9492
ELF(Sym) *sym = raw_addr + GET_LE(&symtab_hdr->sh_offset) +
9593
GET_LE(&symtab_hdr->sh_entsize) * i;
9694
const char *sym_name = raw_addr +
@@ -150,11 +148,11 @@ static void BITSFUNC(go)(void *raw_addr, size_t raw_len,
150148
fprintf(outfile,
151149
"static unsigned char raw_data[%lu] __ro_after_init __aligned(PAGE_SIZE) = {",
152150
mapping_size);
153-
for (j = 0; j < stripped_len; j++) {
154-
if (j % 10 == 0)
151+
for (i = 0; i < stripped_len; i++) {
152+
if (i % 10 == 0)
155153
fprintf(outfile, "\n\t");
156154
fprintf(outfile, "0x%02X, ",
157-
(int)((unsigned char *)stripped_addr)[j]);
155+
(int)((unsigned char *)stripped_addr)[i]);
158156
}
159157
fprintf(outfile, "\n};\n\n");
160158

0 commit comments

Comments
 (0)