Преглед на файлове

[i386] Simplify linker script and standardise linker-defined symbol names

Reduce the number of sections within the linker script to match the
number of practical sections within the output file.

Define _section, _msection, _esection, _section_filesz, _section_memsz,
and _section_lma for each section, replacing the mixture of symbols that
previously existed.

In particular, replace _text and _end with _textdata and _etextdata, to
make it explicit within code that uses these symbols that the .text and
.data sections are always treated as a single contiguous block.
tags/v0.9.6
Michael Brown преди 15 години
родител
ревизия
13d09e6719

+ 4
- 4
src/arch/i386/core/relocate.c Целия файл

18
 #define max_align ( ( unsigned int ) _max_align )
18
 #define max_align ( ( unsigned int ) _max_align )
19
 
19
 
20
 /* Linker symbols */
20
 /* Linker symbols */
21
-extern char _text[];
22
-extern char _end[];
21
+extern char _textdata[];
22
+extern char _etextdata[];
23
 
23
 
24
 /* within 1MB of 4GB is too close. 
24
 /* within 1MB of 4GB is too close. 
25
  * MAX_ADDR is the maximum address we can easily do DMA to.
25
  * MAX_ADDR is the maximum address we can easily do DMA to.
47
 
47
 
48
 	/* Get memory map and current location */
48
 	/* Get memory map and current location */
49
 	get_memmap ( &memmap );
49
 	get_memmap ( &memmap );
50
-	start = virt_to_phys ( _text );
51
-	end = virt_to_phys ( _end );
50
+	start = virt_to_phys ( _textdata );
51
+	end = virt_to_phys ( _etextdata );
52
 	size = ( end - start );
52
 	size = ( end - start );
53
 	padded_size = ( size + max_align - 1 );
53
 	padded_size = ( size + max_align - 1 );
54
 
54
 

+ 2
- 2
src/arch/i386/firmware/pcbios/e820mangler.S Целия файл

66
 	.align 16
66
 	.align 16
67
 	.globl hidemem_base
67
 	.globl hidemem_base
68
 	.globl hidemem_umalloc
68
 	.globl hidemem_umalloc
69
-	.globl hidemem_text
69
+	.globl hidemem_textdata
70
 memory_windows:
70
 memory_windows:
71
 base_memory_window:	.long 0x00000000, 0x00000000 /* Start of memory */
71
 base_memory_window:	.long 0x00000000, 0x00000000 /* Start of memory */
72
 
72
 
76
 hidemem_umalloc:	.long 0xffffffff, 0xffffffff /* Changes at runtime */
76
 hidemem_umalloc:	.long 0xffffffff, 0xffffffff /* Changes at runtime */
77
 			.long 0xffffffff, 0xffffffff /* Changes at runtime */
77
 			.long 0xffffffff, 0xffffffff /* Changes at runtime */
78
 
78
 
79
-hidemem_text:		.long 0xffffffff, 0xffffffff /* Changes at runtime */
79
+hidemem_textdata:	.long 0xffffffff, 0xffffffff /* Changes at runtime */
80
 			.long 0xffffffff, 0xffffffff /* Changes at runtime */
80
 			.long 0xffffffff, 0xffffffff /* Changes at runtime */
81
 
81
 
82
 			.long 0xffffffff, 0xffffffff /* End of memory */
82
 			.long 0xffffffff, 0xffffffff /* End of memory */

+ 16
- 16
src/arch/i386/firmware/pcbios/hidemem.c Целия файл

55
 #define hidemem_umalloc __use_data16 ( hidemem_umalloc )
55
 #define hidemem_umalloc __use_data16 ( hidemem_umalloc )
56
 
56
 
57
 /** Hidden text memory */
57
 /** Hidden text memory */
58
-extern struct hidden_region __data16 ( hidemem_text );
59
-#define hidemem_text __use_data16 ( hidemem_text )
58
+extern struct hidden_region __data16 ( hidemem_textdata );
59
+#define hidemem_textdata __use_data16 ( hidemem_textdata )
60
 
60
 
61
 /** Assembly routine in e820mangler.S */
61
 /** Assembly routine in e820mangler.S */
62
 extern void int15();
62
 extern void int15();
66
 #define int15_vector __use_text16 ( int15_vector )
66
 #define int15_vector __use_text16 ( int15_vector )
67
 
67
 
68
 /* The linker defines these symbols for us */
68
 /* The linker defines these symbols for us */
69
-extern char _text[];
70
-extern char _end[];
71
-extern char _text16_size[];
72
-#define _text16_size ( ( unsigned int ) _text16_size )
73
-extern char _data16_size[];
74
-#define _data16_size ( ( unsigned int ) _data16_size )
69
+extern char _textdata[];
70
+extern char _etextdata[];
71
+extern char _text16_memsz[];
72
+#define _text16_memsz ( ( unsigned int ) _text16_memsz )
73
+extern char _data16_memsz[];
74
+#define _data16_memsz ( ( unsigned int ) _data16_memsz )
75
 
75
 
76
 /**
76
 /**
77
  * Hide region of memory from system memory map
77
  * Hide region of memory from system memory map
110
  *
110
  *
111
  */
111
  */
112
 void hide_umalloc ( physaddr_t start, physaddr_t end ) {
112
 void hide_umalloc ( physaddr_t start, physaddr_t end ) {
113
-	assert ( end <= virt_to_phys ( _text ) );
113
+	assert ( end <= virt_to_phys ( _textdata ) );
114
 	hide_region ( &hidemem_umalloc, start, end );
114
 	hide_region ( &hidemem_umalloc, start, end );
115
 }
115
 }
116
 
116
 
118
  * Hide .text and .data
118
  * Hide .text and .data
119
  *
119
  *
120
  */
120
  */
121
-void hide_text ( void ) {
122
-	hide_region ( &hidemem_text, virt_to_phys ( _text ),
123
-		      virt_to_phys ( _end ) );
121
+void hide_textdata ( void ) {
122
+	hide_region ( &hidemem_textdata, virt_to_phys ( _textdata ),
123
+		      virt_to_phys ( _etextdata ) );
124
 }
124
 }
125
 
125
 
126
 /**
126
 /**
148
 
148
 
149
 	/* Initialise the hidden regions */
149
 	/* Initialise the hidden regions */
150
 	hide_basemem();
150
 	hide_basemem();
151
-	hide_umalloc ( virt_to_phys ( _text ), virt_to_phys ( _text ) );
152
-	hide_text();
151
+	hide_umalloc ( virt_to_phys ( _textdata ), virt_to_phys ( _textdata ) );
152
+	hide_textdata();
153
 
153
 
154
 	/* Some really moronic BIOSes bring up the PXE stack via the
154
 	/* Some really moronic BIOSes bring up the PXE stack via the
155
 	 * UNDI loader entry point and then don't bother to unload it
155
 	 * UNDI loader entry point and then don't bother to unload it
161
 	 * We use a heuristic to guess whether or not we are being
161
 	 * We use a heuristic to guess whether or not we are being
162
 	 * loaded sensibly.
162
 	 * loaded sensibly.
163
 	 */
163
 	 */
164
-	rm_cs_top = ( ( ( rm_cs << 4 ) + _text16_size + 1024 - 1 ) >> 10 );
165
-	rm_ds_top = ( ( ( rm_ds << 4 ) + _data16_size + 1024 - 1 ) >> 10 );
164
+	rm_cs_top = ( ( ( rm_cs << 4 ) + _text16_memsz + 1024 - 1 ) >> 10 );
165
+	rm_ds_top = ( ( ( rm_ds << 4 ) + _data16_memsz + 1024 - 1 ) >> 10 );
166
 	fbms = get_fbms();
166
 	fbms = get_fbms();
