]> git.eshelyaron.com Git - emacs.git/commitdiff
Implement position independent dump.
authorAndrea Corallo <akrl@sdf.org>
Fri, 10 Apr 2020 21:30:34 +0000 (22:30 +0100)
committerAndrea Corallo <akrl@sdf.org>
Sun, 12 Apr 2020 15:52:05 +0000 (16:52 +0100)
Set the filename for every compilation unit as realtive to obtain a
position independent dump.

* lisp/loadup.el: Modify filename for every compilation unit as
position independent.

* src/pdumper.c (dump_do_dump_relocation): Update to be invocation
directory relative.

lisp/loadup.el
src/pdumper.c

index 97525b2708660ec2069445dd2f495187fc120701..bda9919cbbcc2dcc04acdb5591c99c5716b4640e 100644 (file)
@@ -449,6 +449,21 @@ lost after dumping")))
 ;; At this point, we're ready to resume undo recording for scratch.
 (buffer-enable-undo "*scratch*")
 
+(when (boundp 'comp-ctxt) ; FIXME better native-comp build discriminant?
+  ;; Set the filename for every compilation unit as realtive
+  ;; to obtain a position independent dump.
+  (let ((h (make-hash-table :test #'eq)))
+    (mapatoms (lambda (s)
+                (let ((f (symbol-function s)))
+                  (when (subr-native-elisp-p f)
+                    (puthash (subr-native-comp-unit f) nil h)))))
+    (maphash (lambda (cu _)
+              (native-comp-unit-set-file
+                cu
+               (file-relative-name (native-comp-unit-file cu)
+                                   invocation-directory)))
+            h)))
+
 (when (hash-table-p purify-flag)
   (let ((strings 0)
         (vectors 0)
index 03c31681cd516d58327d42028492909181b37d4a..7fbacfe4a1a9093fc71c3c0daf8424f2008ec470 100644 (file)
@@ -5298,7 +5298,8 @@ dump_do_dump_relocation (const uintptr_t dump_base,
       {
        struct Lisp_Native_Comp_Unit *comp_u =
          dump_ptr (dump_base, reloc_offset);
-       comp_u->handle = dynlib_open (SSDATA (comp_u->file));
+       comp_u->handle =
+         dynlib_open (SSDATA (concat2 (Vinvocation_directory, comp_u->file)));
        if (!comp_u->handle)
          error ("%s", dynlib_error ());
        load_comp_unit (comp_u, true, false);