Assemble all files to ELF instead of using the NASM built-in linker.
This can enable us to do actual linking in the future.
*.orig
*.rej
*.s
+*.sec
*.sys
*_bin.c
*~
#
# No builtin rules
-MAKEFLAGS = -r
+MAKEFLAGS += -r
+MAKE += -r
TMPFILE = $(shell mktemp /tmp/gcc_ok.XXXXXX)
LDFLAGS = -O2 -s $(LDHASH)
AR = ar
RANLIB = ranlib
+LD = ld
+OBJCOPY = objcopy
+OBJDUMP = objdump
NASM = nasm
NASMOPT = -O9999
kwdhash.gen: keywords genhash.pl
$(PERL) genhash.pl < keywords > kwdhash.gen
+.PRECIOUS: %.elf
+
# Standard rule for {isolinux,isolinux-debug}.bin
-iso%.bin: iso%.asm kwdhash.gen version.gen
- $(NASM) $(NASMOPT) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
- -DMAP=$(@:.bin=.map) -l $(@:.bin=.lsr) -o $@ $<
- $(PERL) lstadjust.pl $(@:.bin=.lsr) $(@:.bin=.map) $(@:.bin=.lst)
+iso%.bin: iso%.elf
+ $(OBJCOPY) -O binary $< $@
$(PERL) checksumiso.pl $@
- $(PERL) checkov.pl $(@:.bin=.map) $@
# Standard rule for {ldlinux,pxelinux,extlinux}.bin
-%.bin: %.asm kwdhash.gen version.gen
- $(NASM) $(NASMOPT) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \
- -DMAP=$(@:.bin=.map) -l $(@:.bin=.lsr) -o $@ $<
- $(PERL) lstadjust.pl $(@:.bin=.lsr) $(@:.bin=.map) $(@:.bin=.lst)
- $(PERL) checkov.pl $(@:.bin=.map) $@
+%.bin: %.elf
+ $(OBJCOPY) -O binary $< $@
+
+%.o: %.asm kwdhash.gen version.gen
+ $(NASM) $(NASMOPT) -f elf -F stabs -DDATE_STR="'$(DATE)'" \
+ -DHEXDATE="$(HEXDATE)" \
+ -l $(@:.o=.lsr) -o $@ $<
+
+%.elf: %.o syslinux.ld
+ $(LD) -m elf_i386 -T syslinux.ld -M -o $@ $< > $(@:.elf=.map)
+ $(OBJDUMP) -h $@ > $(@:.elf=.sec)
+ $(PERL) lstadjust.pl $(@:.elf=.lsr) $(@:.elf=.sec) $(@:.elf=.lst)
pxelinux.0: pxelinux.bin
cp -f $< $@
install -m 644 $(NETINSTALLABLE) $(INSTALLROOT)$(TFTPBOOT)
local-tidy:
- rm -f *.o *_bin.c stupid.* patch.offset
- rm -f *.lsr *.lst *.map
+ rm -f *.o *.elf *_bin.c stupid.* patch.offset
+ rm -f *.lsr *.lst *.map *.sec
rm -f $(OBSOLETE)
- $(MAKE) -C gpxe/src veryclean
tidy: local-tidy
set -e ; for i in $(BESUBDIRS) $(IESUBDIRS) $(BSUBDIRS) $(ISUBDIRS) ; do $(MAKE) -C $$i $@ ; done
+ $(MAKE) -C gpxe/src veryclean
local-clean:
rm -f $(ITARGET)
.depend:
rm -f .depend
for csrc in $(CSRC) ; do $(CC) $(INCLUDE) -MM $$csrc >> .depend ; done
- for nsrc in $(NASMSRC) ; do $(NASM) -DDEPEND $(NINCLUDE) -o `echo $$nsrc | sed -e 's/\.asm/\.bin/'` -M $$nsrc >> .depend ; done
+ for nsrc in $(NASMSRC) ; do $(NASM) -DDEPEND $(NINCLUDE) -o `echo $$nsrc | sed -e 's/\.asm/\.o/'` -M $$nsrc >> .depend ; done
local-depend:
rm -f .depend
LIBGCC := $(shell $(CC) --print-libgcc)
SRCS = syslinux.c \
- ../syslxmod.c ../bootsect_bin.c ../ldlinux_bin.c ../mbr_bin.c \
+ ../libinstaller/syslxmod.c \
+ ../bootsect_bin.c ../ldlinux_bin.c ../mbr_bin.c \
$(wildcard ../libfat/*.c)
OBJS = crt0.o $(patsubst %.c,%.o,$(notdir $(SRCS)))
LIBOBJS = conio.o memcpy.o memset.o skipatou.o atou.o malloc.o free.o \
; "magic number" (using the term very loosely) for the DOS superblock.
;
bootsec equ $
- jmp short start ; 2 bytes
+_start: jmp short start ; 2 bytes
nop ; 1 byte
;
; "Superblock" follows -- it's in the boot sector, so it's already
CFLAGS = -W -Wall -Wno-sign-compare -D_FILE_OFFSET_BITS=64 $(OPTFLAGS) $(INCLUDES)
LDFLAGS = $(LDHASH) # -s
-SRCS = extlinux.c setadv.c extlinux_bss_bin.c extlinux_sys_bin.c
+SRCS = main.c ../libinstaller/setadv.c \
+ ../extlinux_bss_bin.c ../extlinux_sys_bin.c
OBJS = $(patsubst %.c,%.o,$(notdir $(SRCS)))
.SUFFIXES: .c .o .i .s .S
%include "macros.inc"
%include "config.inc"
+%include "layout.inc"
%include "kernel.inc"
%include "bios.inc"
%include "tracers.inc"
-%include "layout.inc"
%include "stack.inc"
%endif ; _HEAD_INC
; Memory layout of segments
;
+ ; Default to 16-bit code
+ bits 16
; Memory below 0800h is reserved for the BIOS and the MBR.
BSS_START equ 0800h
; but it doesn't seem to work that way.
LATEBSS_START equ 0B800h
-; Reserve memory for the stack. This causes checkov to abort the
-; compile if we violate this space.
-STACK_SIZE equ 4096
-STACK_START equ TEXT_START-STACK_SIZE
-
%ifdef MAP
[map all MAP]
%endif
;
; The various sections and their relationship
;
- org TEXT_START
-
; Use .earlybss for things that MUST be in low memory.
section .earlybss nobits start=BSS_START
- section .bcopy32 align=4 valign=16 follows=.data vfollows=.earlybss
- section .config align=4 valign=16 follows=.bcopy32 vfollows=.bcopy32
- section .config.end nobits valign=4 vfollows=.config
+ section .bcopy32 exec nowrite progbits align=4
+ section .config write progbits align=4
+ section .config.end write nobits align=4
; Use .bss for things that doesn't have to be in low memory;
; with .bss1 and .bss2 to offload. .earlybss should be used
; for things that absolutely have to be below 0x7c00.
- section .bss nobits valign=16 vfollows=.config.end
+ section .bss write nobits align=16
; Warning here: RBFG build 22 randomly overwrites
; memory location [0x5680,0x576c), possibly more. It
; pointer to its own internal packet buffer and starts
; writing a received ARP packet into low memory.
%if IS_PXELINUX
- section .rbfg nobits start=0x5680
+ section .rbfg write nobits
RBFG_brainfuck: resb 2048 ; Bigger than an Ethernet packet...
%endif
; For section following .rbfg
%if IS_PXELINUX
- section .bss2 nobits valign=16 vfollows=.rbfg
+ section .bss2 write nobits align=16
%else
- section .bss2 nobits valign=16 vfollows=.bss
+ section .bss2 write nobits align=16
%endif
- section .text start=TEXT_START
- ; NASM BUG: .data always follows .text; can't override
- section .data align=16 ; follows=.text
-
- ; This empty section works around a NASM bug with regards
- ; to follows= and nobits sections following a section which
- ; has VMA != LMA.
- section .advpad progbits align=512 follows=.config
+ section .text exec write progbits align=16
+ section .data write progbits align=16
- section .adv nobits align=512 follows=.advpad
+ section .adv write nobits align=512
; .uibss contains bss data which is guaranteed to be
; safe to clobber during the loading of the image. This
; is because while loading the primary image we will clobber
; the spillover from the last fractional sector load.
- section .uibss nobits align=16 follows=.adv
+ section .uibss write nobits align=16
; Normal bss...
- section .bss1 nobits align=16 follows=.uibss
+ section .bss1 write nobits align=16
+
+ ; Symbols from linker script
+ extern Stack
+ extern section..bcopy32.start
+ extern section..config.start
+ extern section..config.vstart
+ extern section..config.end.start
+
+ global _start
- ; Reserve space for stack
- section .stack nobits align=16 start=STACK_START
-Stack resb STACK_SIZE
+ section .text
; "magic number" (using the term very loosely) for the DOS superblock.
;
bootsec equ $
- jmp short start ; 2 bytes
+_start: jmp short start ; 2 bytes
nop ; 1 byte
;
; "Superblock" follows -- it's in the boot sector, so it's already
or die "$0: cannot create: $outfile: $!\n";
%vstart = ();
-undef $sec;
while (defined($line = <MAP>)) {
- chomp $line;
- if ($line =~ /^\-+\s+Section\s+(\S+)\s+\-/) {
- $sec = $1;
- }
- next unless (defined($sec));
- if ($line =~ /^vstart:\s+([0-9a-f]+)/i) {
- $vstart{$sec} = hex $1;
+ if ($line =~ /^\s*([0-9]+)\s+(\S+)\s+([0-9a-f]+)\s+([0-9a-f]+)\s+([0-9a-f]+)\s+([0-9a-f]+)\s+2\*\*([0-9]+)/i) {
+ $vstart{$2} = hex $4;
}
}
close(MAP);
CFLAGS = -W -Wall -D_FILE_OFFSET_BITS=64 $(OPTFLAGS) $(INCLUDES)
LDFLAGS = $(LDHASH) -s
-SRCS = syslinux.c ../syslxmod.c ../bootsect_bin.c ../ldlinux_bin.c $(wildcard ../libfat/*.c)
+SRCS = syslinux.c ../syslxmod.c ../bootsect_bin.c ../ldlinux_bin.c \
+ $(wildcard ../libfat/*.c)
OBJS = $(patsubst %.c,%.o,$(notdir $(SRCS)))
.SUFFIXES: .c .o .i .s .S
--- /dev/null
+/*
+ * Linker script for the SYSLINUX core
+ */
+
+OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
+OUTPUT_ARCH(i386)
+EXTERN(_start)
+ENTRY(_start)
+
+STACK_LEN = 4096;
+
+SECTIONS
+{
+ /* "Early" sections (before the load) */
+ . = 0x0800;
+
+ .earlybss : {
+ __earlybss_start = .;
+ *(.earlybss)
+ __earlybss_len = . - __earlybss_start;
+ }
+
+ .bcopy32 : AT (__bcopy32_lma) {
+ FILL(0x90909090)
+ __bcopy32_start = .;
+ *(.bcopy32)
+ __bcopy32_len = . - __bcopy32_start;
+ }
+
+ .config : AT (__config_lma) {
+ __config_start = .;
+ *(.config)
+ __config_len = . - __config_start;
+ }
+
+ .bss : AT(__bss_start) {
+ __bss_start = .;
+ *(.bss)
+ *(.bss2)
+ __bss_len = . - __bss_start;
+ }
+
+ /* Stack */
+
+ . = 0x7c00 - STACK_LEN;
+ .stack : {
+ __stack_start = .;
+ . += STACK_LEN;
+ __stack_len = . - __stack_start;
+ }
+
+ /* Initialized sections */
+
+ . = 0x7c00;
+ .text : {
+ FILL(0x90909090)
+ __text_start = .;
+ *(.text)
+ __text_len = . - __text_start;
+ }
+
+ . = ALIGN(4);
+ __bcopy32_lma = .;
+ . += SIZEOF(.bcopy32);
+
+ . = ALIGN(4);
+ .data : {
+ __data_start = .;
+ *(.data)
+ __data_len = . - __data_start;
+ }
+
+ . = ALIGN(4);
+ __config_lma = .;
+ . += SIZEOF(.config);
+
+ /* ADV, must be the last intialized section */
+
+ . = ALIGN(512);
+ .adv : {
+ __adv_start = .;
+ *(.adv)
+ __adv_len = . - __adv_start;
+ }
+
+ /* Late uninitialized sections */
+
+ .uibss : {
+ __uibss_start = .;
+ *(.uibss)
+ __uibss_len = . - __uibss_start;
+ }
+
+ .bss1 : {
+ __bss1_start = .;
+ *(.bss1)
+ __bss1_len = . - __bss1_start;
+ }
+
+ Stack = __stack_start;
+ section..bcopy32.start = __bcopy32_lma;
+ section..config.start = __config_lma;
+ section..config.vstart = __config_start;
+ section..config.end.start = __config_start + SIZEOF(.config);
+}
CFLAGS = -W -Wall -D_FILE_OFFSET_BITS=64 $(OPTFLAGS) $(INCLUDES)
LDFLAGS = $(LDHASH) -s
-SRCS = syslinux.c ../syslxmod.c ../bootsect_bin.c ../ldlinux_bin.c
+SRCS = syslinux.c ../libinstaller/syslxmod.c \
+ ../bootsect_bin.c ../ldlinux_bin.c
OBJS = $(patsubst %.c,%.o,$(notdir $(SRCS)))
.SUFFIXES: .c .o .i .s .S