aboutsummaryrefslogtreecommitdiffstats
path: root/com32
diff options
context:
space:
mode:
authorFeng Tang <feng.tang@intel.com>2010-06-03 10:48:22 +0800
committerFeng Tang <feng.tang@intel.com>2010-07-20 11:10:03 +0800
commit0cb6490fa96f752c01bbb9add2c9ca6dbf99ece2 (patch)
tree893dce505df9799ad59aea2538865909d814b8a7 /com32
parent8f33a3dff6cd44fa2d12e626354479e020e25bdc (diff)
downloadsyslinux-0cb6490fa96f752c01bbb9add2c9ca6dbf99ece2.tar.gz
syslinux-0cb6490fa96f752c01bbb9add2c9ca6dbf99ece2.tar.xz
syslinux-0cb6490fa96f752c01bbb9add2c9ca6dbf99ece2.zip
elflink: start merge with pathbased branch
modify these files to make compile pass modified: com32/MCONFIG modified: com32/Makefile modified: com32/include/klibc/compiler.h modified: com32/include/sys/elfcommon.h modified: com32/lib/Makefile modified: com32/lib/free.c modified: com32/lib/malloc.c
Diffstat (limited to 'com32')
-rw-r--r--com32/MCONFIG9
-rw-r--r--com32/Makefile2
-rw-r--r--com32/include/klibc/compiler.h6
-rw-r--r--com32/include/sys/elfcommon.h231
-rwxr-xr-x[-rw-r--r--]com32/lib/Makefile242
-rw-r--r--com32/lib/free.c5
-rw-r--r--com32/lib/malloc.c23
7 files changed, 386 insertions, 132 deletions
diff --git a/com32/MCONFIG b/com32/MCONFIG
index 0b774d4f..a2b5d0a0 100644
--- a/com32/MCONFIG
+++ b/com32/MCONFIG
@@ -54,8 +54,8 @@ SFLAGS = $(GCCOPT) $(GCCWARN) -march=i386 \
-nostdinc -iwithprefix include \
-I$(com32)/libutil/include -I$(com32)/include $(GPLINCLUDE)
-COM32LD = $(com32)/lib/com32.ld
-LDFLAGS = -m elf_i386 --emit-relocs -T $(COM32LD)
+COM32LD = $(com32)/lib/elf32.ld
+LDFLAGS = -m elf_i386 -shared --hash-style=gnu -T $(COM32LD)
LIBGCC := $(shell $(CC) $(GCCOPT) --print-libgcc)
LNXCFLAGS = -I$(com32)/libutil/include $(GCCWARN) -O -g -D_GNU_SOURCE
@@ -93,5 +93,6 @@ C_LNXLIBS = $(com32)/libutil/libutil_lnx.a
$(CC) $(LNXCFLAGS) -o $@ $^
%.c32: %.elf
- $(OBJCOPY) -O binary $< $@
- $(RELOCS) $< >> $@ || ( rm -f $@ ; false )
+ $(OBJCOPY) --strip-debug --strip-unneeded $< $@
+ ##$(OBJCOPY) -O binary $< $@
+ ##$(RELOCS) $< >> $@ || ( rm -f $@ ; false )
diff --git a/com32/Makefile b/com32/Makefile
index 4f95017a..b247bce2 100644
--- a/com32/Makefile
+++ b/com32/Makefile
@@ -1,4 +1,4 @@
-SUBDIRS = tools lib gpllib libutil modules mboot menu samples rosh cmenu \
+SUBDIRS = tools lib gpllib libutil modules mboot menu samples elflink elflink/modules rosh cmenu \
hdt gfxboot sysdump
all tidy dist clean spotless install:
set -e; for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
diff --git a/com32/include/klibc/compiler.h b/com32/include/klibc/compiler.h
index 5ac21185..b5919d67 100644
--- a/com32/include/klibc/compiler.h
+++ b/com32/include/klibc/compiler.h
@@ -108,6 +108,9 @@
# define __unusedfunc
#endif
+/* Used symbol */
+#define __used __attribute__((used))
+
/* Constructors and destructors */
#define __constructor __attribute__((constructor))
#define __destructor __attribute__((destructor))
@@ -126,4 +129,7 @@
#define __common __attribute__((common))
#define __nocommon __attribute__((nocommon))
+/* Weak symbols */
+#define __weak __attribute__((weak))
+
#endif
diff --git a/com32/include/sys/elfcommon.h b/com32/include/sys/elfcommon.h
index 2489e3c0..8d6ddb05 100644
--- a/com32/include/sys/elfcommon.h
+++ b/com32/include/sys/elfcommon.h
@@ -59,32 +59,108 @@
#define EM_S390_OLD 0xA390 /* Obsolete interrim value for S/390 */
/* Dynamic type values */
-#define DT_NULL 0
-#define DT_NEEDED 1
-#define DT_PLTRELSZ 2
-#define DT_PLTGOT 3
-#define DT_HASH 4
-#define DT_STRTAB 5
-#define DT_SYMTAB 6
-#define DT_RELA 7
-#define DT_RELASZ 8
-#define DT_RELAENT 9
-#define DT_STRSZ 10
-#define DT_SYMENT 11
-#define DT_INIT 12
-#define DT_FINI 13
-#define DT_SONAME 14
-#define DT_RPATH 15
-#define DT_SYMBOLIC 16
-#define DT_REL 17
-#define DT_RELSZ 18
-#define DT_RELENT 19
-#define DT_PLTREL 20
-#define DT_DEBUG 21
-#define DT_TEXTREL 22
-#define DT_JMPREL 23
-#define DT_LOPROC 0x70000000
-#define DT_HIPROC 0x7fffffff
+#define DT_NULL 0 /* Marks end of dynamic section */
+#define DT_NEEDED 1 /* Name of needed library */
+#define DT_PLTRELSZ 2 /* Size in bytes of PLT relocs */
+#define DT_PLTGOT 3 /* Processor defined value */
+#define DT_HASH 4 /* Address of symbol hash table */
+#define DT_STRTAB 5 /* Address of string table */
+#define DT_SYMTAB 6 /* Address of symbol table */
+#define DT_RELA 7 /* Address of Rela relocs */
+#define DT_RELASZ 8 /* Total size of Rela relocs */
+#define DT_RELAENT 9 /* Size of one Rela reloc */
+#define DT_STRSZ 10 /* Size of string table */
+#define DT_SYMENT 11 /* Size of one symbol table entry */
+#define DT_INIT 12 /* Address of init function */
+#define DT_FINI 13 /* Address of termination function */
+#define DT_SONAME 14 /* Name of shared object */
+#define DT_RPATH 15 /* Library search path (deprecated) */
+#define DT_SYMBOLIC 16 /* Start symbol search here */
+#define DT_REL 17 /* Address of Rel relocs */
+#define DT_RELSZ 18 /* Total size of Rel relocs */
+#define DT_RELENT 19 /* Size of one Rel reloc */
+#define DT_PLTREL 20 /* Type of reloc in PLT */
+#define DT_DEBUG 21 /* For debugging; unspecified */
+#define DT_TEXTREL 22 /* Reloc might modify .text */
+#define DT_JMPREL 23 /* Address of PLT relocs */
+#define DT_BIND_NOW 24 /* Process relocations of object */
+#define DT_INIT_ARRAY 25 /* Array with addresses of init fct */
+#define DT_FINI_ARRAY 26 /* Array with addresses of fini fct */
+#define DT_INIT_ARRAYSZ 27 /* Size in bytes of DT_INIT_ARRAY */
+#define DT_FINI_ARRAYSZ 28 /* Size in bytes of DT_FINI_ARRAY */
+#define DT_RUNPATH 29 /* Library search path */
+#define DT_FLAGS 30 /* Flags for the object being loaded */
+#define DT_ENCODING 32 /* Start of encoded range */
+#define DT_PREINIT_ARRAY 32 /* Array with addresses of preinit fct*/
+#define DT_PREINIT_ARRAYSZ 33 /* size in bytes of DT_PREINIT_ARRAY */
+#define DT_NUM 34 /* Number used */
+#define DT_LOOS 0x6000000d /* Start of OS-specific */
+#define DT_HIOS 0x6ffff000 /* End of OS-specific */
+#define DT_LOPROC 0x70000000 /* Start of processor-specific */
+#define DT_HIPROC 0x7fffffff /* End of processor-specific */
+
+#define DT_VALRNGLO 0x6ffffd00
+#define DT_GNU_PRELINKED 0x6ffffdf5 /* Prelinking timestamp */
+#define DT_GNU_CONFLICTSZ 0x6ffffdf6 /* Size of conflict section */
+#define DT_GNU_LIBLISTSZ 0x6ffffdf7 /* Size of library list */
+#define DT_CHECKSUM 0x6ffffdf8
+#define DT_PLTPADSZ 0x6ffffdf9
+#define DT_MOVEENT 0x6ffffdfa
+#define DT_MOVESZ 0x6ffffdfb
+#define DT_FEATURE_1 0x6ffffdfc /* Feature selection (DTF_*). */
+#define DT_POSFLAG_1 0x6ffffdfd /* Flags for DT_* entries, effecting
+ the following DT_* entry. */
+#define DT_SYMINSZ 0x6ffffdfe /* Size of syminfo table (in bytes) */
+#define DT_SYMINENT 0x6ffffdff /* Entry size of syminfo */
+#define DT_VALRNGHI 0x6ffffdff
+#define DT_VALTAGIDX(tag) (DT_VALRNGHI - (tag)) /* Reverse order! */
+#define DT_VALNUM 12
+
+/* DT_* entries which fall between DT_ADDRRNGHI & DT_ADDRRNGLO use the
+ Dyn.d_un.d_ptr field of the Elf*_Dyn structure.
+
+ If any adjustment is made to the ELF object after it has been
+ built these entries will need to be adjusted. */
+#define DT_ADDRRNGLO 0x6ffffe00
+#define DT_GNU_HASH 0x6ffffef5 /* GNU-style hash table. */
+#define DT_TLSDESC_PLT 0x6ffffef6
+#define DT_TLSDESC_GOT 0x6ffffef7
+#define DT_GNU_CONFLICT 0x6ffffef8 /* Start of conflict section */
+#define DT_GNU_LIBLIST 0x6ffffef9 /* Library list */
+#define DT_CONFIG 0x6ffffefa /* Configuration information. */
+#define DT_DEPAUDIT 0x6ffffefb /* Dependency auditing. */
+#define DT_AUDIT 0x6ffffefc /* Object auditing. */
+#define DT_PLTPAD 0x6ffffefd /* PLT padding. */
+#define DT_MOVETAB 0x6ffffefe /* Move table. */
+#define DT_SYMINFO 0x6ffffeff /* Syminfo table. */
+#define DT_ADDRRNGHI 0x6ffffeff
+#define DT_ADDRTAGIDX(tag) (DT_ADDRRNGHI - (tag)) /* Reverse order! */
+#define DT_ADDRNUM 11
+
+/* The versioning entry types. The next are defined as part of the
+ GNU extension. */
+#define DT_VERSYM 0x6ffffff0
+
+#define DT_RELACOUNT 0x6ffffff9
+#define DT_RELCOUNT 0x6ffffffa
+
+/* These were chosen by Sun. */
+#define DT_FLAGS_1 0x6ffffffb /* State flags, see DF_1_* below. */
+#define DT_VERDEF 0x6ffffffc /* Address of version definition
+ table */
+#define DT_VERDEFNUM 0x6ffffffd /* Number of version definitions */
+#define DT_VERNEED 0x6ffffffe /* Address of table with needed
+ versions */
+#define DT_VERNEEDNUM 0x6fffffff /* Number of needed versions */
+#define DT_VERSIONTAGIDX(tag) (DT_VERNEEDNUM - (tag)) /* Reverse order! */
+#define DT_VERSIONTAGNUM 16
+
+/* Sun added these machine-independent extensions in the "processor-specific"
+ range. Be compatible. */
+#define DT_AUXILIARY 0x7ffffffd /* Shared object to load before self */
+#define DT_FILTER 0x7fffffff /* Shared object to get values from */
+#define DT_EXTRATAGIDX(tag) ((Elf32_Word)-((Elf32_Sword) (tag) <<1>>1)-1)
+#define DT_EXTRANUM 3
/* Auxilliary table entries */
#define AT_NULL 0 /* end of vector */
@@ -147,6 +223,52 @@
#define SHN_COMMON 0xfff2
#define SHN_HIRESERVE 0xffff
+/* Symbol table definitions */
+
+/* How to extract and insert information held in the st_info field. */
+
+#define ELF32_ST_BIND(val) (((unsigned char) (val)) >> 4)
+#define ELF32_ST_TYPE(val) ((val) & 0xf)
+#define ELF32_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf))
+
+/* Both Elf32_Sym and Elf64_Sym use the same one-byte st_info field. */
+#define ELF64_ST_BIND(val) ELF32_ST_BIND (val)
+#define ELF64_ST_TYPE(val) ELF32_ST_TYPE (val)
+#define ELF64_ST_INFO(bind, type) ELF32_ST_INFO ((bind), (type))
+
+/* Legal values for ST_BIND subfield of st_info (symbol binding). */
+
+#define STB_LOCAL 0 /* Local symbol */
+#define STB_GLOBAL 1 /* Global symbol */
+#define STB_WEAK 2 /* Weak symbol */
+#define STB_NUM 3 /* Number of defined types. */
+#define STB_LOOS 10 /* Start of OS-specific */
+#define STB_HIOS 12 /* End of OS-specific */
+#define STB_LOPROC 13 /* Start of processor-specific */
+#define STB_HIPROC 15 /* End of processor-specific */
+
+/* Legal values for ST_TYPE subfield of st_info (symbol type). */
+
+#define STT_NOTYPE 0 /* Symbol type is unspecified */
+#define STT_OBJECT 1 /* Symbol is a data object */
+#define STT_FUNC 2 /* Symbol is a code object */
+#define STT_SECTION 3 /* Symbol associated with a section */
+#define STT_FILE 4 /* Symbol's name is file name */
+#define STT_COMMON 5 /* Symbol is a common data object */
+#define STT_TLS 6 /* Symbol is thread-local data object*/
+#define STT_NUM 7 /* Number of defined types. */
+#define STT_LOOS 10 /* Start of OS-specific */
+#define STT_HIOS 12 /* End of OS-specific */
+#define STT_LOPROC 13 /* Start of processor-specific */
+#define STT_HIPROC 15 /* End of processor-specific */
+
+
+/* Symbol table indices are found in the hash buckets and chain table
+ of a symbol hash table section. This special index value indicates
+ the end of a chain, meaning no further symbols are found in that bucket. */
+
+#define STN_UNDEF 0 /* End of a chain. */
+
/* Lenght of magic at the start of a file */
#define EI_NIDENT 16
@@ -184,4 +306,59 @@
#define ELFOSABI_NONE 0
#define ELFOSABI_LINUX 3
-#endif /* _SYS_ELFCOMMON_H */
+/* Intel 80386 specific definitions. */
+
+/* i386 relocs. */
+
+#define R_386_NONE 0 /* No reloc */
+#define R_386_32 1 /* Direct 32 bit */
+#define R_386_PC32 2 /* PC relative 32 bit */
+#define R_386_GOT32 3 /* 32 bit GOT entry */
+#define R_386_PLT32 4 /* 32 bit PLT address */
+#define R_386_COPY 5 /* Copy symbol at runtime */
+#define R_386_GLOB_DAT 6 /* Create GOT entry */
+#define R_386_JMP_SLOT 7 /* Create PLT entry */
+#define R_386_RELATIVE 8 /* Adjust by program base */
+#define R_386_GOTOFF 9 /* 32 bit offset to GOT */
+#define R_386_GOTPC 10 /* 32 bit PC relative offset to GOT */
+#define R_386_32PLT 11
+#define R_386_TLS_TPOFF 14 /* Offset in static TLS block */
+#define R_386_TLS_IE 15 /* Address of GOT entry for static TLS
+ block offset */
+#define R_386_TLS_GOTIE 16 /* GOT entry for static TLS block
+ offset */
+#define R_386_TLS_LE 17 /* Offset relative to static TLS
+ block */
+#define R_386_TLS_GD 18 /* Direct 32 bit for GNU version of
+ general dynamic thread local data */
+#define R_386_TLS_LDM 19 /* Direct 32 bit for GNU version of
+ local dynamic thread local data
+ in LE code */
+#define R_386_16 20
+#define R_386_PC16 21
+#define R_386_8 22
+#define R_386_PC8 23
+#define R_386_TLS_GD_32 24 /* Direct 32 bit for general dynamic
+ thread local data */
+#define R_386_TLS_GD_PUSH 25 /* Tag for pushl in GD TLS code */
+#define R_386_TLS_GD_CALL 26 /* Relocation for call to
+ __tls_get_addr() */
+#define R_386_TLS_GD_POP 27 /* Tag for popl in GD TLS code */
+#define R_386_TLS_LDM_32 28 /* Direct 32 bit for local dynamic
+ thread local data in LE code */
+#define R_386_TLS_LDM_PUSH 29 /* Tag for pushl in LDM TLS code */
+#define R_386_TLS_LDM_CALL 30 /* Relocation for call to
+ __tls_get_addr() in LDM code */
+#define R_386_TLS_LDM_POP 31 /* Tag for popl in LDM TLS code */
+#define R_386_TLS_LDO_32 32 /* Offset relative to TLS block */
+#define R_386_TLS_IE_32 33 /* GOT entry for negated static TLS
+ block offset */
+#define R_386_TLS_LE_32 34 /* Negated offset relative to static
+ TLS block */
+#define R_386_TLS_DTPMOD32 35 /* ID of module containing symbol */
+#define R_386_TLS_DTPOFF32 36 /* Offset in TLS block */
+#define R_386_TLS_TPOFF32 37 /* Negated offset in static TLS block */
+/* Keep this the last entry. */
+#define R_386_NUM 38
+
+#endif /* _SYS_ELFCOMMON_H */
diff --git a/com32/lib/Makefile b/com32/lib/Makefile
index 93643ce2..c7e7e7dc 100644..100755
--- a/com32/lib/Makefile
+++ b/com32/lib/Makefile
@@ -7,46 +7,131 @@ NOGPL := 1
topdir = ../..
include MCONFIG
-LIBOBJS = \
- abort.o atexit.o atoi.o atol.o atoll.o calloc.o creat.o \
+## OPTIONAL OBJECTS, AVAILABLE AS DYNAMIC LINKED MODULES
+# PNG library object files
+LIBPNG_OBJS = \
+ libpng/png.o libpng/pngset.o libpng/pngget.o libpng/pngrutil.o \
+ libpng/pngtrans.o libpng/pngwutil.o libpng/pngread.o \
+ libpng/pngrio.o libpng/pngwio.o libpng/pngwrite.o \
+ libpng/pngrtran.o libpng/pngwtran.o libpng/pngmem.o \
+ libpng/pngerror.o libpng/pngpread.o
+
+# ZIP library object files
+LIBZLIB_OBJS = \
+ zlib/adler32.o zlib/compress.o zlib/crc32.o \
+ zlib/uncompr.o zlib/deflate.o zlib/trees.o zlib/zutil.o \
+ zlib/inflate.o zlib/infback.o zlib/inftrees.o zlib/inffast.o \
+ sys/zfile.o sys/zfopen.o
+
+# JPG library object files
+LIBJPG_OBJS = \
+ jpeg/tinyjpeg.o jpeg/jidctflt.o jpeg/decode1.o jpeg/decode3.o \
+ jpeg/rgb24.o jpeg/bgr24.o jpeg/yuv420p.o jpeg/grey.o \
+ jpeg/rgba32.o jpeg/bgra32.o
+
+LIBVESA_OBJS = \
+ sys/vesacon_write.o sys/vesaserial_write.o \
+ sys/vesa/initvesa.o sys/vesa/drawtxt.o sys/vesa/background.o \
+ sys/vesa/alphatbl.o sys/vesa/screencpy.o sys/vesa/fmtpixel.o
+
+LIBPCI_OBJS = \
+ pci/cfgtype.o pci/scan.o pci/bios.o \
+ pci/readb.o pci/readw.o pci/readl.o \
+ pci/writeb.o pci/writew.o pci/writel.o
+
+LIBSYSLINUX_OBJS = \
+ syslinux/reboot.o syslinux/keyboard.o \
+ syslinux/features.o syslinux/config.o \
+ syslinux/ipappend.o syslinux/dsinfo.o syslinux/version.o \
+ syslinux/pxe_get_cached.o syslinux/pxe_get_nic.o \
+ syslinux/adv.o syslinux/advwrite.o syslinux/getadv.o \
+ syslinux/setadv.o
+
+LIBLOAD_OBJS = \
+ syslinux/addlist.o syslinux/freelist.o syslinux/memmap.o \
+ syslinux/movebits.o syslinux/shuffle.o syslinux/shuffle_pm.o \
+ syslinux/shuffle_rm.o syslinux/zonelist.o \
+ syslinux/dump_mmap.o syslinux/dump_movelist.o \
+ \
+ syslinux/run_default.o syslinux/run_command.o \
+ syslinux/cleanup.o syslinux/localboot.o syslinux/runimage.o \
+ \
+ syslinux/loadfile.o syslinux/floadfile.o syslinux/zloadfile.o \
+ \
+ syslinux/load_linux.o syslinux/initramfs.o \
+ syslinux/initramfs_file.o syslinux/initramfs_loadfile.o \
+ syslinux/initramfs_archive.o
+
+DYNENTRY_OBJS = \
+ atexit.o onexit.o abort.o
+
+## CORE OBJECTS, INCLUDED IN THE ROOT COM32 MODULE
+LIBENTRY_OBJS = \
+ sys/intcall.o sys/farcall.o sys/cfarcall.o sys/zeroregs.o \
+ sys/argv.o \
+ sys/fileinfo.o sys/opendev.o sys/read.o sys/write.o sys/ftell.o \
+ sys/close.o sys/open.o sys/fileread.o sys/fileclose.o \
+ sys/openmem.o \
+ sys/isatty.o sys/fstat.o \
+ \
+ syslinux/idle.o \
+ \
+ exit.o
+
+LIBMODULE_OBJS = \
+ sys/module/common.o sys/module/elf_module.o \
+ sys/module/shallow_module.o sys/module/elfutils.o \
+ sys/module/exec.o
+
+LIBGCC_OBJS = \
+ libgcc/__ashldi3.o libgcc/__udivdi3.o \
+ libgcc/__negdi2.o libgcc/__ashrdi3.o libgcc/__lshrdi3.o \
+ libgcc/__muldi3.o libgcc/__udivmoddi4.o libgcc/__umoddi3.o \
+ libgcc/__divdi3.o libgcc/__moddi3.o
+
+LIBCONSOLE_OBJS = \
+ \
+ sys/openconsole.o sys/line_input.o \
+ sys/colortable.o sys/screensize.o \
+ \
+ sys/stdcon_read.o sys/stdcon_write.o sys/rawcon_read.o \
+ sys/rawcon_write.o sys/err_read.o sys/err_write.o \
+ sys/null_read.o sys/null_write.o sys/serial_write.o \
+ \
+ sys/xserial_write.o \
+ \
+ sys/ansi.o \
+ \
+ sys/ansicon_write.o sys/ansiserial_write.o \
+ \
+ syslinux/serial.o
+
+LIBOTHER_OBJS = \
+ atoi.o atol.o atoll.o calloc.o creat.o \
ctypes.o errno.o fgetc.o fgets.o fopen.o fprintf.o fputc.o \
- fclose.o putchar.o setjmp.o \
+ fclose.o putchar.o setjmp.o \
fputs.o fread2.o fread.o free.o fwrite2.o fwrite.o getopt.o \
lrand48.o malloc.o stack.o memccpy.o memchr.o memcmp.o \
memcpy.o mempcpy.o memmem.o memmove.o memset.o memswap.o \
- exit.o onexit.o \
perror.o printf.o puts.o qsort.o realloc.o seed48.o snprintf.o \
- sprintf.o srand48.o sscanf.o stack.o strcasecmp.o strcat.o \
- strchr.o strcmp.o strcpy.o strdup.o strlen.o \
- strerror.o strnlen.o \
+ sprintf.o srand48.o sscanf.o strcasecmp.o strcat.o \
+ strchr.o strcmp.o strcpy.o strdup.o strerror.o strlen.o \
+ strnlen.o \
strncasecmp.o strncat.o strncmp.o strncpy.o strndup.o \
- stpcpy.o stpncpy.o \
+ stpcpy.o stpncpy.o \
strntoimax.o strntoumax.o strrchr.o strsep.o strspn.o strstr.o \
strtoimax.o strtok.o strtol.o strtoll.o strtoul.o strtoull.o \
strtoumax.o vfprintf.o vprintf.o vsnprintf.o vsprintf.o \
asprintf.o vasprintf.o strlcpy.o strlcat.o \
vsscanf.o zalloc.o \
\
- lmalloc.o lstrdup.o \
- \
- dprintf.o vdprintf.o \
+ sys/readdir.o getcwd.o chdir.o fdopendir.o \
\
- sys/readdir.o getcwd.o chdir.o fdopendir.o \
- \
- libgcc/__ashldi3.o libgcc/__udivdi3.o \
+ libgcc/__ashldi3.o libgcc/__udivdi3.o \
libgcc/__negdi2.o libgcc/__ashrdi3.o libgcc/__lshrdi3.o \
libgcc/__muldi3.o libgcc/__udivmoddi4.o libgcc/__umoddi3.o \
libgcc/__divdi3.o libgcc/__moddi3.o \
\
- sys/intcall.o sys/farcall.o sys/cfarcall.o sys/zeroregs.o \
- sys/entry.o sys/exit.o sys/argv.o sys/times.o \
- sys/fileinfo.o sys/opendev.o sys/read.o sys/write.o sys/ftell.o \
- sys/close.o sys/open.o sys/fileread.o sys/fileclose.o \
- sys/openmem.o \
- sys/isatty.o sys/fstat.o \
- \
- sys/zfile.o sys/zfopen.o \
- \
sys/openconsole.o sys/line_input.o \
sys/colortable.o sys/screensize.o \
\
@@ -58,86 +143,40 @@ LIBOBJS = \
\
sys/ansi.o \
\
- sys/libansi.o \
- \
- sys/gpxe.o \
- \
sys/ansicon_write.o sys/ansiserial_write.o \
\
- sys/vesacon_write.o sys/vesaserial_write.o \
- sys/vesa/initvesa.o sys/vesa/drawtxt.o sys/vesa/background.o \
- sys/vesa/alphatbl.o sys/vesa/screencpy.o sys/vesa/fmtpixel.o \
- sys/vesa/i915resolution.o \
- \
- pci/cfgtype.o pci/scan.o pci/bios.o \
- pci/readb.o pci/readw.o pci/readl.o \
- pci/writeb.o pci/writew.o pci/writel.o \
- \
- zlib/adler32.o zlib/compress.o zlib/crc32.o \
- zlib/uncompr.o zlib/deflate.o zlib/trees.o zlib/zutil.o \
- zlib/inflate.o zlib/infback.o zlib/inftrees.o zlib/inffast.o \
- \
- libpng/png.o libpng/pngset.o libpng/pngget.o libpng/pngrutil.o \
- libpng/pngtrans.o libpng/pngwutil.o libpng/pngread.o \
- libpng/pngrio.o libpng/pngwio.o libpng/pngwrite.o \
- libpng/pngrtran.o libpng/pngwtran.o libpng/pngmem.o \
- libpng/pngerror.o libpng/pngpread.o \
- \
- jpeg/tinyjpeg.o jpeg/jidctflt.o jpeg/decode1.o jpeg/decode3.o \
- jpeg/grey.o jpeg/yuv420p.o \
- jpeg/rgb24.o jpeg/bgr24.o \
- jpeg/rgba32.o jpeg/bgra32.o \
+ pci/cfgtype.o pci/scan.o pci/bios.o \
+ pci/readb.o pci/readw.o pci/readl.o \
+ pci/writeb.o pci/writew.o pci/writel.o \
\
sys/x86_init_fpu.o math/pow.o math/strtod.o \
\
- syslinux/idle.o syslinux/reboot.o \
- syslinux/features.o syslinux/config.o syslinux/serial.o \
- syslinux/ipappend.o syslinux/dsinfo.o syslinux/version.o \
- syslinux/keyboard.o \
- \
- syslinux/memscan.o \
- \
- syslinux/addlist.o syslinux/freelist.o syslinux/memmap.o \
- syslinux/movebits.o syslinux/shuffle.o syslinux/shuffle_pm.o \
- syslinux/shuffle_rm.o syslinux/zonelist.o \
- syslinux/dump_mmap.o syslinux/dump_movelist.o \
- \
- syslinux/run_default.o syslinux/run_command.o \
- syslinux/cleanup.o syslinux/localboot.o syslinux/runimage.o \
- \
- syslinux/loadfile.o syslinux/floadfile.o syslinux/zloadfile.o \
- \
- syslinux/load_linux.o syslinux/initramfs.o \
- syslinux/initramfs_file.o syslinux/initramfs_loadfile.o \
- syslinux/initramfs_archive.o \
- \
- syslinux/pxe_get_cached.o syslinux/pxe_get_nic.o \
- syslinux/pxe_dns.o \
- \
- syslinux/adv.o syslinux/advwrite.o syslinux/getadv.o \
- syslinux/setadv.o \
- \
- syslinux/video/fontquery.o syslinux/video/forcetext.o \
- syslinux/video/reportmode.o
+ syslinux/memscan.o
-# These are the objects which are also imported into the core
-LIBCOREOBJS = \
- memcpy.o mempcpy.o memset.o memcmp.o memmove.o \
- strlen.o stpcpy.o strcpy.o strcmp.o strlcpy.o strlcat.o \
- strchr.o strncmp.o strncpy.o \
- \
- snprintf.o sprintf.o vsnprintf.o \
- \
- dprintf.o vdprintf.o \
- \
- zalloc.o strdup.o \
- \
- sys/intcall.o sys/farcall.o sys/cfarcall.o sys/zeroregs.o \
- \
- libgcc/__ashldi3.o libgcc/__udivdi3.o \
- libgcc/__negdi2.o libgcc/__ashrdi3.o libgcc/__lshrdi3.o \
- libgcc/__muldi3.o libgcc/__udivmoddi4.o libgcc/__umoddi3.o \
- libgcc/__divdi3.o libgcc/__moddi3.o
+MINLIBOBJS = \
+ $(LIBOTHER_OBJS) \
+ $(LIBENTRY_OBJS) \
+ $(LIBGCC_OBJS) \
+ $(LIBCONSOLE_OBJS) \
+ $(LIBLOAD_OBJS) \
+ $(LIBMODULE_OBJS) \
+# $(LIBVESA_OBJS)
+
+
+DYNLIBOBJS = \
+ $(LIBZLIB_OBJS) \
+ $(LIBPNG_OBJS) \
+ $(LIBJPG_OBJS) \
+ $(LIBPCI_OBJS) \
+ $(LIBVESA_OBJS) \
+ $(LIBSYSLINUX_OBJS) \
+ $(LIBLOAD_OBJS) \
+ $(DYNENTRY_OBJS)
+
+
+LIBOBJS = \
+ $(MINLIBOBJS) \
+ $(DYNLIBOBJS)
BINDIR = /usr/bin
LIBDIR = /usr/lib
@@ -146,18 +185,23 @@ AUXDIR = $(DATADIR)/syslinux
INCDIR = /usr/include
COM32DIR = $(AUXDIR)/com32
-all: libcom32.a libcomcore.a
+all: libcom32.a libcom32min.a klibc.c32
libcom32.a : $(LIBOBJS)
rm -f $@
$(AR) cq $@ $^
$(RANLIB) $@
-libcomcore.a : $(LIBCOREOBJS)
+$(LIBMODULE_OBJS) : CFLAGS += -DELF_DEBUG
+libcom32min.a : $(MINLIBOBJS)
rm -f $@
$(AR) cq $@ $^
$(RANLIB) $@
+klibc.c32 : $(DYNLIBOBJS)
+ rm -f $@
+ $(LD) -shared -T elf32.ld -o $@ $(DYNLIBOBJS)
+
tidy dist clean:
rm -f sys/vesa/alphatbl.c
find . \( -name \*.o -o -name \*.a -o -name .\*.d -o -name \*.tmp \) -print0 | \
diff --git a/com32/lib/free.c b/com32/lib/free.c
index be23865a..9fea69fb 100644
--- a/com32/lib/free.c
+++ b/com32/lib/free.c
@@ -107,6 +107,11 @@ void free(void *ptr)
assert(ah->a.type == ARENA_TYPE_USED);
#endif
+ if (ah->a.type != ARENA_TYPE_USED || ah->a.size == 0) {
+ printf("error in free, ptr = %p\n", ptr);
+ return;
+ }
+
__free_block(ah);
/* Here we could insert code to return memory to the system. */
diff --git a/com32/lib/malloc.c b/com32/lib/malloc.c
index ec103ab3..136e41b4 100644
--- a/com32/lib/malloc.c
+++ b/com32/lib/malloc.c
@@ -7,6 +7,7 @@
#include <stdlib.h>
#include <string.h>
#include <com32.h>
+#include <errno.h>
#include <syslinux/memscan.h>
#include "init.h"
#include "malloc.h"
@@ -144,7 +145,7 @@ void *malloc(size_t size)
size = (size + 2 * sizeof(struct arena_header) - 1) & ARENA_SIZE_MASK;
for (fp = __malloc_head.next_free; fp->a.type != ARENA_TYPE_HEAD;
- fp = fp->next_free) {
+ fp = fp->next_free) {
if (fp->a.size >= size) {
/* Found fit -- allocate out of this block */
return __malloc_from_block(fp, size);
@@ -154,3 +155,23 @@ void *malloc(size_t size)
/* Nothing found... need to request a block from the kernel */
return NULL; /* No kernel to get stuff from */
}
+
+/* need to revisit this later */
+int posix_memalign(void **memptr, size_t align, size_t size)
+{
+ void *ptr;
+ unsigned long tmp;
+
+ ptr = malloc(size + align - 1);
+ if (!ptr)
+ return -ENOMEM;
+
+ /* do the alignment */
+ tmp = (unsigned long)ptr;
+ tmp = (tmp + align -1) & ~(align - 1);
+ ptr = (void *)tmp;
+
+ *memptr = ptr;
+ return 0;
+
+}