Advertisement
Guest User

Linker Fix

a guest
Dec 14th, 2022
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 3.75 KB | None | 0 0
  1. diff --git a/Makefile b/Makefile
  2. index cbfcd13..25273c4 100644
  3. --- a/Makefile
  4. +++ b/Makefile
  5. @@ -15,7 +15,7 @@ BIN                   := kernel.mod
  6.  include $(shell pwd)/scripts/target-$(TARGETL).mk
  7.  
  8.  WARNINGS       := -Wall -Wextra -Wno-unused-parameter
  9. -DEFS           := $(INCLUDEDIR) -fbuiltin -DGITREV="\"$(GIT_REV)\""
  10. +CFLAGS         := $(INCLUDEDIR) -fbuiltin -DGITREV="\"$(GIT_REV)\""
  11.  
  12.  HELPER_MK      := $(shell pwd)/scripts/helper.mk
  13.  MK_FLAGS       := --no-print-directory -s
  14. @@ -27,7 +27,7 @@ OBJECTS               := $(shell for dir in $(SUBDIRS); do\
  15.                                  done;)
  16.  
  17.  ifeq ($(CONFIG_TESTING),y)
  18. -       DEFS    += -DTEST_HARNESS=1
  19. +       CFLAGS  += -DTEST_HARNESS=1
  20.  endif
  21.  
  22.  OBJECTS                := $(patsubst %.o,$(BUILD)/%.o,$(OBJECTS))
  23. @@ -40,13 +40,12 @@ all: $(BUILD)/apollo.iso
  24.  $(BUILD)/%.c.o: %.c
  25.         @printf "\033[1mCC\033[0m   $<\n"
  26.         @mkdir -p $(@D)
  27. -       @$(CC) -c $< -o $@ $(DEFS) $(TARGET_DEFS) $(WARNINGS)
  28. +       @$(CC) -c $< -o $@ $(CFLAGS) $(TARGET_CFLAGS) $(WARNINGS)
  29.  
  30.  $(BUILD)/apollo/$(BIN): $(OBJECTS)
  31.         @printf "\033[1mLINK\033[0m $@\n"
  32.         @mkdir -p $(BUILD)/apollo
  33. -       @$(CC) $(DEFS) $(WARNINGS) $(LDFLAGS) $(TARGET_LDFLAGS) \
  34. -       -o $(BUILD)/apollo/$(BIN) $(OBJECTS)
  35. +       @$(CC) $(LDFLAGS) $(TARGET_LDFLAGS) -o $(BUILD)/apollo/$(BIN) $(OBJECTS)
  36.  
  37.  link: $(BUILD)/apollo/$(BIN)
  38.  
  39. diff --git a/scripts/target-rpi4.mk b/scripts/target-rpi4.mk
  40. index 3e22197..d019d66 100644
  41. --- a/scripts/target-rpi4.mk
  42. +++ b/scripts/target-rpi4.mk
  43. @@ -9,8 +9,8 @@ SHELL   := $(shell which bash)
  44.  CC             := $(shell command -v aarch64-elf-gcc)
  45.  OBJCOPY := $(shell command -v aarch64-elf-objcopy)
  46.  
  47. -TARGET_DEFS    := -DRPI4=1 -ffreestanding -nostdlib -O2
  48. -TARGET_LDFLAGS ?= -Tsrc/arch/rpi4/link.ld -nostdlib -lgcc -n
  49. +TARGET_CFLAGS  := -DRPI4=1 -ffreestanding -nostdlib -O2
  50. +TARGET_LDFLAGS ?= -Tsrc/arch/rpi4/link.ld -nostdlib -lgcc
  51.  
  52.  $(BUILD)/%.S.o: %.S
  53.         @printf "\033[1mAS\033[0m   $<\n"
  54. diff --git a/scripts/target-x86.mk b/scripts/target-x86.mk
  55. index cdca081..97c071b 100644
  56. --- a/scripts/target-x86.mk
  57. +++ b/scripts/target-x86.mk
  58. @@ -21,8 +21,8 @@ endif
  59.  
  60.  AS                             := nasm
  61.  ASFLAGS                        := -felf -dGITREV="'$(GIT_REV)'"
  62. -TARGET_DEFS    := -DX86=1 -m32 -masm=intel -ffreestanding -nostdlib -Os
  63. -TARGET_LDFLAGS ?= -m32 -Tsrc/arch/x86/link.ld -nostdlib -lgcc -n
  64. +TARGET_CFLAGS  := -DX86=1 -m32 -masm=intel -ffreestanding -nostdlib -Os
  65. +TARGET_LDFLAGS ?= -m32 -Tsrc/arch/x86/link.ld -nostdlib -lgcc
  66.  
  67.  $(BUILD)/%.s.o: %.s
  68.         @printf "\033[1mAS\033[0m   $<\n"
  69. diff --git a/src/arch/rpi4/link.ld b/src/arch/rpi4/link.ld
  70. index 871b7a8..4c89dee 100644
  71. --- a/src/arch/rpi4/link.ld
  72. +++ b/src/arch/rpi4/link.ld
  73. @@ -11,7 +11,6 @@ SECTIONS
  74.  
  75.      .text ALIGN(4096) :
  76.      {
  77. -        *(.init)
  78.          *(.text.unlikely .text.*_unlikely)
  79.          *(.text.exit .text.exit.*)
  80.          *(.text.startup text.startup.*)
  81. @@ -20,13 +19,13 @@ SECTIONS
  82.          *(.gnu.warning)
  83.      }
  84.  
  85. -    . += CONSTANT(COMMONPAGESIZE);
  86. -
  87.      .rodata ALIGN(4096):
  88.      {
  89. -        *(.data .data.* .gnu.linkonce.r*)
  90. +        *(.rodata .rodata.* .gnu.linkonce.r*)
  91.      }
  92.  
  93. +    . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));
  94. +
  95.      .data ALIGN(4096):
  96.      {
  97.          PROVIDE (__startup_begin = .);
  98. diff --git a/src/arch/x86/link.ld b/src/arch/x86/link.ld
  99. index bb3cbdf..cb8cab6 100644
  100. --- a/src/arch/x86/link.ld
  101. +++ b/src/arch/x86/link.ld
  102. @@ -29,7 +29,7 @@ SECTIONS
  103.          *(.gnu.warning)
  104.         }
  105.  
  106. -    .   += CONSTANT(COMMONPAGESIZE);
  107. +    . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));
  108.  
  109.      .rodata ALIGN(4096) : AT(ADDR(.rodata) - 0xC0000000)
  110.      {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement