From 6036679a122f55c59876be38ec82a5138f52c53b Mon Sep 17 00:00:00 2001 From: mintsuki Date: Fri, 20 May 2022 20:02:14 +0200 Subject: [PATCH] misc: Work around GNU binutils nonsense --- common/GNUmakefile | 15 +++++++++++---- common/linker_bios.ld.in | 4 ++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/common/GNUmakefile b/common/GNUmakefile index 472daaea..e12bc1f8 100644 --- a/common/GNUmakefile +++ b/common/GNUmakefile @@ -158,19 +158,19 @@ ifeq ($(TARGET), bios) override ASM32_FILES := $(shell find ./ -type f -name '*.asm32') override ASMB_FILES := $(shell find ./ -type f -name '*.asmb') -override OBJ := $(addprefix $(call MKESCAPE,$(BUILDDIR))/, $(ASM32_FILES:.asm32=.o) $(ASMB_FILES:.asmb=.o) $(C_FILES:.c=.o)) +override OBJ := $(addprefix $(call MKESCAPE,$(BUILDDIR))/, $(C_FILES:.c=.o) $(ASM32_FILES:.asm32=.o) $(ASMB_FILES:.asmb=.o)) endif ifeq ($(TARGET), uefi64) override ASM64_FILES := $(shell find ./ -type f -name '*.asm64') override ASM64U_FILES := $(shell find ./ -type f -name '*.asm64u') -override OBJ := $(addprefix $(call MKESCAPE,$(BUILDDIR))/, $(ASM64_FILES:.asm64=.o) $(ASM64U_FILES:.asm64u=.o) $(C_FILES:.c=.o)) +override OBJ := $(addprefix $(call MKESCAPE,$(BUILDDIR))/, $(C_FILES:.c=.o) $(ASM64_FILES:.asm64=.o) $(ASM64U_FILES:.asm64u=.o)) endif ifeq ($(TARGET), uefi32) override ASM32_FILES := $(shell find ./ -type f -name '*.asm32') override ASM32U_FILES := $(shell find ./ -type f -name '*.asm32u') -override OBJ := $(addprefix $(call MKESCAPE,$(BUILDDIR))/, $(ASM32_FILES:.asm32=.o) $(ASM32U_FILES:.asm32u=.o) $(C_FILES:.c=.o)) +override OBJ := $(addprefix $(call MKESCAPE,$(BUILDDIR))/, $(C_FILES:.c=.o) $(ASM32_FILES:.asm32=.o) $(ASM32U_FILES:.asm32u=.o)) endif override HEADER_DEPS := $(addprefix $(call MKESCAPE,$(BUILDDIR))/, $(C_FILES:.c=.d)) @@ -249,6 +249,13 @@ $(call MKESCAPE,$(BUILDDIR))/linker_nomap.ld: linker_bios.ld.in $(call MKESCAPE,$(BUILDDIR))/limine_nomap.elf: $(OBJ) $(call MKESCAPE,$(BUILDDIR))/tinf/tinfgzip.o $(call MKESCAPE,$(BUILDDIR))/tinf/tinflate.o $(call MKESCAPE,$(BUILDDIR))/font.o $(call MKESCAPE,$(BUILDDIR))/sys/smp_trampoline.o $(call MKESCAPE,$(BUILDDIR))/stage2.map.o $(MAKE) '$(call SHESCAPE,$(BUILDDIR))/linker_nomap.ld' $(LIMINE_LD) '$(call OBJESCAPE,$^)' $(LIMINE_LDFLAGS) $(INTERNAL_LDFLAGS) -T'$(call SHESCAPE,$(BUILDDIR))/linker_nomap.ld' -o '$(call SHESCAPE,$@)' + $(LIMINE_OBJCOPY) -O binary --only-section=.note.gnu.build-id '$(call SHESCAPE,$@)' '$(call SHESCAPE,$(BUILDDIR))/build-id.s2.bin' + cd '$(call SHESCAPE,$(BUILDDIR))' && \ + $(LIMINE_OBJCOPY) -B i8086 -I binary -O $(OBJCOPY_ARCH) build-id.s2.bin build-id.s2.o + $(LIMINE_OBJCOPY) -O binary --only-section=.note.gnu.build-id '$(call SHESCAPE,$@)' '$(call SHESCAPE,$(BUILDDIR))/build-id.s3.bin' + cd '$(call SHESCAPE,$(BUILDDIR))' && \ + $(LIMINE_OBJCOPY) -B i8086 -I binary -O $(OBJCOPY_ARCH) build-id.s3.bin build-id.s3.o + $(LIMINE_LD) '$(call OBJESCAPE,$^)' '$(call SHESCAPE,$(BUILDDIR))/build-id.s2.o' '$(call SHESCAPE,$(BUILDDIR))/build-id.s3.o' $(LIMINE_LDFLAGS) $(INTERNAL_LDFLAGS) -T'$(call SHESCAPE,$(BUILDDIR))/linker_nomap.ld' -o '$(call SHESCAPE,$@)' $(call MKESCAPE,$(BUILDDIR))/linker.ld: linker_bios.ld.in mkdir -p '$(call SHESCAPE,$(BUILDDIR))' @@ -263,7 +270,7 @@ $(call MKESCAPE,$(BUILDDIR))/limine.elf: $(OBJ) $(call MKESCAPE,$(BUILDDIR))/tin $(LIMINE_OBJCOPY) -O binary --only-section=.note.gnu.build-id '$(call SHESCAPE,$@)' '$(call SHESCAPE,$(BUILDDIR))/build-id.s3.bin' cd '$(call SHESCAPE,$(BUILDDIR))' && \ $(LIMINE_OBJCOPY) -B i8086 -I binary -O $(OBJCOPY_ARCH) build-id.s3.bin build-id.s3.o - $(LIMINE_LD) '$(call SHESCAPE,$(BUILDDIR))/build-id.s2.o' '$(call SHESCAPE,$(BUILDDIR))/build-id.s3.o' '$(call OBJESCAPE,$^)' $(LIMINE_LDFLAGS) $(INTERNAL_LDFLAGS) -T'$(call SHESCAPE,$(BUILDDIR))/linker.ld' -o '$(call SHESCAPE,$@)' + $(LIMINE_LD) '$(call OBJESCAPE,$^)' '$(call SHESCAPE,$(BUILDDIR))/build-id.s2.o' '$(call SHESCAPE,$(BUILDDIR))/build-id.s3.o' $(LIMINE_LDFLAGS) $(INTERNAL_LDFLAGS) -T'$(call SHESCAPE,$(BUILDDIR))/linker.ld' -o '$(call SHESCAPE,$@)' endif diff --git a/common/linker_bios.ld.in b/common/linker_bios.ld.in index e1b047a3..267c63e2 100644 --- a/common/linker_bios.ld.in +++ b/common/linker_bios.ld.in @@ -22,7 +22,7 @@ SECTIONS .data.stage2 : { build_id_s2 = .; - *build-id.s2.o(*) + KEEP(*build-id.s2.o(*)) *.s2.o(.no_unwind) s2_data_begin = .; @@ -57,7 +57,7 @@ SECTIONS .data.stage3 : { build_id_s3 = .; - *build-id.s3.o(*) + KEEP(*build-id.s3.o(*)) *(.rodata .rodata.*) #ifdef LINKER_NOMAP