|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v3 02/32] Mini-OS: explicitly mark symbols to be visible for apps
Add an EXPORT_SYMBOL() macro to explicitly mark a symbol to be visible
for an app or library linked with Mini-OS. This prepares hiding all
other symbols from external components, avoiding any problems with
duplicate symbol names.
Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
---
V3:
- new patch
---
.gitignore | 1 +
Makefile | 3 ++-
include/export.h | 10 ++++++++++
include/lib.h | 1 +
4 files changed, 14 insertions(+), 1 deletion(-)
create mode 100644 include/export.h
diff --git a/.gitignore b/.gitignore
index abef46b2..bacf787e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -16,3 +16,4 @@ mini-os.gz
minios-config.mk
mini-os-debug
mini-os-debug.gz
+syms
diff --git a/Makefile b/Makefile
index 85c6db75..588496cb 100644
--- a/Makefile
+++ b/Makefile
@@ -166,10 +166,11 @@ $(OBJ_DIR)/arch/x86/minios-x86%.lds:
arch/x86/minios-x86.lds.S
$(OBJ_DIR)/$(TARGET)-kern.o: $(OBJS) arch_lib
$(OBJ_DIR)/$(TARGET_ARCH_DIR)/minios-$(MINIOS_TARGET_ARCH).lds
$(LD) -r $(LDFLAGS) $(HEAD_OBJ) $(OBJS) $(LDARCHLIB) -o $@
+ $(OBJCOPY) --dump-section .export_symbol=$(OBJ_DIR)/syms $@
$(OBJ_DIR)/$(TARGET): $(OBJ_DIR)/$(TARGET)-kern.o $(APP_O)
$(LD) -r $(LDFLAGS) $(OBJ_DIR)/$(TARGET)-kern.o $(APP_O) $(LDLIBS) -o
$@.o
- $(OBJCOPY) -w -G $(GLOBAL_PREFIX)* -G _start $@.o $@.o
+ $(OBJCOPY) -w -G $(GLOBAL_PREFIX)* -G _start
--remove-section=.export_symbol $@.o $@.o
$(LD) $(LDFLAGS) $(LDFLAGS_FINAL) $@.o $(EXTRA_OBJS) -o $@-debug
strip -s $@-debug -o $@
gzip -n -f -9 -c $@-debug >$@-debug.gz
diff --git a/include/export.h b/include/export.h
new file mode 100644
index 00000000..7140ac68
--- /dev/null
+++ b/include/export.h
@@ -0,0 +1,10 @@
+#ifndef _EXPORT_H_
+#define _EXPORT_H_
+
+/* Mark a symbol to be visible for apps and libs. */
+#define EXPORT_SYMBOL(sym) \
+ asm(".section .export_symbol\n" \
+ ".ascii \""#sym"\\n\"\n" \
+ ".previous\n")
+
+#endif /* _EXPORT_H_ */
diff --git a/include/lib.h b/include/lib.h
index dd68985a..abd4e9ab 100644
--- a/include/lib.h
+++ b/include/lib.h
@@ -53,6 +53,7 @@
#include <stddef.h>
#include <xen/xen.h>
#include <xen/event_channel.h>
+#include <mini-os/export.h>
#include "gntmap.h"
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
--
2.35.3
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |