summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2013-03-18 04:14:02 (GMT)
committerH. Peter Anvin <hpa@zytor.com>2013-03-18 04:14:02 (GMT)
commit507fab0b8b1ce1ed19a1e5c1138d71c2c58f4f1e (patch)
treea24053b3d1217a98532aa54647f93b3d8453a9fd
parente18ab632a9b45689f5b92b67c94c2bfef726868c (diff)
downloadvirtio9p-507fab0b8b1ce1ed19a1e5c1138d71c2c58f4f1e.zip
virtio9p-507fab0b8b1ce1ed19a1e5c1138d71c2c58f4f1e.tar.gz
virtio9p-507fab0b8b1ce1ed19a1e5c1138d71c2c58f4f1e.tar.bz2
virtio9p-507fab0b8b1ce1ed19a1e5c1138d71c2c58f4f1e.tar.xz
Cleaner way to handle the relocation code
Actually overlay the relocation code with the .rbss segment, even in VMA space. This means that the VMA addresses for labels in the .textearly segment are actually correct and we don't have to play any funny games, but also that the .textearly segment doesn't actually take up any space in memory.
-rw-r--r--dostsr.ld24
-rw-r--r--start.asm5
2 files changed, 17 insertions, 12 deletions
diff --git a/dostsr.ld b/dostsr.ld
index d1c5c3a..190660d 100644
--- a/dostsr.ld
+++ b/dostsr.ld
@@ -54,6 +54,7 @@ SECTIONS
_erdata = .;
. = ALIGN(16);
+ __rbss_vma = .;
.rbss (NOLOAD) : {
__rbss_start = .;
*(SORT_BY_ALIGNMENT(.rbss*))
@@ -66,22 +67,27 @@ SECTIONS
*(.rbuf)
__rbuf_end = .;
}
+ . = ALIGN(16);
+ __tsr_end = .;
/* ----------------------------------------------------------------- *
* Sections dropped at TSR time
* ----------------------------------------------------------------- */
- . = ALIGN(16);
- __init_vma = .;
- __init_lma = __dgroup_lma + __rbss_start - __init_vma;
-
- __textearly_vma = .;
- .textearly : AT (__textearly_vma + __init_lma) {
+ /* .textearly overlays the .rbss segment */
+ __textearly_vma = __rbss_vma;
+ __textearly_lma = __dgroup_lma + __rbss_vma;
+ . = __textearly_vma;
+ .textearly : AT (__textearly_lma) {
*(.textearly)
} = 0x90909090
+ . = ALIGN(16);
_etextearly = .;
- /* This is the address of _start before moving to clear .rbss/.rbuf */
- _exe_start = _start + __rbss_start - __init_vma;
+ _exe_start = _start;
+
+ . = (_etextearly > __tsr_end) ? _etextearly : __tsr_end;
+ __init_vma = .;
+ __init_lma = __dgroup_lma + _etextearly - __init_vma;
. = ALIGN(4);
__text_vma = .;
@@ -103,7 +109,7 @@ SECTIONS
. = ALIGN(16);
} = 0
_edata = .;
- _edata_premove = _edata + __rbss_start - __init_vma;
+ _edata_premove = _edata + __init_lma - __dgroup_lma;
__move_dwords = (_edata - __text_vma) >> 2;
_exe_edata_low = ((_edata + __init_lma) & 511);
diff --git a/start.asm b/start.asm
index 31ce2a2..64c1bf6 100644
--- a/start.asm
+++ b/start.asm
@@ -53,9 +53,8 @@ GPROC(_start)
movw $_edata_premove-4,%si
rep movsl
- /* This has to be absolute, so we can't just jmp */
- movw $start,%di
- jmp *%di
+ /* Move to the real .text segment before clearing .rbss */
+ jmp start
END(_start)
.section ".text","ax"