Skip to contentSkip to conversation

Mini-OS: don't use objcopy --dump-section

PATCH In review Juergen Gross 2 participants 2 messages Dec 6, 2023 – Dec 7, 2023 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Mini-OS: don't use objcopy --dump-section

The objcopy option "--dump-section" isn't supported in binutils before version 2.25, which are still supported by the Xen build system.

Avoid that by using the "-O binary" format together with "--only-section". This requires to set the "alloc" section flag.

Fixes 33411a11f848 ("Mini-OS: hide all symbols not exported via EXPORT_SYMBOLS()")
---
 Makefile | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Makefile +3 -1
index 456aed0b..6c8df8b5 100644
@@ -166,7 +166,9 @@ $(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 $@
+	# The following would be neat, but isn't supported in binutils < 2.25
+	# $(OBJCOPY) --dump-section .export_symbol=$(OBJ_DIR)/syms $@
+	$(OBJCOPY) --set-section-flags .export_symbol=alloc -O binary --only-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)
Signature · 1 line
2.35.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Juergen Gross

The objcopy option "--dump-section" isn't supported in binutils before version 2.25, which are still supported by the Xen build system.

Avoid that by using the "-O binary" format together with "--only-section". This requires to set the "alloc" section flag.

Fixes 33411a11f848 ("Mini-OS: hide all symbols not exported via EXPORT_SYMBOLS()")

And FAOD, I'm taking this, plus a bump to the minios rev right now to unbreak Gitlab CI, as it's been broken for 2 now.

~Andrew