Browse Source

[librm] Use garbage-collectable section names

Allow unused sections of librm.o to be removed via --gc-sections.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 9 years ago
parent
commit
b1436e0b83
1 changed files with 26 additions and 22 deletions
  1. 26
    22
      src/arch/x86/transitions/librm.S

+ 26
- 22
src/arch/x86/transitions/librm.S View File

37
  * "non absolute segment" error.  This is most probably a bug in gas.
37
  * "non absolute segment" error.  This is most probably a bug in gas.
38
  ****************************************************************************
38
  ****************************************************************************
39
  */
39
  */
40
-	.section ".data16", "aw", @progbits
40
+	.section ".data16.gdt", "aw", @progbits
41
 	.align 16
41
 	.align 16
42
 gdt:
42
 gdt:
43
 gdtr:		/* The first GDT entry is unused, the GDTR can fit here. */
43
 gdtr:		/* The first GDT entry is unused, the GDTR can fit here. */
89
  *   %edi : Physical base of protected-mode code (virt_offset)
89
  *   %edi : Physical base of protected-mode code (virt_offset)
90
  ****************************************************************************
90
  ****************************************************************************
91
  */
91
  */
92
-	.section ".text16", "ax", @progbits
92
+	.section ".text16.init_librm", "ax", @progbits
93
 	.code16
93
 	.code16
94
 	.globl init_librm
94
 	.globl init_librm
95
 init_librm:
95
 init_librm:
141
 	popl	%eax
141
 	popl	%eax
142
 	lret
142
 	lret
143
 
143
 
144
-	.section ".text16", "ax", @progbits
144
+	.section ".text16.set_seg_base", "ax", @progbits
145
 	.code16
145
 	.code16
146
 set_seg_base:
146
 set_seg_base:
147
 1:	movw	%ax, 2(%bx)
147
 1:	movw	%ax, 2(%bx)
167
  *
167
  *
168
  ****************************************************************************
168
  ****************************************************************************
169
  */
169
  */
170
-	.section ".text16", "ax", @progbits
170
+	.section ".text16.real_to_prot", "ax", @progbits
171
 	.code16
171
 	.code16
172
 real_to_prot:
172
 real_to_prot:
173
 	/* Enable A20 line */
173
 	/* Enable A20 line */
219
 	orb	$CR0_PE, %al
219
 	orb	$CR0_PE, %al
220
 	movl	%eax, %cr0
220
 	movl	%eax, %cr0
221
 	data32 ljmp	$VIRTUAL_CS, $r2p_pmode
221
 	data32 ljmp	$VIRTUAL_CS, $r2p_pmode
222
-	.section ".text", "ax", @progbits
222
+	.section ".text.real_to_prot", "ax", @progbits
223
 	.code32
223
 	.code32
224
 r2p_pmode:
224
 r2p_pmode:
225
 	/* Set up protected-mode data segments and stack pointer */
225
 	/* Set up protected-mode data segments and stack pointer */
272
  *
272
  *
273
  ****************************************************************************
273
  ****************************************************************************
274
  */
274
  */
275
-	.section ".text", "ax", @progbits
275
+	.section ".text.prot_to_real", "ax", @progbits
276
 	.code32
276
 	.code32
277
 prot_to_real:
277
 prot_to_real:
278
 	/* Copy real-mode global descriptor table register to RM code segment */
278
 	/* Copy real-mode global descriptor table register to RM code segment */
311
 	movw	%ax, %gs
311
 	movw	%ax, %gs
312
 	movw	%ax, %ss
312
 	movw	%ax, %ss
313
 	ljmp	$REAL_CS, $p2r_rmode
313
 	ljmp	$REAL_CS, $p2r_rmode
314
-	.section ".text16", "ax", @progbits
314
+	.section ".text16.prot_to_real", "ax", @progbits
315
 	.code16
315
 	.code16
316
 p2r_rmode:
316
 p2r_rmode:
317
 	/* Load real-mode GDT */
317
 	/* Load real-mode GDT */
347
 	.globl rm_cs
347
 	.globl rm_cs
348
 	.equ	rm_cs, ( p2r_ljmp_rm_cs + 3 )
348
 	.equ	rm_cs, ( p2r_ljmp_rm_cs + 3 )
349
 
349
 
350
-	.section ".text16.data", "aw", @progbits
350
+	.section ".text16.data.rm_ds", "aw", @progbits
351
 	.globl rm_ds
351
 	.globl rm_ds
352
 rm_ds:	.word 0
352
 rm_ds:	.word 0
353
 
353
 
354
 	/* Real-mode global and interrupt descriptor table registers */
354
 	/* Real-mode global and interrupt descriptor table registers */
355
-	.section ".text16.data", "aw", @progbits
355
+	.section ".text16.data.rm_gdtr", "aw", @progbits
356
 rm_gdtr:
356
 rm_gdtr:
357
 	.word 0 /* Limit */
357
 	.word 0 /* Limit */
358
 	.long 0 /* Base */
358
 	.long 0 /* Base */
398
 #define PC_OFFSET_FUNCTION ( PC_OFFSET_RETADDR + 4 )
398
 #define PC_OFFSET_FUNCTION ( PC_OFFSET_RETADDR + 4 )
399
 #define PC_OFFSET_END ( PC_OFFSET_FUNCTION + 4 )
399
 #define PC_OFFSET_END ( PC_OFFSET_FUNCTION + 4 )
400
 
400
 
401
-	.section ".text16", "ax", @progbits
401
+	.section ".text16.prot_call", "ax", @progbits
402
 	.code16
402
 	.code16
403
 	.globl prot_call
403
 	.globl prot_call
404
 prot_call:
404
 prot_call:
423
 	movl	$PC_OFFSET_END, %ecx
423
 	movl	$PC_OFFSET_END, %ecx
424
 	pushl	$pc_pmode
424
 	pushl	$pc_pmode
425
 	jmp	real_to_prot
425
 	jmp	real_to_prot
426
-	.section ".text", "ax", @progbits
426
+	.section ".text.prot_call", "ax", @progbits
427
 	.code32
427
 	.code32
428
 pc_pmode:
428
 pc_pmode:
429
 	/* Call function */
429
 	/* Call function */
437
 	movl	%esp, %esi
437
 	movl	%esp, %esi
438
 	pushl	$pc_rmode
438
 	pushl	$pc_rmode
439
 	jmp	prot_to_real
439
 	jmp	prot_to_real
440
-	.section ".text16", "ax", @progbits
440
+	.section ".text16.prot_call", "ax", @progbits
441
 	.code16
441
 	.code16
442
 pc_rmode:
442
 pc_rmode:
443
 	/* Restore registers and flags and return */
443
 	/* Restore registers and flags and return */
484
 #define RC_OFFSET_FUNCTION ( RC_OFFSET_RETADDR + 4 )
484
 #define RC_OFFSET_FUNCTION ( RC_OFFSET_RETADDR + 4 )
485
 #define RC_OFFSET_END ( RC_OFFSET_FUNCTION + 4 )
485
 #define RC_OFFSET_END ( RC_OFFSET_FUNCTION + 4 )
486
 
486
 
487
-	.section ".text", "ax", @progbits
487
+	.section ".text.real_call", "ax", @progbits
488
 	.code32
488
 	.code32
489
 	.globl real_call
489
 	.globl real_call
490
 real_call:
490
 real_call:
497
 	pushl	$rc_rmode
497
 	pushl	$rc_rmode
498
 	movl	$rm_default_gdtr_idtr, %esi
498
 	movl	$rm_default_gdtr_idtr, %esi
499
 	jmp	prot_to_real
499
 	jmp	prot_to_real
500
-	.section ".text16", "ax", @progbits
500
+	.section ".text16.real_call", "ax", @progbits
501
 	.code16
501
 	.code16
502
 rc_rmode:
502
 rc_rmode:
503
 	/* Call real-mode function */
503
 	/* Call real-mode function */
513
 	movl	$RC_OFFSET_RETADDR, %ecx
513
 	movl	$RC_OFFSET_RETADDR, %ecx
514
 	pushl	$rc_pmode
514
 	pushl	$rc_pmode
