Rename LINKAGE-TABLE to ALIEN-LINKAGE-TABLE

Anticipating that FDEFNs can be subsumed by something other than 1st-class
objects, we'll need a unified space of lisp function pointers. I tried to pick
a non-conflicting name for such space, but "linkage table" really fits.
Therefore this change renames the existing table. It was FOREIGN-LINKAGE-TABLE
in CMUCL, but "ALIEN" requires fewer keystrokes and matches DEFINE-ALIEN.
This commit is contained in:
Douglas Katzman 2022-09-03 17:27:36 -04:00
parent d553587657
commit 851cbd2b77
40 changed files with 110 additions and 110 deletions

View file

@ -19,7 +19,7 @@ also utilized to allow references to as-of-yet unknown aliens.
The SBCL implementation is somewhat simplified from the CMUCL one by
Timothy Moore, but the basic idea and mechanism remain identical:
instead of having addresses from @code{dlsym(3)} in the core, we have
addresses to an mmapped memory area (@code{LINKAGE_TABLE_SPACE}) that
addresses to an mmapped memory area (@code{ALIEN_LINKAGE_TABLE_SPACE}) that
is initialized at startup to contain jumps & references to the correct
addresses, based on information stored on the lisp side in
@code{*LINKAGE-INFO*}.
@ -72,8 +72,8 @@ is used by SB-POSIX.)
Find a memory area for the linkage-table, and add it for the OS in
@file{src/compiler/target/parms.lisp} by defining
@code{SB-VM:LINKAGE-TABLE-SPACE-START} and
@code{SB-VM:LINKAGE-TABLE-SPACE-END}. See existing ports and CMUCL for
@code{SB-VM:ALIEN-LINKAGE-TABLE-SPACE-START} and
@code{SB-VM:ALIEN-LINKAGE-TABLE-SPACE-END}. See existing ports and CMUCL for
examples.
@subsubsection Porting to new architectures
@ -82,7 +82,7 @@ Write @code{arch_write_linkage_table_entry}.
Write @code{FOREIGN-SYMBOL-DATAREF} VOP.
Define correct @code{SB-VM:LINKAGE-TABLE-ENTRY-SIZE} in
Define correct @code{SB-VM:ALIEN-LINKAGE-TABLE-ENTRY-SIZE} in
@file{src/compiler/target/parms.lisp}.
@page
@ -105,7 +105,7 @@ signalling the appropriate error.
These placeholder addresses get recorded in the linkage-table.
When new shared objects are loaded @code{UPDATE-LINKAGE-TABLE} is
When new shared objects are loaded @code{UPDATE-ALIEN-LINKAGE-TABLE} is
called, which in turn attempts to resolve all currently undefined
aliens, and registers the correct addresses for them in the
linkage-table.

View file

@ -59,7 +59,7 @@
#-sb-thread
(progn
;; Each of these loads of a fixup loads the address of a linkage table entry,
;; that is, if LINKAGE-TABLE-SPACE-START is #xF0200000, then the first load puts
;; that is, if ALIEN-LINKAGE-TABLE-SPACE-START is #xF0200000, then the first load puts
;; #xF0200000+something, not the address of current_control_frame_pointer,
;; into register nl2.
;; This is kinda dumb because first of all we could have calculated the address

View file

@ -92,7 +92,7 @@ will be signalled when the core is saved -- this is orthogonal from DONT-SAVE."
;; If OLD is non-NIL, then we're passing "true" which causes all foreign
;; symbols to get looked up again. Otherwise we're passing "false"
;; which only tries to find symbols that aren't already found.
(update-linkage-table old))))
(update-alien-linkage-table old))))
pathname))
(defun unload-shared-object (pathname)
@ -108,7 +108,7 @@ Experimental."
(when old
(dlclose-or-lose old)
(setf *shared-objects* (remove old *shared-objects*))
(update-linkage-table t)
(update-alien-linkage-table t)
;; Return T for unloaded, vs whatever update-linkage-info returns
t)))))

View file

