yasm/modules/objfmts/bin/tests/multisect/ldlinux-sects.asm
Peter Johnson 52affeb01a Add NASM-compatible multi-section binary support to bin object format.
This allows for arbitrary load (LMA) and execution (VMA) addresses.

The following new section attributes are supported:
 - start (LMA start address)
 - follows (follow another section's last LMA)
 - align (LMA alignment)
 - vstart (VMA start address)
 - vfollows (follow another section's last VMA)
 - valign (VMA alignment)
In addition, sections can be designed progbits or nobits.

The following special symbols are generated for program use:
 - section.<sectname>.start (LMA start address)
 - section.<sectname>.vstart (VMA start address)
 - section.<sectname>.length (section length)

The ORG directive adjusts the file offset relative to LMA, so that if
ORG=0x100, a section with LMA=0x100 will be at file offset 0.

VMA addresses are the same as LMA addresses unless otherwise specified.

Full map file support is supported via the [MAP] directive.  The map output
filename can be set either as a parameter to the [MAP] directive or on the
command line with --mapfile=<filename>.  MAP options are BRIEF, SECTIONS,
SEGMENTS, SYMBOLS, and ALL (all of the above).  If no filename is specified
either on the command line or in the source file, the map is output to
standard output.

Full documentation will be added to the Yasm manual in the near future.

This implementation supports several configurations NASM does not, for
instance http://osdir.com/ml/lang.nasm.devel/2004-12/msg00032.html .
It is also fully 64-bit aware.

Fixes: #71, #99.

svn path=/trunk/yasm/; revision=2010
2007-11-14 08:33:32 +00:00

102 lines
2 KiB
NASM

[map all]
BSS_START equ 0800h
LATEBSS_START equ 0B800h
TEXT_START equ 7C00h
STACK_SIZE equ 4096
STACK_START equ TEXT_START-STACK_SIZE
org TEXT_START
[section .text]
times 0x2410 db 0x1
[section .earlybss nobits start=BSS_START]
resb 0x40C4
[section .bcopy32 align=4 valign=16 follows=.data vfollows=.earlybss]
times 0x2A0 db 0x3
[section .config align=4 valign=16 follows=.bcopy32 vfollows=.bcopy32]
times 0x23 db 0x4
[section .config.end nobits valign=4 vfollows=.config]
[section .bss1 nobits valign=16 vfollows=.config.end]
resb 0x1FB
[section .text start=TEXT_START]
[section .data align=16]
times 0x590 db 0x2
[section .adv progbits align=1 follows=.config]
[section .bss nobits align=16 follows=.adv]
resb 0x3900
[section .stack nobits align=16 start=STACK_START]
resb STACK_SIZE
[section .stack nobits align=16 start=STACK_START]
[section .stack nobits align=16 start=STACK_START]
[section .earlybss]
[section .bss]
[section .text]
[section .bss]
[section .text]
[section .data]
[section .text]
[section .text]
[section .text]
[section .bss]
[section .text]
[section .data]
[section .bss]
[section .text]
[section .data]
[section .bss]
[section .text]
[section .text]
[section .text]
[section .data]
[section .bss1]
[section .data]
[section .text]
[section .bss1]
[section .text]
[section .text]
[section .data]
[section .text]
[section .text]
[section .bss]
[section .text]
[section .bss]
[section .text]
[section .data]
[section .text]
[section .text]
[section .bss1]
[section .data]
[section .text]
[section .text]
[section .data]
[section .config]
[section .bss]
[section .text]
[section .text]
[section .text]
[section .data]
[section .text]
[section .data]
[section .config]
[section .bss]
[section .text]
[section .text]
[section .data]
[section .bss]
[section .bcopy32]
[section .data]
[section .bcopy32]
[section .earlybss]
[section .text]
[section .text]
[section .bss]
[section .data]
[section .bss1]
[section .text]
[section .data]
[section .bss1]
[section .text]
[section .bss]
[section .text]
[section .text]
[section .text]
[section .bss]
[section .data]