167
 	if ( ( rm_cs_top < fbms ) && ( rm_ds_top < fbms ) ) {
167
 	if ( ( rm_cs_top < fbms ) && ( rm_ds_top < fbms ) ) {
168
 		DBG ( "Detected potentially unsafe UNDI load at CS=%04x "
168
 		DBG ( "Detected potentially unsafe UNDI load at CS=%04x "

+ 7
- 7
src/arch/i386/interface/pxe/pxe_entry.S Целия файл

44
 	.byte SegDescCnt		/* SegDescCnt */
44
 	.byte SegDescCnt		/* SegDescCnt */
45
 	.word 0				/* FirstSelector */
45
 	.word 0				/* FirstSelector */
46
 pxe_segments:
46
 pxe_segments:
47
-	.word 0, 0, 0, _data16_size	/* Stack */
48
-	.word 0, 0, 0, _data16_size	/* UNDIData */
49
-	.word 0, 0, 0, _text16_size	/* UNDICode */
50
-	.word 0, 0, 0, _text16_size	/* UNDICodeWrite */
47
+	.word 0, 0, 0, _data16_memsz	/* Stack */
48
+	.word 0, 0, 0, _data16_memsz	/* UNDIData */
49
+	.word 0, 0, 0, _text16_memsz	/* UNDICode */
50
+	.word 0, 0, 0, _text16_memsz	/* UNDICodeWrite */
51
 	.word 0, 0, 0, 0		/* BC_Data */
51
 	.word 0, 0, 0, 0		/* BC_Data */
52
 	.word 0, 0, 0, 0		/* BC_Code */
52
 	.word 0, 0, 0, 0		/* BC_Code */
53
 	.word 0, 0, 0, 0		/* BC_CodeWrite */
53
 	.word 0, 0, 0, 0		/* BC_CodeWrite */
76
 	.long 0				/* PMEntry */
76
 	.long 0				/* PMEntry */
77
 	.word 0				/* PMSelector */
77
 	.word 0				/* PMSelector */
78
 	.word 0				/* StackSeg */
78
 	.word 0				/* StackSeg */
79
-	.word _data16_size		/* StackSize */
79
+	.word _data16_memsz		/* StackSize */
80
 	.word 0				/* BC_CodeSeg */
80
 	.word 0				/* BC_CodeSeg */
81
 	.word 0				/* BC_CodeSize */
81
 	.word 0				/* BC_CodeSize */
82
 	.word 0				/* BC_DataSeg */
82
 	.word 0				/* BC_DataSeg */
83
 	.word 0				/* BC_DataSize */
83
 	.word 0				/* BC_DataSize */
84
 	.word 0				/* UNDIDataSeg */
84
 	.word 0				/* UNDIDataSeg */
85
-	.word _data16_size		/* UNDIDataSize */
85
+	.word _data16_memsz		/* UNDIDataSize */
86
 	.word 0				/* UNDICodeSeg */
86
 	.word 0				/* UNDICodeSeg */
87
-	.word _text16_size		/* UNDICodeSize */
87
+	.word _text16_memsz		/* UNDICodeSize */
88
 	.word ppxe, 0			/* PXEPtr */
88
 	.word ppxe, 0			/* PXEPtr */
89
 	.equ	pxenv_length, . - pxenv
89
 	.equ	pxenv_length, . - pxenv
90
 	.size	pxenv, . - pxenv
90
 	.size	pxenv, . - pxenv

+ 1
- 1
src/arch/i386/prefix/dskprefix.S Целия файл

144
 	/* Jump to loaded copy */
144
 	/* Jump to loaded copy */
145
 	ljmp	$SYSSEG, $start_runtime
145
 	ljmp	$SYSSEG, $start_runtime
146
 
146
 
147
-endseg:	.word SYSSEG + _load_size_pgh
147
+endseg:	.word SYSSEG + _filesz_pgh
148
 	.section ".zinfo.fixup", "a"	/* Compressor fixup information */
148
 	.section ".zinfo.fixup", "a"	/* Compressor fixup information */
149
 	.ascii	"SUBW"
149
 	.ascii	"SUBW"
150
 	.long	endseg
150
 	.long	endseg

+ 1
- 1
src/arch/i386/prefix/hdprefix.S Целия файл

63
 max_head:
63
 max_head:
64
 	.byte	0
64
 	.byte	0
65
 load_length:
65
 load_length:
66
-	.long	_load_size_sect
66
+	.long	_filesz_sect
67
 	
67
 	
68
 	.section ".zinfo.fixup", "a"	/* Compressor fixup information */
68
 	.section ".zinfo.fixup", "a"	/* Compressor fixup information */
69
 	.ascii	"SUBL"
69
 	.ascii	"SUBL"

+ 18
- 18
src/arch/i386/prefix/libprefix.S Целия файл

511
 	shlw	$6, %ax
511
 	shlw	$6, %ax
512
 
512
 
513
 	/* .data16 segment address */
513
 	/* .data16 segment address */
514
-	subw	$_data16_size_pgh, %ax
514
+	subw	$_data16_memsz_pgh, %ax
515
 	pushw	%ax
515
 	pushw	%ax
516
 
516
 
517
 	/* .text16 segment address */
517
 	/* .text16 segment address */
518
-	subw	$_text16_size_pgh, %ax
518
+	subw	$_text16_memsz_pgh, %ax
519
 	pushw	%ax
519
 	pushw	%ax
520
 
520
 
521
 	/* Update FBMS */
521
 	/* Update FBMS */
594
 	jnz	1f
594
 	jnz	1f
595
 	movw	%cs, %si
595
 	movw	%cs, %si
596
 	shll	$4, %esi
596
 	shll	$4, %esi
597
-1:	addl	$_payload_offset, %esi
597
+1:	addl	$_payload_lma, %esi
598
 
598
 
599
 	/* Install .text16 and .data16 */
599
 	/* Install .text16 and .data16 */
600
 	pushl	%edi
600
 	pushl	%edi
601
 	movzwl	%ax, %edi
601
 	movzwl	%ax, %edi
602
 	shll	$4, %edi
602
 	shll	$4, %edi
603
-	movl	$_text16_size, %ecx
603
+	movl	$_text16_memsz, %ecx
604
 	movl	%ecx, %edx
604
 	movl	%ecx, %edx
605
 	call	install_block		/* .text16 */
605
 	call	install_block		/* .text16 */
606
 	movzwl	%bx, %edi
606
 	movzwl	%bx, %edi
607
 	shll	$4, %edi
607
 	shll	$4, %edi
608
-	movl	$_data16_progbits_size, %ecx
609
-	movl	$_data16_size, %edx
608
+	movl	$_data16_filesz, %ecx
609
+	movl	$_data16_memsz, %edx
610
 	call	install_block		/* .data16 */
610
 	call	install_block		/* .data16 */
611
 	popl	%edi
611
 	popl	%edi
612
 
612
 
622
 	 * prior to reading the E820 memory map and relocating
622
 	 * prior to reading the E820 memory map and relocating
623
 	 * properly.
623
 	 * properly.
624
 	 */
624
 	 */
625
-	movl	$_textdata_progbits_size, %ecx
626
-	movl	$_textdata_size, %edx
625
+	movl	$_textdata_filesz, %ecx
626
+	movl	$_textdata_memsz, %edx
627
 	call	install_block
627
 	call	install_block
628
 
628
 
629
 	/* Initialise librm at current location */
629
 	/* Initialise librm at current location */
681
 #if COMPRESS
681
 #if COMPRESS
682
 	.section ".zinfo", "a"
682
 	.section ".zinfo", "a"
683
 	.ascii	"COPY"
683
 	.ascii	"COPY"
684
-	.long	_prefix_load_offset
685
-	.long	_prefix_progbits_size
684
+	.long	_prefix_lma
685
+	.long	_prefix_filesz
686
 	.long	_max_align
686
 	.long	_max_align
687
 	.ascii	"PACK"
687
 	.ascii	"PACK"
688
-	.long	_text16_load_offset
689
-	.long	_text16_progbits_size
688
+	.long	_text16_lma
689
+	.long	_text16_filesz
690
 	.long	_max_align
690
 	.long	_max_align
691
 	.ascii	"PACK"
691
 	.ascii	"PACK"
692
-	.long	_data16_load_offset
693
-	.long	_data16_progbits_size
692
+	.long	_data16_lma
693
+	.long	_data16_filesz
694
 	.long	_max_align
694
 	.long	_max_align
695
 	.ascii	"PACK"
695
 	.ascii	"PACK"
696
-	.long	_textdata_load_offset
697
-	.long	_textdata_progbits_size
696
+	.long	_textdata_lma
697
+	.long	_textdata_filesz
698
 	.long	_max_align
698
 	.long	_max_align
699
 #else /* COMPRESS */
699
 #else /* COMPRESS */
700
 	.section ".zinfo", "a"
700
 	.section ".zinfo", "a"
701
 	.ascii	"COPY"
701
 	.ascii	"COPY"
702
-	.long	_prefix_load_offset
703
-	.long	_load_size
702
+	.long	_prefix_lma
703
+	.long	_filesz
704
 	.long	_max_align
704
 	.long	_max_align
705
 #endif /* COMPRESS */
705
 #endif /* COMPRESS */

+ 1
- 1
src/arch/i386/prefix/lkrnprefix.S Целия файл

92
 root_flags: 
92
 root_flags: 
93
 	.word	0
93
 	.word	0
94
 syssize: 
94
 syssize: 
95
-	.long	_load_size_pgh - PREFIXPGH
95
+	.long	_filesz_pgh - PREFIXPGH
96
 
96
 
97
 	.section ".zinfo.fixup", "a"	/* Compressor fixup information */
97
 	.section ".zinfo.fixup", "a"	/* Compressor fixup information */
98
 	.ascii	"SUBL"
98
 	.ascii	"SUBL"

+ 2
- 2
src/arch/i386/prefix/nbiprefix.S Целия файл

32
 	.byte	0
32
 	.byte	0
33
 	.byte	0x04		/* Last segment */
33
 	.byte	0x04		/* Last segment */
34
 	.long	0x00007e00
34
 	.long	0x00007e00
35
-imglen:	.long	_load_size - 512
36
-memlen:	.long	_load_size - 512
35
+imglen:	.long	_filesz - 512
36
+memlen:	.long	_filesz - 512
37
 	.size	segment_header, . - segment_header
37
 	.size	segment_header, . - segment_header
38
 
38
 
39
 	.section ".zinfo.fixup", "a"	/* Compressor fixup information */
39
 	.section ".zinfo.fixup", "a"	/* Compressor fixup information */

+ 7
- 7
src/arch/i386/prefix/romprefix.S Целия файл

30
 	.org	0x00
30
 	.org	0x00
31
 romheader:
31
 romheader:
32
 	.word	0xAA55			/* BIOS extension signature */
32
 	.word	0xAA55			/* BIOS extension signature */
33
-romheader_size:	.byte _load_size_sect	/* Size in 512-byte blocks */
33
+romheader_size:	.byte _filesz_sect	/* Size in 512-byte blocks */
34
 	jmp	init			/* Initialisation vector */
34
 	jmp	init			/* Initialisation vector */
35
 checksum:
35
 checksum:
36
 	.byte	0
36
 	.byte	0
58
 	.byte	0x03			/* PCI data structure revision */
58
 	.byte	0x03			/* PCI data structure revision */
59
 	.byte	0x02, 0x00, 0x00	/* Class code */
59
 	.byte	0x02, 0x00, 0x00	/* Class code */
60
 pciheader_image_length:
60
 pciheader_image_length:
61
-	.word	_load_size_sect		/* Image length */
61
+	.word	_filesz_sect		/* Image length */
62
 	.word	0x0001			/* Revision level */
62
 	.word	0x0001			/* Revision level */
63
 	.byte	0x00			/* Code type */
63
 	.byte	0x00			/* Code type */
64
 	.byte	0x80			/* Last image indicator */
64
 	.byte	0x80			/* Last image indicator */
65
 pciheader_runtime_length:
65
 pciheader_runtime_length:
66
-	.word	_load_size_sect		/* Maximum run-time image length */
66
+	.word	_filesz_sect		/* Maximum run-time image length */
67
 	.word	0x0000			/* Configuration utility code header */
67
 	.word	0x0000			/* Configuration utility code header */
68
 	.word	0x0000			/* DMTF CLP entry point */
68
 	.word	0x0000			/* DMTF CLP entry point */
69
 	.equ pciheader_len, . - pciheader
69
 	.equ pciheader_len, . - pciheader
130
 	.byte	0			/* Structure revision */
130
 	.byte	0			/* Structure revision */
131
 	.byte	0,1,2			/* PXE version: 2.1.0 */
131
 	.byte	0,1,2			/* PXE version: 2.1.0 */
132
 	.word	undiloader		/* Offset to loader routine */
132
 	.word	undiloader		/* Offset to loader routine */
133
-	.word	_data16_size		/* Stack segment size */
134
-	.word	_data16_size		/* Data segment size */
135
-	.word	_text16_size		/* Code segment size */
133
+	.word	_data16_memsz		/* Stack segment size */
134
+	.word	_data16_memsz		/* Data segment size */
135
+	.word	_text16_memsz		/* Code segment size */
136
 	.ascii	"PCIR"			/* Bus type */
136
 	.ascii	"PCIR"			/* Bus type */
137
 	.equ undiheader_len, . - undiheader
137
 	.equ undiheader_len, . - undiheader
138
 	.size undiheader, . - undiheader
138
 	.size undiheader, . - undiheader
294
 	/* Shrink ROM and update checksum */
294
 	/* Shrink ROM and update checksum */
295
 	xorw	%bx, %bx
295
 	xorw	%bx, %bx
296
 	xorw	%si, %si
296
 	xorw	%si, %si
297
-	movw	$_prefix_size_sect, %cx
297
+	movw	$_prefix_memsz_sect, %cx
298
 	movb	%cl, romheader_size
298
 	movb	%cl, romheader_size
299
 	shlw	$9, %cx
299
 	shlw	$9, %cx
300
 1:	lodsb
300
 1:	lodsb

+ 94
- 177
src/arch/i386/scripts/i386.lds Целия файл

5
  *
5
  *
6
  */
6
  */
7
 
7
 
8
-OUTPUT_FORMAT ( "elf32-i386", "elf32-i386", "elf32-i386" )
9
-OUTPUT_ARCH ( i386 )
10
-ENTRY ( _entry )
11
-
12
 SECTIONS {
8
 SECTIONS {
13
 
9
 
14
-    /* All sections in the resulting file have consecutive load
15
-     * addresses, but may have individual link addresses depending on
16
-     * the memory model being used.
10
+    /* Each section starts at a virtual address of zero.
17
      *
11
      *
18
      * We guarantee alignment of virtual addresses to any alignment
12
      * We guarantee alignment of virtual addresses to any alignment
19
      * specified by the constituent object files (e.g. via
13
      * specified by the constituent object files (e.g. via
30
      *
24
      *
31
      */
25
      */
32
 
26
 
33
-    /*
34
-     * Weak symbols that need zero values if not otherwise defined
35
-     */
36
-
37
-    . = 0;
38
-    .weak : AT ( 0 ) {
39
-	*(.weak)
40
-    }
41
-    _assert = ASSERT ( ( . == 0 ), ".weak is non-zero length" );
42
-
43
     /*
27
     /*
44
      * The prefix
28
      * The prefix
29
+     *
45
      */
30
      */
46
 
31
 
47
-    _prefix_link_addr = 0;
48
-    . = _prefix_link_addr;
49
-    _prefix = .;
50
-
51
-    .prefix : AT ( _prefix_load_offset + __prefix ) {
52
-	__prefix = .;
53
-	_entry = .;
32
+    .prefix 0x0 : AT ( _prefix_lma ) {
33
+	_prefix = .;
54
 	*(.prefix)
34
 	*(.prefix)
55
 	*(.prefix.*)
35
 	*(.prefix.*)
56
-	_eprefix_progbits = .;
36
+	_mprefix = .;
37
+    } .prefix_bss (NOLOAD) : {
38
+	_eprefix = .;
57
     }
39
     }
58
-    
59
-    _eprefix = .;
40
+    _prefix_filesz	= ABSOLUTE ( _mprefix - _prefix );
41
+    _prefix_memsz	= ABSOLUTE ( _eprefix - _prefix );
60
 
42
 
61
     /*
43
     /*
62
-     * The 16-bit sections, if present
44
+     * The 16-bit (real-mode) code section
45
+     *
63
      */
46
      */
64
 
47
 
65
-    _text16_link_addr = 0;
66
-    . = _text16_link_addr;
67
-    _text16 = .;
68
-
69
-    /* We need to allow code at the NULL address in .text16 */
70
-
71
-    .text16 : AT ( _text16_load_offset + __text16 ) {
72
-	__text16 = .;
48
+    .text16 0x0 : AT ( _text16_lma ) {
49
+	_text16 = .;
73
 	*(.text16.null)
50
 	*(.text16.null)
74
-	. += 1;			/* Prevent NULL being valid */
51
+	. += 1;				/* Prevent NULL being valid */
75
 	*(.text16)
52
 	*(.text16)
76
 	*(.text16.*)
53
 	*(.text16.*)
77
-	_etext16_progbits = .;
78
-    } = 0x9090
79
-
80
-    _etext16 = .;
81
-
82
-    _data16_link_addr = 0;
83
-    . = _data16_link_addr;
84
-    _data16 = .;
54
+	_mtext16 = .;
55
+    } .text16_bss (NOLOAD) : {
56
+	_etext16 = .;
57
+    }
58
+    _text16_filesz	= ABSOLUTE ( _mtext16 - _text16 );
59
+    _text16_memsz	= ABSOLUTE ( _etext16 - _text16 );
85
 
60
 
86
-    . += 1;			/* Prevent NULL being valid */
61
+    /*
62
+     * The 16-bit (real-mode) data section
63
+     *
64
+     */
87
 
65
 
88
-    .rodata16 : AT ( _data16_load_offset + __rodata16 ) {
89
-	__rodata16 = .;
66
+    .data16 0x0 : AT ( _data16_lma ) {
67
+	_data16 = .;
68
+	. += 1;				/* Prevent NULL being valid */
90
 	*(.rodata16)
69
 	*(.rodata16)
91
 	*(.rodata16.*)
70
 	*(.rodata16.*)
92
-    }
93
-    .data16 : AT ( _data16_load_offset + __data16 ) {
94
-	__data16 = .;
95
 	*(.data16)
71
 	*(.data16)
96
 	*(.data16.*)
72
 	*(.data16.*)
97
-	_edata16_progbits = .;
98
-    }
99
-    .bss16 : AT ( _data16_load_offset + __bss16 ) {
100
-	__bss16 = .;
101
-	_bss16 = .;
73
+	_mdata16 = .;
74
+    } .data16_bss (NOLOAD) : {
102
 	*(.bss16)
75
 	*(.bss16)
103
 	*(.bss16.*)
76
 	*(.bss16.*)
104
-	_ebss16 = .;
105
-    }
106
-    .stack16 : AT ( _data16_load_offset + __stack16 ) {
107
-	__stack16 = .;
108
 	*(.stack16)
77
 	*(.stack16)
109
 	*(.stack16.*)
78
 	*(.stack16.*)
79
+	_edata16 = .;
110
     }
80
     }
111
-
112
-    _edata16 = .;
81
+    _data16_filesz	= ABSOLUTE ( _mdata16 - _data16 );
82
+    _data16_memsz	= ABSOLUTE ( _edata16 - _data16 );
113
 
83
 
114
     /*
84
     /*
115
      * The 32-bit sections
85
      * The 32-bit sections
86
+     *
116
      */
87
      */
117
 
88
 
118
-    _textdata_link_addr = 0;
119
-    . = _textdata_link_addr;
120
-    _textdata = .;
121
-
122
-    _text = .;
123
-
124
-    . += 1;			/* Prevent NULL being valid */
125
-
126
-    .text : AT ( _textdata_load_offset + __text ) {
127
-	__text = .;
89
+    .textdata 0x0 : AT ( _textdata_lma ) {
90
+	_textdata = .;
128
 	*(.text.null_trap)
91
 	*(.text.null_trap)
92
+	. += 1;				/* Prevent NULL being valid */
129
 	*(.text)
93
 	*(.text)
130
 	*(.text.*)
94
 	*(.text.*)
131
-    } = 0x9090
132
-
133
-    _etext = .;
134
-
135
-    _data = .;
136
-
137
-    .rodata : AT ( _textdata_load_offset + __rodata ) {
138
-	__rodata = .;
139
 	*(.rodata)
95
 	*(.rodata)
140
 	*(.rodata.*)
96
 	*(.rodata.*)
141
-    }
142
-    .data : AT ( _textdata_load_offset + __data ) {
143
-	__data = .;
144
 	*(.data)
97
 	*(.data)
145
 	*(.data.*)
98
 	*(.data.*)
146
 	*(SORT(.tbl.*))		/* Various tables.  See include/tables.h */
99
 	*(SORT(.tbl.*))		/* Various tables.  See include/tables.h */
147
-	_etextdata_progbits = .;
148
-    }
149
-    .bss : AT ( _textdata_load_offset + __bss ) {
150
-	__bss = .;
151
-	_bss = .;
100
+	_mtextdata = .;
101
+    } .textdata_bss (NOLOAD) : {
152
 	*(.bss)
102
 	*(.bss)
153
 	*(.bss.*)
103
 	*(.bss.*)
154
 	*(COMMON)
104
 	*(COMMON)
155
-	_ebss = .;
156
-    }
157
-    .stack : AT ( _textdata_load_offset + __stack ) {
158
-	__stack = .;
159
 	*(.stack)
105
 	*(.stack)
160
 	*(.stack.*)
106
 	*(.stack.*)
107
+	_etextdata = .;
161
     }
108
     }
162
-
163
-    _edata = .;
164
-
165
-    _etextdata = .;
166
-
167
-    _end = .;
109
+    _textdata_filesz	= ABSOLUTE ( _mtextdata - _textdata );
110
+    _textdata_memsz	= ABSOLUTE ( _etextdata - _textdata );
168
 
111
 
169
     /*
112
     /*
170
      * Compressor information block
113
      * Compressor information block
114
+     *
171
      */
115
      */
172
 
116
 
173
-    _zinfo_link_addr = 0;
174
-    . = _zinfo_link_addr;
175
-    _zinfo = .;
176
-
177
-    .zinfo : AT ( _zinfo_load_offset + __zinfo ) {
178
-	__zinfo = .;
179
-	_entry = .;
117
+    .zinfo 0x0 : AT ( _zinfo_lma ) {
118
+	_zinfo = .;
180
 	*(.zinfo)
119
 	*(.zinfo)
181
 	*(.zinfo.*)
120
 	*(.zinfo.*)
182
-	_ezinfo_progbits = .;
121
+	_mzinfo = .;
122
+    } .zinfo_bss (NOLOAD) : {
123
+	_ezinfo = .;
183
     }
124
     }
184
-    
185
-    _ezinfo = .;
125
+    _zinfo_filesz	= ABSOLUTE ( _mzinfo - _zinfo );
126
+    _zinfo_memsz	= ABSOLUTE ( _ezinfo - _zinfo );
127
+
128
+    /*
129
+     * Weak symbols that need zero values if not otherwise defined
130
+     *
131
+     */
132
+
133
+    .weak 0x0 : {
134
+	_weak = .;
135
+	*(.weak)
136
+	_eweak = .;
137
+    }
138
+    _assert = ASSERT ( ( _weak == _eweak ), ".weak is non-zero length" );
186
 
139
 
187
     /*
140
     /*
188
      * Dispose of the comment and note sections to make the link map
141
      * Dispose of the comment and note sections to make the link map
189
      * easier to read
142
      * easier to read
143
+     *
190
      */
144
      */
191
 
145
 
192
     /DISCARD/ : {
146
     /DISCARD/ : {
195
     }
149
     }
196
 
150
 
197
     /*
151
     /*
198
-     * Load address calculations.  The slightly obscure nature of the
199
-     * calculations is because ALIGN(x) can only operate on the
200
-     * location counter.
152
+     * Load address calculations.  In older versions of ld, ALIGN()
153
+     * can operate only on the location counter, so we use that.
154
+     *
201
      */
155
      */
202
 
156
 
203
-    _max_align		    = 16;
204
-    _load_addr		    = 0;
205
-
206
-    .			    = _load_addr;
207
-
208
-    .			   -= _prefix_link_addr;
209
-    _prefix_load_offset	    = ALIGN ( _max_align );
210
-    _prefix_load_addr	    = _prefix_link_addr + _prefix_load_offset;
211
-    _prefix_size	    = _eprefix - _prefix;
212
-    _prefix_progbits_size   = _eprefix_progbits - _prefix;
213
-    .			    = _prefix_load_addr + _prefix_progbits_size;
214
-
215
-    .			   -= _text16_link_addr;
216
-    _text16_load_offset	    = ALIGN ( _max_align );
217
-    _text16_load_addr	    = _text16_link_addr + _text16_load_offset;
218
-    _text16_size	    = _etext16 - _text16;
219
-    _text16_progbits_size   = _etext16_progbits - _text16;
220
-    .			    = _text16_load_addr + _text16_progbits_size;
157
+    PROVIDE ( _max_align = 16 );
158
+    .			= 0;
221
 
159
 
222
-    .			   -= _data16_link_addr;
223
-    _data16_load_offset	    = ALIGN ( _max_align );
224
-    _data16_load_addr	    = _data16_link_addr + _data16_load_offset;
225
-    _data16_size	    = _edata16 - _data16;
226
-    _data16_progbits_size   = _edata16_progbits - _data16;
227
-    .			    = _data16_load_addr + _data16_progbits_size;
160
+    _prefix_lma		= .;
161
+    .			+= _prefix_filesz;
162
+    .			= ALIGN ( _max_align );
228
 
163
 
229
-    .			   -= _textdata_link_addr;
230
-    _textdata_load_offset   = ALIGN ( _max_align );
231
-    _textdata_load_addr	    = _textdata_link_addr + _textdata_load_offset;
232
-    _textdata_size	    = _etextdata - _textdata;
233
-    _textdata_progbits_size = _etextdata_progbits - _textdata;
234
-    .			    = _textdata_load_addr + _textdata_progbits_size;
164
+    _payload_lma	= .;
235
 
165
 
236
-    _load_size		    = . - _load_addr;
166
+    _text16_lma		= .;
167
+    .			+= _text16_filesz;
168
+    .			= ALIGN ( _max_align );
237
 
169
 
238
-    .			   -= _zinfo_link_addr;
239
-    _zinfo_load_offset	    = ALIGN ( _max_align );
240
-    _zinfo_load_addr	    = _zinfo_link_addr + _zinfo_load_offset;
241
-    _zinfo_size		    = _ezinfo - _zinfo;
242
-    _zinfo_progbits_size    = _ezinfo_progbits - _zinfo;
243
-    .			    = _zinfo_load_addr + _zinfo_progbits_size;
170
+    _data16_lma		= .;
171
+    .			+= _data16_filesz;
172
+    .			= ALIGN ( _max_align );
244
 
173
 
245
-    _payload_offset	    = _text16_load_offset;
174
+    _textdata_lma	= .;
175
+    .			+= _textdata_filesz;
176
+    .			= ALIGN ( _max_align );
246
 
177
 
247
-    /*
248
-     * Alignment checks.  ALIGN() can only operate on the location
249
-     * counter, so we set the location counter to each value we want
250
-     * to check.
251
-     */
252
-
253
-    . = _prefix_load_addr - _prefix_link_addr;
254
-    _assert = ASSERT ( ( . == ALIGN ( _max_align ) ),
255
-		       "_prefix is badly aligned" );
256
-
257
-    . = _text16_load_addr - _text16_link_addr;
258
-    _assert = ASSERT ( ( . == ALIGN ( _max_align ) ),
259
-		       "_text16 is badly aligned" );
178
+    _filesz		= .; /* Do not include zinfo block in file size */
260
 
179
 
261
-    . = _data16_load_addr - _data16_link_addr;
262
-    _assert = ASSERT ( ( . == ALIGN ( _max_align ) ),
263
-		       "_data16 is badly aligned" );
264
-
265
-    . = _textdata_load_addr - _textdata_link_addr;
266
-    _assert = ASSERT ( ( . == ALIGN ( _max_align ) ),
267
-		       "_text is badly aligned" );
180
+    _zinfo_lma		= .;
181
+    .			+= _zinfo_filesz;
182
+    .			= ALIGN ( _max_align );
268
 
183
 
269
     /*
184
     /*
270
      * Values calculated to save code from doing it
185
      * Values calculated to save code from doing it
186
+     *
271
      */
187
      */
272
-    _prefix_size_pgh	= ( ( _prefix_size + 15 ) / 16 );
273
-    _prefix_size_sect	= ( ( _prefix_size + 511 ) / 512 );
274
-    _text16_size_pgh	= ( ( _text16_size + 15 ) / 16 );
275
-    _data16_size_pgh	= ( ( _data16_size + 15 ) / 16 );
188
+    _prefix_memsz_pgh	= ( ( _prefix_memsz + 15 ) / 16 );
189
+    _prefix_memsz_sect	= ( ( _prefix_memsz + 511 ) / 512 );
190
+    _text16_memsz_pgh	= ( ( _text16_memsz + 15 ) / 16 );
191
+    _data16_memsz_pgh	= ( ( _data16_memsz + 15 ) / 16 );
276
 
192
 
277
     /*
193
     /*
278
-     * Load sizes in paragraphs and sectors.  Note that wherever the
279
-     * _load_size variables are used, there must be a corresponding
194
+     * File size in paragraphs and sectors.  Note that wherever the
195
+     * _filesz variables are used, there must be a corresponding
280
      * .zinfo.fixup section.
196
      * .zinfo.fixup section.
197
+     *
281
      */
198
      */
282
-    _load_size_pgh	= ( ( _load_size + 15 ) / 16 );
283
-    _load_size_sect	= ( ( _load_size + 511 ) / 512 );
199
+    _filesz_pgh		= ( ( _filesz + 15 ) / 16 );
200
+    _filesz_sect	= ( ( _filesz + 511 ) / 512 );
284
 }
201
 }

Loading…
Отказ
Запис