From 1583c2e6f783521717736d5e67f1e6a0dfad0081 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Thu, 6 Feb 2025 15:23:04 +0100 Subject: [PATCH 1/3] Add runtime-path to DynamicLinking.md --- DynamicLinking.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/DynamicLinking.md b/DynamicLinking.md index fe287ec..3cbbc60 100644 --- a/DynamicLinking.md +++ b/DynamicLinking.md @@ -43,6 +43,8 @@ The current list of valid `type` codes are: - `4 / WASM_DYLINK_IMPORT_INFO` - Specify additional metadata about imports. +- `5 / WASM_DYLINK_RUNTIME_PATH` - Specify the runtime path, corresponding to `DT_RUNPATH` in an ELF `.dynamic` section. + For `WASM_DYLINK_MEM_INFO` the following fields are present in the subsection: @@ -117,6 +119,8 @@ The "import_info" type is defined as: The set of possible symbol flags are the same as those specified in [Linking](Linking.md). +For `WASM_DYLINK_RUNTIME_PATH` the payload is a valid UTF-8 byte sequence. + The "dylink" section should be the very first section in the module; this allows detection of whether a binary is a dynamic library without having to scan the entire contents. @@ -309,6 +313,25 @@ present in `WASM_DYLINK_NEEDED`: ) ``` +** `runtime-path` ** + +The `runtime-path` contains a single colon-separated sequence of directories. +The loader should look in these directories to locate `needed` dependencies that +do not contain a slash in their name. + +Dynamic string tokens: The loader should expand certain string tokens appearing +in the `runtime-path`. The tokens are as follows: + +* `$ORIGIN` and `${ORIGIN}` -- these expand to the directory containing the + shared object. + +* `$LIB` and `${LIB}` -- these expand to `lib` on `wasm32` architecture and + `lib64` on `wasm64` architecture. + +* `$PLATFORM` and `${PLATFORM}` -- these expand to the platform string for the + host system. E.g., `wasm32` or `wasm64`. + + **`export-info` / `import-info`** The `export-info` and `import-info` constructs correspond to From fb4240cecf1b4bb698e30bd97d434033c1bb5174 Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Thu, 6 Feb 2025 17:14:11 +0100 Subject: [PATCH 2/3] Remove $LIB and $PLATFORM --- DynamicLinking.md | 7 ------- 1 file changed, 7 deletions(-) diff --git a/DynamicLinking.md b/DynamicLinking.md index 3cbbc60..34a23bc 100644 --- a/DynamicLinking.md +++ b/DynamicLinking.md @@ -325,13 +325,6 @@ in the `runtime-path`. The tokens are as follows: * `$ORIGIN` and `${ORIGIN}` -- these expand to the directory containing the shared object. -* `$LIB` and `${LIB}` -- these expand to `lib` on `wasm32` architecture and - `lib64` on `wasm64` architecture. - -* `$PLATFORM` and `${PLATFORM}` -- these expand to the platform string for the - host system. E.g., `wasm32` or `wasm64`. - - **`export-info` / `import-info`** The `export-info` and `import-info` constructs correspond to From 7c49d5967d76f6a15839fbc37e7da2e2319c71ac Mon Sep 17 00:00:00 2001 From: Hood Chatham Date: Thu, 6 Feb 2025 17:29:58 +0100 Subject: [PATCH 3/3] Change from a single string to a list of strings --- DynamicLinking.md | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/DynamicLinking.md b/DynamicLinking.md index 34a23bc..5cf80be 100644 --- a/DynamicLinking.md +++ b/DynamicLinking.md @@ -119,7 +119,13 @@ The "import_info" type is defined as: The set of possible symbol flags are the same as those specified in [Linking](Linking.md). -For `WASM_DYLINK_RUNTIME_PATH` the payload is a valid UTF-8 byte sequence. +For `WASM_DYLINK_RUNTIME_PATH` the following fields are present in the +subsection: + +| Field | Type | Description | +| ---------------------- | --------------- | ------------------------------------- | +| runtime_path_count | `varuint32` | Number of runtime_path entries | +| runtime_path_entries | `string*` | string values of runtime_path entries | The "dylink" section should be the very first section in the module; this allows detection of whether a binary is a dynamic library without having to scan the @@ -315,9 +321,9 @@ present in `WASM_DYLINK_NEEDED`: ** `runtime-path` ** -The `runtime-path` contains a single colon-separated sequence of directories. -The loader should look in these directories to locate `needed` dependencies that -do not contain a slash in their name. +The `runtime-path` contains a list of paths. The loader should look in these +directories to locate `needed` dependencies that do not contain a slash in their +name. Dynamic string tokens: The loader should expand certain string tokens appearing in the `runtime-path`. The tokens are as follows: