Subject: GNU Emacs native compiled functions (was Re: Malicious Computer Architecture)
Aidan Kehoe <
kehoea@parhasard.net> writes:
I haven?t gone into the weeds of the GNU Emacs native-compiled function implementation, but it has to be doing something similar. The functions are not
in the data segment, they?re not in BSS, they?re not on the stack; that leaves
the heap.
On amd64, at least, instead of running them from a heap, it seems to be compiling elisp into .so files which it can then dlopen(), but it names
them `*.eln` instead of `*.so`:
: ~; shuf -n 8 /proc/$(pidof emacs)/maps
7f44e7cb3000-7f44e7cb4000 r--p 00005000 fe:01 1216485 /usr/lib/x86_64-linux-gnu/libgpm.so.2
7f44e8e34000-7f44e8e47000 r--p 00000000 fe:01 1212779 /usr/lib/x86_64-linux-gnu/libpango-1.0.so.0.5000.12
7f44c4151000-7f44c4154000 rw-p 00005000 fe:05 1323730 /home/user/.emacs.d/eln-cache/28.2-66fa0d00/nxml-parse-79a53381-b87f8800.eln
7f44c74a5000-7f44c74bb000 rw-p 00006000 fe:05 1320433 /home/user/.emacs.d/eln-cache/28.2-66fa0d00/cc-vars-6cc3f0fc-a4ab31d9.eln
7f44c544e000-7f44c5458000 rw-p 0000b000 fe:05 1323563 /home/user/.emacs.d/eln-cache/28.2-66fa0d00/with-editor-ad819b7b-2e1f7b93.eln
7f44c5383000-7f44c5384000 r--p 0000d000 fe:05 1321666 /home/user/.emacs.d/eln-cache/28.2-66fa0d00/log-edit-bc58b2d4-860d5c35.eln
7f44c52f5000-7f44c52f8000 r--p 00021000 fe:05 1323613 /home/user/.emacs.d/eln-cache/28.2-66fa0d00/magit-log-ffefa368-c52fff03.eln
7f44c50a5000-7f44c50a8000 r-xp 00001000 fe:05 1321734 /home/user/.emacs.d/eln-cache/28.2-66fa0d00/xdg-9947111f-70cd76a9.eln
: ~; file /home/user/.emacs.d/eln-cache/28.2-66fa0d00/nxml-parse-79a53381-b87f8800.eln /home/user/.emacs.d/eln-cache/28.2-66fa0d00/cc-vars-6cc3f0fc-a4ab31d9.eln /home/user/.emacs.d/eln-cache/28.2-66fa0d00/with-editor-ad819b7b-2e1f7b93.eln
/home/user/.emacs.d/eln-cache/28.2-66fa0d00/nxml-parse-79a53381-b87f8800.eln: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=ae37239bb67ec11b5d1eaf514df0660634fbd946, not stripped
/home/user/.emacs.d/eln-cache/28.2-66fa0d00/cc-vars-6cc3f0fc-a4ab31d9.eln: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=043e590c8a3917994270925abbfa6ec746488abb, not stripped
/home/user/.emacs.d/eln-cache/28.2-66fa0d00/with-editor-ad819b7b-2e1f7b93.eln: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=2bfb93008822275a66cad1c463d286f366388725, not stripped
: ~;
When I?ve disassembled these, they seem to indirect all their function
calls through a jump table, so that you can rebind existing symbols to
new functions and affect already-compiled code. I haven?t dug into it
in much detail, though, so I might be mistaken.
Kragen
--- PyGate Linux v1.5.19
* Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)