Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 31 Oct 2019 14:49:30 +0000 (UTC)
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r354216 - stable/12/sys/kern
Message-ID:  <201910311449.x9VEnUJ1021199@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: markj
Date: Thu Oct 31 14:49:30 2019
New Revision: 354216
URL: https://svnweb.freebsd.org/changeset/base/354216

Log:
  MFC r353699:
  Clean up some nits in link_elf_(un)load_file().

Modified:
  stable/12/sys/kern/link_elf_obj.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/kern/link_elf_obj.c
==============================================================================
--- stable/12/sys/kern/link_elf_obj.c	Thu Oct 31 14:22:54 2019	(r354215)
+++ stable/12/sys/kern/link_elf_obj.c	Thu Oct 31 14:49:30 2019	(r354216)
@@ -779,7 +779,6 @@ link_elf_load_file(linker_class_t cls, const char *fil
 		error = ENOMEM;
 		goto out;
 	}
-	ef->address = (caddr_t) vm_map_min(kernel_map);
 
 	/*
 	 * In order to satisfy amd64's architectural requirements on the
@@ -794,9 +793,10 @@ link_elf_load_file(linker_class_t cls, const char *fil
 	error = vm_map_find(kernel_map, ef->object, 0, &mapbase,
 	    round_page(mapsize), 0, VMFS_OPTIMAL_SPACE, VM_PROT_ALL,
 	    VM_PROT_ALL, 0);
-	if (error) {
+	if (error != KERN_SUCCESS) {
 		vm_object_deallocate(ef->object);
-		ef->object = 0;
+		ef->object = NULL;
+		error = ENOMEM;
 		goto out;
 	}
 
@@ -1084,11 +1084,9 @@ link_elf_unload_file(linker_file_t file)
 	free(ef->relatab, M_LINKER);
 	free(ef->progtab, M_LINKER);
 
-	if (ef->object) {
-		vm_map_remove(kernel_map, (vm_offset_t) ef->address,
-		    (vm_offset_t) ef->address +
-		    (ef->object->size << PAGE_SHIFT));
-	}
+	if (ef->object != NULL)
+		vm_map_remove(kernel_map, (vm_offset_t)ef->address,
+		    (vm_offset_t)ef->address + ptoa(ef->object->size));
 	free(ef->e_shdr, M_LINKER);
 	free(ef->ddbsymtab, M_LINKER);
 	free(ef->ddbstrtab, M_LINKER);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201910311449.x9VEnUJ1021199>