From: H. Peter Anvin <hpa@zy...> - 2004-12-27 06:35:32
I just ran into a *very* real-life problem which shows that some of the
assumptions we've made about nobits sections are just plain wrong.
This is an excerpt from my current SYSLINUX development tree:
; Memory below 0800h is reserved for the BIOS and the MBR
BSS_START equ 0800h
; PXELINUX needs lots of BSS, so it relocates itself on startup
TEXT_START equ 9000h
TEXT_START equ 7C00h
; The various sections and their relationship
section .earlybss nobits start=BSS_START
section .bcopy32 align=16 follows=.data vfollows=.earlybss
section .bss nobits align=256 vfollows=.bcopy32
section .text start=TEXT_START
section .data align=16 follows=.text
section .latebss nobits align=16 follows=.bcopy32
The section .bcopy32 is relocated at runtime, and so has LMA != VMA.
There are two different sections following it, quite literally; one
after its VMA and one after its LMA.
Anyway, this doesn't currently work; NASM rejects the vfollows=
statement on .bss. I'm going to try to fix this, but I haven't groped
around too much inside the outbin code.
A few more things: it would be a very useful things to have
auto-generated symbols for the vstart as well as the start, and the
total length. Although this can be accomplished with carefully
positioned symbols, it would be more foolproof if it didn't need it.
Also a thought for people: how hard do you guys think it would be to put
a hack in to show the VMA in the list file when using -f bin, instead of
the section offset? It would definitely make debugging of
NASM-generated code a lot easier, especially when making lots of sections.
Finally, I really think [map] needs to be command-line optionable. It's
really awkward for it to be specified inline.