summaryrefslogtreecommitdiffstats
path: root/src/amd/common/ac_rtld.h
diff options
context:
space:
mode:
authorNicolai Hähnle <[email protected]>2018-05-04 16:00:35 +0200
committerMarek Olšák <[email protected]>2019-06-12 20:28:23 -0400
commitb3be346c68953e693b79459434ff7ee9cd7b9bed (patch)
treead33079f63963bc078551616ee1ba86373c843b0 /src/amd/common/ac_rtld.h
parent608257cf82f49109c8f1a2bab1d6e30fa14f9ba7 (diff)
amd/common: add a more powerful runtime linker
Using an explicit linker instead of just concatenating .text sections will allow us to start using .rodata sections and explicit descriptions of data on LDS that is shared between stages. Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/amd/common/ac_rtld.h')
-rw-r--r--src/amd/common/ac_rtld.h88
1 files changed, 88 insertions, 0 deletions
diff --git a/src/amd/common/ac_rtld.h b/src/amd/common/ac_rtld.h
new file mode 100644
index 00000000000..0d93488fbbb
--- /dev/null
+++ b/src/amd/common/ac_rtld.h
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2014-2019 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef AC_RTLD_H
+#define AC_RTLD_H
+
+#include <stdbool.h>
+#include <stdint.h>
+#include <stddef.h>
+
+struct ac_rtld_part;
+struct ac_shader_config;
+
+/* Lightweight wrapper around underlying ELF objects. */
+struct ac_rtld_binary {
+ /* Required buffer sizes, currently read/executable only. */
+ uint64_t rx_size;
+
+ uint64_t rx_end_markers;
+
+ unsigned num_parts;
+ struct ac_rtld_part *parts;
+};
+
+/**
+ * Callback function type used during upload to resolve external symbols that
+ * are not defined in any of the ELF binaries available to the linker.
+ *
+ * \param cb_data caller-defined data
+ * \param symbol NUL-terminated symbol name
+ * \param value to be filled in by the callback
+ * \return whether the symbol was found successfully
+ */
+typedef bool (*ac_rtld_get_external_symbol_cb)(
+ void *cb_data, const char *symbol, uint64_t *value);
+
+bool ac_rtld_open(struct ac_rtld_binary *binary, unsigned num_parts,
+ const char * const *elf_ptrs,
+ const size_t *elf_sizes);
+
+void ac_rtld_close(struct ac_rtld_binary *binary);
+
+bool ac_rtld_get_section_by_name(struct ac_rtld_binary *binary, const char *name,
+ const char **data, size_t *nbytes);
+
+bool ac_rtld_read_config(struct ac_rtld_binary *binary,
+ struct ac_shader_config *config);
+
+struct ac_rtld_upload_info {
+ struct ac_rtld_binary *binary;
+
+ /** GPU mapping of the read/executable buffer. */
+ uint64_t rx_va;
+
+ /** CPU mapping of the read/executable buffer */
+ char *rx_ptr;
+
+ /** Optional callback function that will be queried for symbols not
+ * defined in any of the binary's parts. */
+ ac_rtld_get_external_symbol_cb get_external_symbol;
+
+ /** Caller-defined data that will be passed to callback functions. */
+ void *cb_data;
+};
+
+bool ac_rtld_upload(struct ac_rtld_upload_info *u);
+
+#endif /* AC_RTLD_H */