Commit 36650a35 authored by Christophe JAILLET's avatar Christophe JAILLET Committed by Kees Cook
Browse files

binfmt: Slightly simplify elf_fdpic_map_file()



There is no point in initializing 'load_addr' and 'seg' here, they are both
re-written just before being used below.

Doing so, 'load_addr' can be moved in the #ifdef CONFIG_MMU section.

Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Acked-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: default avatarKees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/4f5e4096ad7f17716e924b5bd080e5709fc0b84b.1685290790.git.christophe.jaillet@wanadoo.fr
parent e6302d5a
Loading
Loading
Loading
Loading
+2 −4
Original line number Original line Diff line number Diff line
@@ -743,11 +743,12 @@ static int elf_fdpic_map_file(struct elf_fdpic_params *params,
	struct elf32_fdpic_loadmap *loadmap;
	struct elf32_fdpic_loadmap *loadmap;
#ifdef CONFIG_MMU
#ifdef CONFIG_MMU
	struct elf32_fdpic_loadseg *mseg;
	struct elf32_fdpic_loadseg *mseg;
	unsigned long load_addr;
#endif
#endif
	struct elf32_fdpic_loadseg *seg;
	struct elf32_fdpic_loadseg *seg;
	struct elf32_phdr *phdr;
	struct elf32_phdr *phdr;
	unsigned long load_addr, stop;
	unsigned nloads, tmp;
	unsigned nloads, tmp;
	unsigned long stop;
	int loop, ret;
	int loop, ret;


	/* allocate a load map table */
	/* allocate a load map table */
@@ -768,9 +769,6 @@ static int elf_fdpic_map_file(struct elf_fdpic_params *params,
	loadmap->version = ELF32_FDPIC_LOADMAP_VERSION;
	loadmap->version = ELF32_FDPIC_LOADMAP_VERSION;
	loadmap->nsegs = nloads;
	loadmap->nsegs = nloads;


	load_addr = params->load_addr;
	seg = loadmap->segs;

	/* map the requested LOADs into the memory space */
	/* map the requested LOADs into the memory space */
	switch (params->flags & ELF_FDPIC_FLAG_ARRANGEMENT) {
	switch (params->flags & ELF_FDPIC_FLAG_ARRANGEMENT) {
	case ELF_FDPIC_FLAG_CONSTDISP:
	case ELF_FDPIC_FLAG_CONSTDISP: