Sat Jan 26 16:00:04 2013 UTC ()
Add proper padding to text section for elf2aout conversion.

The data and bss sections are 8 byte aligned on m68k ELF format,
but a.out header doesn't have section addresses and only
contains size values, so we have to pad size of text section
to make data section get aligned even after elf2aout.

Note elf2aout merges ELF data section into a.out text section
if binary is OMAGIC (i.e. text is writable too) so only
BSS section address was affected (and was almost harmless).


(tsutsui)
diff -r1.4 -r1.5 src/sys/arch/luna68k/stand/boot/boot.ldscript

cvs diff -r1.4 -r1.5 src/sys/arch/luna68k/stand/boot/boot.ldscript (switch to unified diff)

--- src/sys/arch/luna68k/stand/boot/boot.ldscript 2013/01/20 02:35:13 1.4
+++ src/sys/arch/luna68k/stand/boot/boot.ldscript 2013/01/26 16:00:04 1.5
@@ -1,46 +1,50 @@ @@ -1,46 +1,50 @@
1/* $NetBSD: boot.ldscript,v 1.4 2013/01/20 02:35:13 tsutsui Exp $ */ 1/* $NetBSD: boot.ldscript,v 1.5 2013/01/26 16:00:04 tsutsui Exp $ */
2 2
3OUTPUT_FORMAT("elf32-m68k") 3OUTPUT_FORMAT("elf32-m68k")
4OUTPUT_ARCH(m68k) 4OUTPUT_ARCH(m68k)
5ENTRY(start) 5ENTRY(start)
6SECTIONS 6SECTIONS
7{ 7{
8 /* Read-only sections, merged into text segment: */ 8 /* Read-only sections, merged into text segment: */
9 .text : 9 .text :
10 { 10 {
11 *(.text) 11 *(.text)
12 *(.text.*) 12 *(.text.*)
13 *(.rodata) *(.rodata.*) 13 *(.rodata) *(.rodata.*)
14 . = ALIGN(4); 14 /* The data and bss sections are 8 byte aligned on ELF format,
 15 but a.out header doesn't have section addresses and only
 16 contains size values, so we have to pad size of text section
 17 to make data section get aligned even after elf2aout. */
 18 . = ALIGN(8);
15 } =0 19 } =0
16 PROVIDE (__etext = .); 20 PROVIDE (__etext = .);
17 PROVIDE (_etext = .); 21 PROVIDE (_etext = .);
18 PROVIDE (etext = .); 22 PROVIDE (etext = .);
19 .data : 23 .data :
20 { 24 {
21 __data_start = . ; 25 __data_start = . ;
22 *(.data) 26 *(.data)
23 *(.data.*) 27 *(.data.*)
24 *(.sdata) 28 *(.sdata)
25 *(.sdata.*) 29 *(.sdata.*)
26 } 30 }
27 _edata = .; 31 _edata = .;
28 PROVIDE (edata = .); 32 PROVIDE (edata = .);
29 __bss_start = .; 33 __bss_start = .;
30 __bss_start__ = .; 34 __bss_start__ = .;
31 .bss : 35 .bss :
32 { 36 {
33 *(.dynbss) 37 *(.dynbss)
34 *(.bss) 38 *(.bss)
35 *(.bss.*) 39 *(.bss.*)
36 *(COMMON) 40 *(COMMON)
37 /* Align here to ensure that the .bss section occupies space up to 41 /* Align here to ensure that the .bss section occupies space up to
38 _end. Align after .bss to ensure correct alignment even if the 42 _end. Align after .bss to ensure correct alignment even if the
39 .bss section disappears because there are no input sections. */ 43 .bss section disappears because there are no input sections. */
40/* . = ALIGN(32 / 8); */ 44/* . = ALIGN(32 / 8); */
41 } 45 }
42/* . = ALIGN(32 / 8);*/ 46/* . = ALIGN(32 / 8);*/
43 _end = .; 47 _end = .;
44 _bss_end__ = . ; __bss_end__ = . ; __end__ = . ; 48 _bss_end__ = . ; __bss_end__ = . ; __end__ = . ;
45 PROVIDE (end = .); 49 PROVIDE (end = .);
46} 50}