@ -50,7 +50,7 @@ if the symbol isn't found."
(defun foreign-reinit ()
#+os-provides-dlopen (reopen-shared-objects)
(update-linkage-table t))
(update-alien-linkage-table t))
;;; Cleanups before saving a core
(defun foreign-deinit ()
@ -64,10 +64,10 @@ if the symbol isn't found."
(declare (ignorable sap))
(let ((addr (sap-int sap)))
(declare (ignorable addr))
(when (<= sb-vm:linkage-table-space-start
(when (<= sb-vm:alien-linkage-table-space-start
addr
sb-vm:linkage-table-space-end)
(let ((table-index (sb-vm::linkage-table-index-from-address addr)))
sb-vm:alien-linkage-table-space-end)
(let ((table-index (sb-vm::alien-linkage-table-index-from-address addr)))
(dohash ((key value) (car *linkage-info*) :locked t)
(when (= value table-index)
(return-from sap-foreign-symbol (if (listp key) (car key) key))))))

View file

@ -61,9 +61,9 @@
(or (awhen (with-system-mutex ((hash-table-lock ht))
(or (gethash key ht)
(let* ((index (hash-table-count ht))
(capacity (floor (- sb-vm:linkage-table-space-end
sb-vm:linkage-table-space-start)
sb-vm:linkage-table-entry-size)))
(capacity (floor (- sb-vm:alien-linkage-table-space-end
sb-vm:alien-linkage-table-space-start)
sb-vm:alien-linkage-table-entry-size)))
(when (< index capacity)
(multiple-value-bind (defined real-address) (dlsym-wrapper t)
(unless defined (push key (cdr info)))
@ -71,7 +71,7 @@
(if datap 1 0))
(logically-readonlyize name)
(setf (gethash key ht) index))))))
(sb-vm::linkage-table-entry-address it))
(sb-vm::alien-alien-linkage-table-entry-address it))
(error "Linkage-table full (~D entries): cannot link ~S."
(hash-table-count ht) name))))
@ -86,9 +86,9 @@
;;; If the shared-object-handle in which each symbol was originally found were
;;; stored in linkage-info, we could know which will become undefined on unload.
;;; The only "problem" is my lack of motivation to change this further.
(defun update-linkage-table (full-scan)
(defun update-alien-linkage-table (full-scan)
;; This symbol is of course itself a prelinked symbol.
(let* ((n-prelinked (extern-alien "lisp_linkage_table_n_prelinked" int))
(let* ((n-prelinked (extern-alien "alien_linkage_table_n_prelinked" int))
(info *linkage-info*)
(ht (car info))
;; for computing anew the list of undefined symbols

View file

@ -593,9 +593,9 @@ structure representations")
"READ-ONLY-SPACE-START" "READ-ONLY-SPACE-END"
"STATIC-SPACE-START" "STATIC-SPACE-END" "*STATIC-SPACE-FREE-POINTER*"
"STATIC-CODE-SPACE-START" "STATIC-CODE-SPACE-END" "*STATIC-CODE-SPACE-FREE-POINTER*"
"LINKAGE-TABLE-SPACE-START"
"LINKAGE-TABLE-SPACE-END"
"LINKAGE-TABLE-ENTRY-SIZE"
"ALIEN-LINKAGE-TABLE-SPACE-START"
"ALIEN-LINKAGE-TABLE-SPACE-END"
"ALIEN-LINKAGE-TABLE-ENTRY-SIZE"
#+sb-safepoint "GC-SAFEPOINT-PAGE-ADDR"
#+sb-safepoint "GC-SAFEPOINT-TRAP-OFFSET"
"THREAD-STATE-WORD-SLOT"
@ -1641,7 +1641,7 @@ SB-KERNEL) have been undone, but probably more remain.")
"SYSTEM-CONDITION-CONTEXT"
"REINIT-INTERNAL-REAL-TIME"
"SYSTEM-INTERNAL-RUN-TIME"
"UPDATE-LINKAGE-TABLE" "VECTOR-SAP"
"UPDATE-ALIEN-LINKAGE-TABLE" "VECTOR-SAP"
"WAIT-UNTIL-FD-USABLE"
"WITH-CODE-PAGES-PINNED"
"WITH-DEADLINE"

View file

@ -209,7 +209,7 @@
(ash 1 (tn-offset lr-tn))))
;; select the C function index as per *LINKAGE-SPACE-PREDEFINED-ENTRIES*
(let ((index (if (eq type 'list) 1 0)))
(inst ldr alloc-tn (@ null-tn (- (linkage-table-entry-address index)
(inst ldr alloc-tn (@ null-tn (- (alien-alien-linkage-table-entry-address index)
nil-value))))
(inst blx alloc-tn)
(inst word (logior #xe8bd0000 ; POP {rN, lr}

View file

@ -78,8 +78,8 @@
(defconstant static-space-start #x08000000)
(defconstant static-space-end #x097fff00)
(defconstant linkage-table-space-start #x0a000000)
(defconstant linkage-table-space-end #x0b000000))
(defconstant alien-linkage-table-space-start #x0a000000)
(defconstant alien-linkage-table-space-end #x0b000000))
#+gencgc
(progn
@ -88,8 +88,8 @@
#+openbsd
(!gencgc-space-setup #x04000000 :dynamic-space-start #x10000000))
(defconstant linkage-table-growth-direction :down)
(defconstant linkage-table-entry-size 16)
(defconstant alien-linkage-table-growth-direction :down)
(defconstant alien-linkage-table-entry-size 16)
;;; Link these as data entries so that we store only the address of the
;;; handwritten assembly code in the linkage able, and not a trampoline
;;; to the trampoline. The ALLOCATION macro just wants an address.

View file

@ -72,8 +72,8 @@
(defconstant static-space-start #x08000000)
(defconstant static-space-end #x097fff00)
(defconstant linkage-table-space-start #x0a000000)
(defconstant linkage-table-space-end #x0b000000)
(defconstant alien-linkage-table-space-start #x0a000000)
(defconstant alien-linkage-table-space-end #x0b000000)
#+(or linux openbsd)
(progn
(defparameter dynamic-0-space-start #x4f000000)
@ -87,8 +87,8 @@
#-darwin #x1000000000
#+darwin #x7003000000)
(defconstant linkage-table-growth-direction :up)
(defconstant linkage-table-entry-size 16)
(defconstant alien-linkage-table-growth-direction :up)
(defconstant alien-linkage-table-entry-size 16)
;;;; other miscellaneous constants

View file

@ -140,7 +140,7 @@
(let ((stop (1- (ash 1 n-word-bits)))
(start dynamic-space-start))
(dolist (other-start (list read-only-space-start static-space-start
linkage-table-space-start))
alien-linkage-table-space-start))
(declare (notinline <)) ; avoid dead code note
(when (< start other-start)
(setf stop (min stop other-start))))

View file

@ -264,7 +264,7 @@
(defvar *immobile-text*)
(defvar *immobile-space-map* nil))
;;; This ignores linkage-table-core-space-id
;;; This ignores alien-linkage-table-core-space-id
;;; which is never present in the core file.
(defconstant max-core-space-id (+ 3 #+immobile-space 2
#+darwin-jit 1))
@ -2360,9 +2360,9 @@ Legal values for OFFSET are -4, -8, -12, ..."
(cold-fun-entry-addr (cold-symbol-function name))
kind :static-call))))
(defun linkage-table-note-symbol (symbol-name datap)
(defun alien-linkage-table-note-symbol (symbol-name datap)
"Register a symbol and return its address in proto-linkage-table."
(sb-vm::linkage-table-entry-address
(sb-vm::alien-alien-linkage-table-entry-address
(ensure-gethash (if datap (list symbol-name) symbol-name)
*cold-foreign-symbol-table*
(hash-table-count *cold-foreign-symbol-table*))))
@ -2928,8 +2928,8 @@ Legal values for OFFSET are -4, -8, -12, ..."
(:assembly-routine* (lookup-assembler-reference name :indirect))
(:asm-routine-nil-offset
(- (lookup-assembler-reference name) sb-vm:nil-value))
(:foreign (linkage-table-note-symbol string nil))
(:foreign-dataref (linkage-table-note-symbol string t))
(:foreign (alien-linkage-table-note-symbol string nil))
(:foreign-dataref (alien-linkage-table-note-symbol string t))
(:code-object (descriptor-bits code-obj))
#+sb-thread ; ENSURE-SYMBOL-TLS-INDEX isn't defined otherwise
(:symbol-tls-index (ensure-symbol-tls-index name))
@ -2977,7 +2977,7 @@ Legal values for OFFSET are -4, -8, -12, ..."
(aver (zerop (rem sb-vm:fixedobj-space-size (* 32 sb-vm:immobile-card-bytes))))
#-gencgc
(check sb-vm:dynamic-0-space-start sb-vm:dynamic-0-space-end :dynamic-0)
(check sb-vm:linkage-table-space-start sb-vm:linkage-table-space-end :linkage-table))))
(check sb-vm:alien-linkage-table-space-start sb-vm:alien-linkage-table-space-end :linkage-table))))
;;;; emitting C header file
@ -3665,7 +3665,7 @@ III. initially undefined function references (alphabetically):
(let ((name (car entry)))
(format t " ~:[ ~;(D)~] ~8x = ~a~%"
(listp name)
(sb-vm::linkage-table-entry-address (cdr entry))
(sb-vm::alien-alien-linkage-table-entry-address (cdr entry))
(car (ensure-list name)))))
#+sb-thread
@ -3855,7 +3855,7 @@ III. initially undefined function references (alphabetically):
;; Prefill some linkage table entries perhaps
(loop for (name datap) in sb-vm::*linkage-space-predefined-entries*
do (linkage-table-note-symbol name datap))
do (alien-linkage-table-note-symbol name datap))
;; Now that we've successfully read our only input file (by
;; loading the symbol table, if any), it's a good time to ensure

View file

@ -83,7 +83,7 @@
((spaces (append `((read-only ,ro-space-size)
#+(and win32 x86-64)
(seh-data ,(symbol-value '+backend-page-bytes+) win64-seh-data-addr)
(linkage-table ,small-space-size)
(alien-linkage-table ,small-space-size)
#+sb-safepoint
;; Must be just before NIL.
(safepoint ,(symbol-value '+backend-page-bytes+) gc-safepoint-page-addr)
@ -99,7 +99,7 @@
appending
(let* ((relocatable
;; READONLY is usually movable now.
;; TODO: linkage-table could move with code, if the CPU
;; TODO: alien-linkage-table could move with code, if the CPU
;; prefers PC-relative jumps, and we emit better code
;; (which we don't- for x86 we jmp via RBX always)
(member space '(fixedobj text

View file

@ -50,17 +50,17 @@
0))
;;; the address of the linkage table entry for table index I.
(defun linkage-table-entry-address (i)
(ecase linkage-table-growth-direction
(:up (+ (* i linkage-table-entry-size) linkage-table-space-start))
(:down (- linkage-table-space-end (* (1+ i) linkage-table-entry-size)))))
(defun alien-alien-linkage-table-entry-address (i)
(ecase alien-linkage-table-growth-direction
(:up (+ (* i alien-linkage-table-entry-size) alien-linkage-table-space-start))
(:down (- alien-linkage-table-space-end (* (1+ i) alien-linkage-table-entry-size)))))
(defun linkage-table-index-from-address (addr)
(ecase linkage-table-growth-direction
(defun alien-linkage-table-index-from-address (addr)
(ecase alien-linkage-table-growth-direction
(:up
(floor (- addr linkage-table-space-start) linkage-table-entry-size))
(floor (- addr alien-linkage-table-space-start) alien-linkage-table-entry-size))
(:down
(1- (floor (- linkage-table-space-end addr) linkage-table-space-end)))))
(1- (floor (- alien-linkage-table-space-end addr) alien-linkage-table-space-end)))))
(defconstant-eqx +all-static-fdefns+
#.(concatenate 'vector +c-callable-fdefns+ +static-fdefns+) #'equalp)

View file

@ -250,8 +250,8 @@
(let ((cur-nfp (current-nfp-tn vop)))
(when cur-nfp
(store-stack-tn nfp-save cur-nfp))
;; (linkage-table-entry-address 0) is "call-into-c" in mips-assem.S
(inst lw tramp null-tn (- (linkage-table-entry-address 0) nil-value))
;; (alien-alien-linkage-table-entry-address 0) is "call-into-c" in mips-assem.S
(inst lw tramp null-tn (- (alien-alien-linkage-table-entry-address 0) nil-value))
(inst nop)
(inst jal tramp)
(inst move cfunc function)

View file

@ -58,8 +58,8 @@
(progn
(!gencgc-space-setup #x04000000 :dynamic-space-start #x4f000000)
(defconstant linkage-table-entry-size 4)
(defconstant linkage-table-growth-direction :down)
(defconstant alien-linkage-table-entry-size 4)
(defconstant alien-linkage-table-growth-direction :down)
(setq *linkage-space-predefined-entries* '(("call_into_c" nil)))
;; C stack grows downward from 0x80000000

View file

@ -26,8 +26,8 @@
(when cur-nfp
(store-stack-tn nfp-save cur-nfp))
(move nl0 object)
;; (linkage-table-entry-address 0) is "call-into-c" in mips-assem.S
(inst lw tramp null-tn (- (linkage-table-entry-address 0) nil-value))
;; (alien-alien-linkage-table-entry-address 0) is "call-into-c" in mips-assem.S
(inst lw tramp null-tn (- (alien-alien-linkage-table-entry-address 0) nil-value))
(inst li cfunc (make-fixup "debug_print" :foreign))
(inst jal tramp)
(inst subu nsp-tn 16)

View file

@ -93,8 +93,8 @@
(defconstant static-space-start #x08000000)
(defconstant static-space-end #x097fff00)
(defconstant linkage-table-space-start #x0a000000)
(defconstant linkage-table-space-end #x0b000000))
(defconstant alien-linkage-table-space-start #x0a000000)
(defconstant alien-linkage-table-space-end #x0b000000))
;;; While on gencgc we don't.
#+gencgc
@ -105,8 +105,8 @@
#+netbsd #x4f000000
#+openbsd #x4f000000)
(defconstant linkage-table-growth-direction :up)
(defconstant linkage-table-entry-size 16)
(defconstant alien-linkage-table-growth-direction :up)
(defconstant alien-linkage-table-entry-size 16)
#+linux
(progn

View file

@ -86,16 +86,16 @@
(defconstant static-space-start #x08000000)
(defconstant static-space-end #x097fff00)
(defconstant linkage-table-space-start #x0a000000)
(defconstant linkage-table-space-end #x0b000000))
(defconstant alien-linkage-table-space-start #x0a000000)
(defconstant alien-linkage-table-space-end #x0b000000))
;;; While on gencgc we don't.
#+gencgc (!gencgc-space-setup #x04000000
:read-only-space-size 0
:dynamic-space-start #x1000000000)
(defconstant linkage-table-growth-direction :up)
(defconstant linkage-table-entry-size #+little-endian 28 #+big-endian 24)
(defconstant alien-linkage-table-growth-direction :up)
(defconstant alien-linkage-table-entry-size #+little-endian 28 #+big-endian 24)
#+linux
(progn

View file

@ -93,7 +93,7 @@
(define-tls-accessors load-stepping store-stepping
thread-stepping-slot sb-impl::*stepping*))
;;; TODO: these two macros would benefit from linkage-table space being
;;; TODO: these two macros would benefit from alien-linkage-table space being
;;; located below static space with linkage entries allocated downward
;;; from the end. Then the sequence would reduce to 2 instructions:
;;; lw temp (k)$NULL

View file

@ -69,15 +69,15 @@
(defconstant static-space-start #x08000000)
(defconstant static-space-end #x097fff00)
(defconstant linkage-table-space-start #x0a000000)
(defconstant linkage-table-space-end #x0b000000))
(defconstant alien-linkage-table-space-start #x0a000000)
(defconstant alien-linkage-table-space-end #x0b000000))
;;; While on gencgc we don't.
#+gencgc
(!gencgc-space-setup #x04000000 :dynamic-space-start #x4f000000)
(defconstant linkage-table-entry-size #-64-bit 8 #+64-bit 24)
(defconstant linkage-table-growth-direction :down)
(defconstant alien-linkage-table-entry-size #-64-bit 8 #+64-bit 24)
(defconstant alien-linkage-table-growth-direction :down)
(setq *linkage-space-predefined-entries* '(#+gencgc("alloc" nil)
#+gencgc("alloc_list" nil)))

View file

@ -83,10 +83,10 @@
(!gencgc-space-setup #x0f800000 :dynamic-space-start #x30000000)
;; Size of one linkage-table entry in bytes. See comment in
;; Size of one alien-linkage-table entry in bytes. See comment in
;; src/runtime/sparc-arch.c
(defconstant linkage-table-entry-size 16)
(defconstant linkage-table-growth-direction :up)
(defconstant alien-linkage-table-entry-size 16)
(defconstant alien-linkage-table-growth-direction :up)
(defenum (:start 8)

View file

@ -108,8 +108,8 @@
:dynamic-space-start #x1000000000
#+openbsd :dynamic-space-size #+openbsd #x1bcf0000)
(defconstant linkage-table-growth-direction :up)
(defconstant linkage-table-entry-size 16)
(defconstant alien-linkage-table-growth-direction :up)
(defconstant alien-linkage-table-entry-size 16)
(defenum (:start 8)

View file

@ -174,9 +174,9 @@
#+netbsd (space-setup #x20000000 :dynamic-space-start #x60000000)
#+darwin (space-setup #x04000000 :dynamic-space-start #x10000000)
;;; Size of one linkage-table entry in bytes.
(defconstant linkage-table-entry-size 8)
(defconstant linkage-table-growth-direction :up)
;;; Size of one alien-linkage-table entry in bytes.
(defconstant alien-linkage-table-entry-size 8)
(defconstant alien-linkage-table-growth-direction :up)
(defenum (:start 8)

View file

@ -126,7 +126,7 @@ void arch_write_linkage_table_entry(int index, void *target_addr, int datap)
{
// allocate successive entries downward
char *reloc_addr =
(char*)LINKAGE_TABLE_SPACE_END - (index + 1) * LINKAGE_TABLE_ENTRY_SIZE;
(char*)ALIEN_LINKAGE_TABLE_SPACE_END - (index + 1) * ALIEN_LINKAGE_TABLE_ENTRY_SIZE;
if (datap) {
*(unsigned long *)reloc_addr = (unsigned long)target_addr;
return;

View file

@ -151,7 +151,7 @@ void arch_install_interrupt_handlers()
void arch_write_linkage_table_entry(int index, void *target_addr, int datap)
{
THREAD_JIT(0);
char *reloc_addr = (char*)LINKAGE_TABLE_SPACE_START + index * LINKAGE_TABLE_ENTRY_SIZE;
char *reloc_addr = (char*)ALIEN_LINKAGE_TABLE_SPACE_START + index * ALIEN_LINKAGE_TABLE_ENTRY_SIZE;
if (datap) {
*(unsigned long *)reloc_addr = (unsigned long)target_addr;

View file

@ -121,10 +121,10 @@ os_validate(int attributes, os_vm_address_t addr, os_vm_size_t len, int space_id
{
int __attribute((unused))
executable = (space_id == READ_ONLY_CORE_SPACE_ID) ||
(space_id == LINKAGE_TABLE_CORE_SPACE_ID) ||
(space_id == ALIEN_LINKAGE_TABLE_CORE_SPACE_ID) ||
(space_id == STATIC_CODE_CORE_SPACE_ID),
jit = (space_id == STATIC_CODE_CORE_SPACE_ID) || (space_id == DYNAMIC_CORE_SPACE_ID)
? 1 : (space_id == LINKAGE_TABLE_CORE_SPACE_ID) ? 2 : 0;
? 1 : (space_id == ALIEN_LINKAGE_TABLE_CORE_SPACE_ID) ? 2 : 0;
int protection;
int flags = 0;
@ -602,7 +602,7 @@ The system may fail to start.\n",
*/
getrlimit (RLIMIT_DATA, &rl);
if (dynamic_space_size + READ_ONLY_SPACE_SIZE + STATIC_SPACE_SIZE +
LINKAGE_TABLE_SPACE_SIZE + wantfree > rl.rlim_cur)
ALIEN_LINKAGE_TABLE_SPACE_SIZE + wantfree > rl.rlim_cur)
fprintf (stderr,
"RUNTIME WARNING: data size resource limit may be too low,\n"
" try decreasing the dynamic space size with --dynamic-space-size\n"

View file

@ -92,7 +92,7 @@ open_binary(char *filename, int mode)
int lisp_code_in_elf() { return 0; }
#else
extern __attribute__((weak)) lispobj
lisp_code_start, lisp_jit_code, lisp_code_end, lisp_linkage_values;
lisp_code_start, lisp_jit_code, lisp_code_end, alien_linkage_values;
int lisp_code_in_elf() { return &lisp_code_start != 0; }
#endif
@ -741,7 +741,7 @@ process_directory(int count, struct ndir_entry *entry,
(uword_t)&lisp_code_start, (uword_t)&lisp_code_end,
text_space_highwatermark);
#endif
// Prefill the Lisp linkage table so that shrinkwrapped executables which link in
// Prefill the alien linkage table so that shrinkwrapped executables which link in
// all their C library dependencies can avoid linking with -ldl.
// All data references are potentially needed because aliencomp doesn't emit
// SAP-REF-n in a way that admits elision of the linkage entry. e.g.
@ -752,12 +752,12 @@ process_directory(int count, struct ndir_entry *entry,
// but that's more of a change to the asm instructions than I'm comfortable making;
// whereas "CALL linkage_entry_for_f" -> "CALL f" is quite straightforward.
// (Rarely would a jmp indirection be used; maybe for newly compiled code?)
lispobj* ptr = &lisp_linkage_values;
lispobj* ptr = &alien_linkage_values;
gc_assert(ptr);
int entry_index = 0;
int count;
extern int lisp_linkage_table_n_prelinked;
count = lisp_linkage_table_n_prelinked = *ptr++;
extern int alien_linkage_table_n_prelinked;
count = alien_linkage_table_n_prelinked = *ptr++;
for ( ; count-- ; entry_index++ ) {
boolean datap = *ptr == (lispobj)-1; // -1 can't be a function address
if (datap)

View file

@ -497,7 +497,7 @@ arch_write_linkage_table_entry(int index, void *target_addr, int datap)
{
// allocate successive entries downward
char *reloc_addr =
(char*)LINKAGE_TABLE_SPACE_END - (index + 1) * LINKAGE_TABLE_ENTRY_SIZE;
(char*)ALIEN_LINKAGE_TABLE_SPACE_END - (index + 1) * ALIEN_LINKAGE_TABLE_ENTRY_SIZE;
*(unsigned int *)reloc_addr = (unsigned int)target_addr;
}

View file

@ -168,7 +168,7 @@ os_dlsym_default(char *name)
}
#endif
int lisp_linkage_table_n_prelinked;
int alien_linkage_table_n_prelinked;
void os_link_runtime()
{
int entry_index = 0;
@ -178,12 +178,12 @@ void os_link_runtime()
void* result;
int j;
if (lisp_linkage_table_n_prelinked)
if (alien_linkage_table_n_prelinked)
return; // Linkage was already performed by coreparse
struct vector* symbols = VECTOR(SymbolValue(REQUIRED_FOREIGN_SYMBOLS,0));
lisp_linkage_table_n_prelinked = vector_len(symbols);
for (j = 0 ; j < lisp_linkage_table_n_prelinked ; ++j)
alien_linkage_table_n_prelinked = vector_len(symbols);
for (j = 0 ; j < alien_linkage_table_n_prelinked ; ++j)
{
lispobj item = symbols->data[j];
datap = listp(item);

View file

@ -608,7 +608,7 @@ ppc_flush_icache(os_vm_address_t address, os_vm_size_t length)
void
arch_write_linkage_table_entry(int index, void *target_addr, int datap)
{
char *reloc_addr = (char*)LINKAGE_TABLE_SPACE_START + index * LINKAGE_TABLE_ENTRY_SIZE;
char *reloc_addr = (char*)ALIEN_LINKAGE_TABLE_SPACE_START + index * ALIEN_LINKAGE_TABLE_ENTRY_SIZE;
if (datap) {
*(unsigned long *)reloc_addr = (unsigned long)target_addr;
return;

View file

@ -165,7 +165,7 @@ void arch_write_linkage_table_entry(int index, void *target_addr, int datap)
{
// allocate successive entries downward
char *reloc_addr =
(char*)LINKAGE_TABLE_SPACE_END - (index + 1) * LINKAGE_TABLE_ENTRY_SIZE;
(char*)ALIEN_LINKAGE_TABLE_SPACE_END - (index + 1) * ALIEN_LINKAGE_TABLE_ENTRY_SIZE;
if (datap) {
*(unsigned long *)reloc_addr = (unsigned long)target_addr;
return;

View file

@ -304,7 +304,7 @@ void arch_install_interrupt_handlers()
void
arch_write_linkage_table_entry(int index, void *target_addr, int datap)
{
char *reloc_addr = (char*)LINKAGE_TABLE_SPACE_START + index * LINKAGE_TABLE_ENTRY_SIZE;
char *reloc_addr = (char*)ALIEN_LINKAGE_TABLE_SPACE_START + index * ALIEN_LINKAGE_TABLE_ENTRY_SIZE;
if (datap) {
*(unsigned long *)reloc_addr = (unsigned long)target_addr;
return;

View file

@ -88,7 +88,7 @@ boolean allocate_hardwired_spaces(boolean hard_failp)
int id;
} preinit_spaces[] = {
{ READ_ONLY_SPACE_START, READ_ONLY_SPACE_SIZE, READ_ONLY_CORE_SPACE_ID },
{ LINKAGE_TABLE_SPACE_START, LINKAGE_TABLE_SPACE_SIZE, LINKAGE_TABLE_CORE_SPACE_ID },
{ ALIEN_LINKAGE_TABLE_SPACE_START, ALIEN_LINKAGE_TABLE_SPACE_SIZE, ALIEN_LINKAGE_TABLE_CORE_SPACE_ID },
{ STATIC_SPACE_START, STATIC_SPACE_SIZE, STATIC_CORE_SPACE_ID },
#ifdef LISP_FEATURE_DARWIN_JIT
{ STATIC_CODE_SPACE_START, STATIC_CODE_SPACE_SIZE, STATIC_CODE_CORE_SPACE_ID },

View file

@ -33,8 +33,8 @@
#define STATIC_CODE_SPACE_SIZE (STATIC_CODE_SPACE_END - STATIC_CODE_SPACE_START)
#endif
#define LINKAGE_TABLE_SPACE_SIZE \
(LINKAGE_TABLE_SPACE_END - LINKAGE_TABLE_SPACE_START)
#define ALIEN_LINKAGE_TABLE_SPACE_SIZE \
(ALIEN_LINKAGE_TABLE_SPACE_END - ALIEN_LINKAGE_TABLE_SPACE_START)
#if !defined(__ASSEMBLER__)
#include "thread.h"

View file

@ -208,7 +208,7 @@ void unmap_gc_page()
* bundle'' that rolls up your patch, redumps and -- presto -- 100MiB
* program is fixed by sending and loading a 50KiB thingie.
*
* However, until LISP_FEATURE_LINKAGE_TABLE, if your bug were fixed
* However, until LISP_FEATURE_ALIEN_LINKAGE_TABLE, if your bug were fixed
* by modifying two lines of _C_ sources, a customer described above
* had to be ready to receive and reinstall a new 100MiB
* executable. With the aid of code below, deploying such a fix

View file

@ -518,7 +518,7 @@ arch_install_interrupt_handlers()
void
arch_write_linkage_table_entry(int index, void *target_addr, int datap)
{
char *reloc_addr = (char*)LINKAGE_TABLE_SPACE_START + index * LINKAGE_TABLE_ENTRY_SIZE;
char *reloc_addr = (char*)ALIEN_LINKAGE_TABLE_SPACE_START + index * ALIEN_LINKAGE_TABLE_ENTRY_SIZE;
if (datap) {
*(uword_t *)reloc_addr = (uword_t)target_addr;
return;

View file

@ -366,7 +366,7 @@ void
arch_write_linkage_table_entry(int index, void *target_addr, int datap)
{
// 'volatile' works around a spurious GCC warning
volatile char *reloc_addr = (char*)LINKAGE_TABLE_SPACE_START + index * LINKAGE_TABLE_ENTRY_SIZE;
volatile char *reloc_addr = (char*)ALIEN_LINKAGE_TABLE_SPACE_START + index * ALIEN_LINKAGE_TABLE_ENTRY_SIZE;
if (datap) {
*(unsigned long *)reloc_addr = (unsigned long)target_addr;
return;

View file

@ -216,7 +216,7 @@
;; Should not have a call to SET-SYMBOL-GLOBAL-VALUE>
(assert (not (ctu:find-code-constants f :type 'sb-kernel:fdefn))))))
(with-test (:name :linkage-table-bogosity)
(with-test (:name :alien-linkage-table-bogosity)
(let ((strings (map 'list (lambda (x) (if (consp x) (car x) x))
sb-vm::+required-foreign-symbols+)))
(assert (= (length (remove-duplicates strings :test 'string=))

View file

@ -6,7 +6,7 @@
#:directory-core-entry-type-code
#:initial-fun-core-entry-type-code
#:page-table-core-entry-type-code
#:linkage-table-core-entry-type-code
#:alien-linkage-table-core-entry-type-code
#:end-core-entry-type-code
#:max-core-space-id
;;
@ -16,7 +16,7 @@
#:dynamic-core-space-id
#:immobile-fixedobj-core-space-id
#:immobile-text-core-space-id
#:linkage-table-core-space-id
#:alien-linkage-table-core-space-id
#:deflated-core-space-id-flag))
(in-package "SB-COREFILE")
@ -43,7 +43,7 @@
(defconstant directory-core-entry-type-code 3861)
(defconstant initial-fun-core-entry-type-code 3863)
(defconstant page-table-core-entry-type-code 3880)
(defconstant linkage-table-core-entry-type-code 3881)
(defconstant alien-linkage-table-core-entry-type-code 3881)
(defconstant end-core-entry-type-code 3840)
(defconstant dynamic-core-space-id 1)
@ -55,4 +55,4 @@
(defconstant deflated-core-space-id-flag 8)
;;; this space-id is not present in the core file
;;; but we need a unique ID to pass to os_validate
(defconstant linkage-table-core-space-id 101)
(defconstant alien-linkage-table-core-space-id 101)

View file

@ -454,12 +454,12 @@
(let* ((linkage-bounds
(make-bounds
(symbol-global-value
(find-target-symbol (package-id "SB-VM") "LINKAGE-TABLE-SPACE-START" spaces :physical))
(find-target-symbol (package-id "SB-VM") "ALIEN-LINKAGE-TABLE-SPACE-START" spaces :physical))
(symbol-global-value
(find-target-symbol (package-id "SB-VM") "LINKAGE-TABLE-SPACE-END" spaces :physical))))
(find-target-symbol (package-id "SB-VM") "ALIEN-LINKAGE-TABLE-SPACE-END" spaces :physical))))
(linkage-entry-size
(symbol-global-value
(find-target-symbol (package-id "SB-VM") "LINKAGE-TABLE-ENTRY-SIZE"
(find-target-symbol (package-id "SB-VM") "ALIEN-LINKAGE-TABLE-ENTRY-SIZE"
spaces :physical)))
(linkage-symbols (compute-linkage-symbols spaces))
(nil-object (compute-nil-object spaces))
@ -1815,7 +1815,7 @@
"~% .section .rodata~%"))
(format asm-file " .globl ~A~%~:*~A:
.quad ~d # ct~%"
(labelize "lisp_linkage_values")
(labelize "alien_linkage_values")
(length (core-linkage-symbols core)))
;; -1 (not a plausible function address) signifies that word
;; following it is a data, not text, reference.