515
 	jmp	real_to_prot
515
 	jmp	real_to_prot
516
-	.section ".text", "ax", @progbits
516
+	.section ".text.real_call", "ax", @progbits
517
 	.code32
517
 	.code32
518
 rc_pmode:
518
 rc_pmode:
519
 	/* Restore registers and return */
519
 	/* Restore registers and return */
524
 	/* Function vector, used because "call xx(%sp)" is not a valid
524
 	/* Function vector, used because "call xx(%sp)" is not a valid
525
 	 * 16-bit expression.
525
 	 * 16-bit expression.
526
 	 */
526
 	 */
527
-	.section ".data16", "aw", @progbits
527
+	.section ".bss16.rc_function", "aw", @nobits
528
 rc_function:	.word 0, 0
528
 rc_function:	.word 0, 0
529
 
529
 
530
 	/* Default real-mode global and interrupt descriptor table registers */
530
 	/* Default real-mode global and interrupt descriptor table registers */
531
-	.section ".data", "aw", @progbits
531
+	.section ".data.rm_default_gdtr_idtr", "aw", @progbits
532
 rm_default_gdtr_idtr:
532
 rm_default_gdtr_idtr:
533
 	.word 0		/* Global descriptor table limit */
533
 	.word 0		/* Global descriptor table limit */
534
 	.long 0		/* Global descriptor table base */
534
 	.long 0		/* Global descriptor table base */
542
  *
542
  *
543
  ****************************************************************************
543
  ****************************************************************************
544
  */
544
  */
545
-	.section ".text16", "ax", @progbits
545
+	.section ".text16.flatten_real_mode", "ax", @progbits
546
 	.code16
546
 	.code16
547
 	.globl flatten_real_mode
547
 	.globl flatten_real_mode
548
 flatten_real_mode:
548
 flatten_real_mode:
559
 	/* Return */
559
 	/* Return */
560
 	ret
560
 	ret
561
 
561
 
562
-	.section ".text", "ax", @progbits
562
+	.section ".text.flatten_dummy", "ax", @progbits
563
 	.code32
563
 	.code32
564
 flatten_dummy:
564
 flatten_dummy:
565
 	ret
565
 	ret
638
  * to us.
638
  * to us.
639
  ****************************************************************************
639
  ****************************************************************************
640
  */
640
  */
641
-	.section ".data", "aw", @progbits
641
+	.section ".bss.rm_sp", "aw", @nobits
642
 	.globl rm_sp
642
 	.globl rm_sp
643
 rm_sp:	.word 0
643
 rm_sp:	.word 0
644
+
645
+	.section ".bss.rm_ss", "aw", @nobits
644
 	.globl rm_ss
646
 	.globl rm_ss
645
 rm_ss:	.word 0
647
 rm_ss:	.word 0
648
+
649
+	.section ".data.pm_esp", "aw", @progbits
646
 pm_esp:	.long _estack
650
 pm_esp:	.long _estack
647
 
651
 
648
 /****************************************************************************
652
 /****************************************************************************
654
  ****************************************************************************
658
  ****************************************************************************
655
  */
659
  */
656
 	/* Internal copies, created by init_librm (which runs in real mode) */
660
 	/* Internal copies, created by init_librm (which runs in real mode) */
657
-	.section ".data16", "aw", @progbits
661
+	.section ".bss16.rm_virt_offset", "aw", @nobits
658
 rm_virt_offset:	.long 0
662
 rm_virt_offset:	.long 0
659
 rm_text16:	.long 0
663
 rm_text16:	.long 0
660
 rm_data16:	.long 0
664
 rm_data16:	.long 0
661
 
665
 
662
 	/* Externally-visible copies, created by real_to_prot */
666
 	/* Externally-visible copies, created by real_to_prot */
663
-	.section ".data", "aw", @progbits
667
+	.section ".bss.virt_offset", "aw", @nobits
664
 	.globl virt_offset
668
 	.globl virt_offset
665
 virt_offset:	.long 0	
669
 virt_offset:	.long 0	
666
 	.globl text16
670
 	.globl text16

Loading…
Cancel
Save