[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/9] Add module metadata macros, add qxl module annotations
From: |
Gerd Hoffmann |
Subject: |
[PATCH 1/9] Add module metadata macros, add qxl module annotations |
Date: |
Wed, 2 Jun 2021 11:17:19 +0200 |
Stealing an idea from the linux kernel: Place module metadata
in an .modinfo elf section. This patch adds macros and qxl module
annotations as example.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
include/qemu/module.h | 18 ++++++++++++++++++
hw/display/qxl.c | 4 ++++
2 files changed, 22 insertions(+)
diff --git a/include/qemu/module.h b/include/qemu/module.h
index 944d403cbd15..afb9656ba4e7 100644
--- a/include/qemu/module.h
+++ b/include/qemu/module.h
@@ -73,4 +73,22 @@ bool module_load_one(const char *prefix, const char
*lib_name, bool mayfail);
void module_load_qom_one(const char *type);
void module_load_qom_all(void);
+/*
+ * objdump -t -s -j .modinfo ${module}.so
+ */
+
+#define ___PASTE(a, b) a##b
+#define __PASTE(a, b) ___PASTE(a, b)
+
+#define modinfo(kind, value) \
+ static const char __PASTE(kind, __LINE__)[] \
+ __attribute__((__used__)) \
+ __attribute__((section(".modinfo"))) \
+ __attribute__((aligned(1))) \
+ = stringify(kind) "=" value
+
+#define module_obj(name) modinfo(obj, name)
+#define module_dep(name) modinfo(dep, name)
+#define module_arch(name) modinfo(arch, name)
+
#endif
diff --git a/hw/display/qxl.c b/hw/display/qxl.c
index 6e1f8ff1b2a7..84f99088e0a0 100644
--- a/hw/display/qxl.c
+++ b/hw/display/qxl.c
@@ -2522,6 +2522,7 @@ static const TypeInfo qxl_primary_info = {
.parent = TYPE_PCI_QXL,
.class_init = qxl_primary_class_init,
};
+module_obj("qxl-vga");
static void qxl_secondary_class_init(ObjectClass *klass, void *data)
{
@@ -2538,6 +2539,7 @@ static const TypeInfo qxl_secondary_info = {
.parent = TYPE_PCI_QXL,
.class_init = qxl_secondary_class_init,
};
+module_obj("qxl");
static void qxl_register_types(void)
{
@@ -2547,3 +2549,5 @@ static void qxl_register_types(void)
}
type_init(qxl_register_types)
+
+module_dep("ui-spice-core");
--
2.31.1
- [PATCH 0/9] [RFC] store module metadata in .modinfo elf section, Gerd Hoffmann, 2021/06/02
- [PATCH 3/9] virtio-gpu module annotations, Gerd Hoffmann, 2021/06/02
- [PATCH 2/9] add qemu-modinfo utility, Gerd Hoffmann, 2021/06/02
- [PATCH 1/9] Add module metadata macros, add qxl module annotations,
Gerd Hoffmann <=
- [PATCH 4/9] chardev module annotations, Gerd Hoffmann, 2021/06/02
- [PATCH 6/9] usb-redir module annotations, Gerd Hoffmann, 2021/06/02
- [PATCH 5/9] audio module annotations, Gerd Hoffmann, 2021/06/02
- [PATCH 8/9] ui module annotations, Gerd Hoffmann, 2021/06/02
- [PATCH 9/9] s390x module annotations, Gerd Hoffmann, 2021/06/02
- [PATCH 7/9] ccid module annotations, Gerd Hoffmann, 2021/06/02