aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@linux.intel.com>2010-07-19 16:17:04 -0700
committerH. Peter Anvin <hpa@linux.intel.com>2010-07-19 16:20:23 -0700
commitdb8899d1faa6fc6e3ea8b89684e5a623df9909ed (patch)
treeb04a876eb9d9f0c8718831875c92f3aca3b16c77
parentccad6e87e9b9a51f3781cc6e4dc045525c5c5342 (diff)
downloadsyslinux-devel-db8899d1faa6fc6e3ea8b89684e5a623df9909ed.tar.gz
syslinux-devel-db8899d1faa6fc6e3ea8b89684e5a623df9909ed.tar.xz
syslinux-devel-db8899d1faa6fc6e3ea8b89684e5a623df9909ed.zip
dos: change the link procedure to use negative pointers below DGROUP
Use negative pointer values below DGROUP, i.e. for the .payload segment. This makes it a lot easier to figure out if we are dealing with pointers that shouldn't come from where they do, since the DGROUP and .payload segments no longer overlap, and in fact are congruent. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
-rwxr-xr-xdos/Makefile4
-rwxr-xr-xdos/dosexe.ld10
-rw-r--r--dos/getsetsl.c2
-rw-r--r--libinstaller/syslxint.h4
4 files changed, 10 insertions, 10 deletions
diff --git a/dos/Makefile b/dos/Makefile
index 3d19ff29..9f48962b 100755
--- a/dos/Makefile
+++ b/dos/Makefile
@@ -31,10 +31,10 @@ SRCS = syslinux.c \
../libinstaller/syslxopt.c \
../libinstaller/setadv.c \
../libinstaller/bootsect_bin.c \
- ../libinstaller/ldlinux_bin.c \
../libinstaller/mbr_bin.c \
$(wildcard ../libfat/*.c)
-OBJS = header.o crt0.o $(patsubst %.c,%.o,$(notdir $(SRCS)))
+OBJS = header.o crt0.o ldlinux.o \
+ $(patsubst %.c,%.o,$(notdir $(SRCS)))
LIBOBJS = int2526.o conio.o memcpy.o memset.o memmove.o skipatou.o atou.o \
malloc.o free.o getopt_long.o getsetsl.o strchr.o strtoul.o \
strntoumax.o argv.o printf.o __divdi3.o __udivmoddi4.o
diff --git a/dos/dosexe.ld b/dos/dosexe.ld
index 4612b30a..c67c5060 100755
--- a/dos/dosexe.ld
+++ b/dos/dosexe.ld
@@ -26,20 +26,22 @@ SECTIONS
__header_size = .;
__payload_lma = .;
- . = 0;
+ . = 0x100000000 - syslinux_ldlinux_size;
.payload : AT (__payload_lma) {
__payload_start = .;
- ldlinux_bin.o(.data)
+ *(.payload)
__payload_end = .;
}
__payload_len = __payload_end - __payload_start;
__payload_dwords = __payload_len >> 2;
- . = ALIGN(16);
- __text_lma = __payload_lma + .;
+ __text_lma = __payload_lma + syslinux_ldlinux_size;
__payload_sseg = (__payload_lma - __text_lma) >> 4;
_exe_text_seg = (__text_lma - __header_size) >> 4;
+ __assert1 = ASSERT((__payload_len == syslinux_ldlinux_size),
+ "syslinux_ldlinux_size must equal the size of .payload");
+
. = 0;
.text : AT (__text_lma) {
*(.text .stub .text.* .gnu.linkonce.t.*)
diff --git a/dos/getsetsl.c b/dos/getsetsl.c
index a48f3df2..5c1dbbda 100644
--- a/dos/getsetsl.c
+++ b/dos/getsetsl.c
@@ -87,7 +87,7 @@ void memcpy_to_sl(void *dst, const void *src, size_t len)
uint16_t seg;
uint16_t off;
- seg = ldlinux_seg + ((size_t)dst >> 4);
+ seg = ds() + ((size_t)dst >> 4);
off = (size_t)dst & 15;
asm volatile("pushw %%es ; "
diff --git a/libinstaller/syslxint.h b/libinstaller/syslxint.h
index f16c2e5c..b8e872a7 100644
--- a/libinstaller/syslxint.h
+++ b/libinstaller/syslxint.h
@@ -111,8 +111,6 @@ static inline void set_64(uint64_t *p, uint64_t v)
*/
#ifdef __MSDOS__
-extern uint16_t ldlinux_seg; /* Defined in dos/syslinux.c */
-
static inline __attribute__ ((const))
uint16_t ds(void)
{
@@ -125,7 +123,7 @@ static inline void *set_fs(const void *p)
{
uint16_t seg;
- seg = ldlinux_seg + ((size_t) p >> 4);
+ seg = ds() + ((size_t) p >> 4);
asm volatile ("movw %0,%%fs"::"rm" (seg));
return (void *)((size_t) p & 0xf);
}