diff mbox series

[v3,32/32] Mini-OS: hide all symbols not exported via EXPORT_SYMBOLS()

Message ID 20231127102523.28003-33-jgross@suse.com (mailing list archive)
State New, archived
Headers show
Series Mini-OS: hide mini-os internal symbols | expand

Commit Message

Jürgen Groß Nov. 27, 2023, 10:25 a.m. UTC
When doing the final linking of the Mini-OS kernel only keep the
symbols visible which have been marked via EXPORT_SYMBOL().

Signed-off-by: Juergen Gross <jgross@suse.com>
---
V3:
- new patch
---
 Makefile | 1 +
 1 file changed, 1 insertion(+)

Comments

Samuel Thibault Nov. 27, 2023, 8:07 p.m. UTC | #1
Juergen Gross, le lun. 27 nov. 2023 11:25:23 +0100, a ecrit:
> When doing the final linking of the Mini-OS kernel only keep the
> symbols visible which have been marked via EXPORT_SYMBOL().
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

> ---
> V3:
> - new patch
> ---
>  Makefile | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/Makefile b/Makefile
> index 588496cb..456aed0b 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -167,6 +167,7 @@ $(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 $@
> +	$(OBJCOPY) -w -G $(GLOBAL_PREFIX)* --keep-global-symbols=$(OBJ_DIR)/syms --remove-section=.export_symbol $@ $@
>  
>  $(OBJ_DIR)/$(TARGET): $(OBJ_DIR)/$(TARGET)-kern.o $(APP_O)
>  	$(LD) -r $(LDFLAGS) $(OBJ_DIR)/$(TARGET)-kern.o $(APP_O) $(LDLIBS) -o $@.o
> -- 
> 2.35.3
>
diff mbox series

Patch

diff --git a/Makefile b/Makefile
index 588496cb..456aed0b 100644
--- a/Makefile
+++ b/Makefile
@@ -167,6 +167,7 @@  $(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 $@
+	$(OBJCOPY) -w -G $(GLOBAL_PREFIX)* --keep-global-symbols=$(OBJ_DIR)/syms --remove-section=.export_symbol $@ $@
 
 $(OBJ_DIR)/$(TARGET): $(OBJ_DIR)/$(TARGET)-kern.o $(APP_O)
 	$(LD) -r $(LDFLAGS) $(OBJ_DIR)/$(TARGET)-kern.o $(APP_O) $(LDLIBS) -o $@.o