OSDN Git Service

Changes from Pauli to enable moving strings into the text area (if possible).
authorDavid McCullough <davidm@snapgear.com>
Sun, 17 Feb 2002 23:26:11 +0000 (23:26 +0000)
committerDavid McCullough <davidm@snapgear.com>
Sun, 17 Feb 2002 23:26:11 +0000 (23:26 +0000)
elf2flt.ld
elf2flt.movdat.ld [new file with mode: 0644]
ld-elf2flt

index 0b5e3f3..7835687 100644 (file)
@@ -2,60 +2,59 @@
 ENTRY (_start)
 
 MEMORY {
-        flatmem : ORIGIN = 0x0, LENGTH = 0x100000
+       flatmem : ORIGIN = 0x0, LENGTH = 0x100000
        junk    : ORIGIN = 0x0, LENGTH = 0x100000
 }
 
 SECTIONS {
-        .text 0 : {
+       .text 0 : {
                . = . + 4;
-                . = ALIGN(0x4) ;
-                _stext = . ;
-                *(.text)
-                *(.text.*)
-                *(.gnu.warning)
-                *(.stub)
-                *(.gnu.linkonce.t*)
-                *(.glue_7t)
+               . = ALIGN(0x4) ;
+               _stext = . ;
+               *(.text)
+               *(.text.*)
+               *(.gnu.warning)
+               *(.stub)
+               *(.gnu.linkonce.t*)
+               *(.glue_7t)
                *(.glue_7)
-                *(.init)
+               *(.init)
                *(.fini)
 
-                /* This is special code area at the end of the normal
-                   text section.  It contains a small lookup table at
-                   the start followed by the code pointed to by entries
-                   in the lookup table.  */
-                . = ALIGN (4) ;
-                PROVIDE(__ctbp = .);
-                *(.call_table_data)
-                *(.call_table_text)
+               /* This is special code area at the end of the normal
+                  text section.  It contains a small lookup table at
+                  the start followed by the code pointed to by entries
+                  in the lookup table.  */
+               . = ALIGN (4) ;
+               PROVIDE(__ctbp = .);
+               *(.call_table_data)
+               *(.call_table_text)
 
-                . = ALIGN(0x10) ;
-                _etext = . ;
-        } > flatmem
-        .data : {
-                . = ALIGN(0x4) ;
-                _sdata = . ;
+               . = ALIGN(0x10) ;
+               _etext = . ;
+       } > flatmem
+       .data : {
+               . = ALIGN(0x4) ;
+               _sdata = . ;
                __data_start = . ;
                data_start = . ;
                *(.got.plt)
                *(.got)
                LONG(-1)
-                *(.rodata)
-                *(.rodata1)
-                *(.rodata.*)
-                *(.gnu.linkonce.r*)
-                *(.rodata1)
-                *(.data)
-                *(.data1)
-                *(.data.*)
-                *(.gnu.linkonce.d*)
-                *(.data1)
-                *(.eh_frame)
-                *(.gcc_except_table)
-                *(.sdata) 
-                *(.sdata.*)
-                *(.gnu.linkonce.s.*)
+               *(.rodata)
+               *(.rodata1)
+               *(.rodata.*)
+               *(.gnu.linkonce.r*)
+               *(.data)
+               *(.data1)
+               *(.data.*)
+               *(.gnu.linkonce.d*)
+               *(.data1)
+               *(.eh_frame)
+               *(.gcc_except_table)
+               *(.sdata) 
+               *(.sdata.*)
+               *(.gnu.linkonce.s.*)
                *(__libc_atexit)
                *(__libc_subinit)
                *(__libc_subfreeres)
@@ -67,26 +66,26 @@ SECTIONS {
                *(.dtors.*)
                *(.dtors)
                LONG(0)
-                . = ALIGN(0x10) ;
-                _edata = . ;
-        } > flatmem
-        .bss : {
-                . = ALIGN(0x4) ;
-                _sbss = ALIGN(0x4) ;
+               . = ALIGN(0x10) ;
+               _edata = . ;
+       } > flatmem
+       .bss : {
+               . = ALIGN(0x4) ;
+               _sbss = ALIGN(0x4) ;
                __bss_start = . ;
-                *(.dynsbss)
-                *(.sbss)
-                *(.sbss.*)
-                *(.scommon)
-                *(.dynbss)
-                *(.bss)
-                *(.bss.*)
-                *(COMMON)
-                . = ALIGN(0x4) ;
-                _ebss = . ;
+               *(.dynsbss)
+               *(.sbss)
+               *(.sbss.*)
+               *(.scommon)
+               *(.dynbss)
+               *(.bss)
+               *(.bss.*)
+               *(COMMON)
+               . = ALIGN(0x4) ;
+               _ebss = . ;
                _end = . ;
                end = . ;
-        } > flatmem
+       } > flatmem
 
        .junk : {
                *(.rel*)
diff --git a/elf2flt.movdat.ld b/elf2flt.movdat.ld
new file mode 100644 (file)
index 0000000..6fbf8de
--- /dev/null
@@ -0,0 +1,95 @@
+
+ENTRY (_start)
+
+MEMORY {
+       flatmem : ORIGIN = 0x0, LENGTH = 0x100000
+       junk    : ORIGIN = 0x0, LENGTH = 0x100000
+}
+
+SECTIONS {
+       .text 0 : {
+               . = . + 4;
+               . = ALIGN(0x4) ;
+               _stext = . ;
+               *(.text)
+               *(.text.*)
+               *(.gnu.warning)
+               *(.stub)
+               *(.gnu.linkonce.t*)
+               *(.glue_7t)
+               *(.glue_7)
+               *(.init)
+               *(.fini)
+
+               *(.rodata)
+               *(.rodata1)
+               *(.rodata.*)
+
+               /* This is special code area at the end of the normal
+                  text section.  It contains a small lookup table at
+                  the start followed by the code pointed to by entries
+                  in the lookup table.  */
+               . = ALIGN (4) ;
+               PROVIDE(__ctbp = .);
+               *(.call_table_data)
+               *(.call_table_text)
+
+               . = ALIGN(0x10) ;
+               _etext = . ;
+       } > flatmem
+       .data : {
+               . = ALIGN(0x4) ;
+               _sdata = . ;
+               __data_start = . ;
+               data_start = . ;
+               *(.got.plt)
+               *(.got)
+               LONG(-1)
+               *(.gnu.linkonce.r*)
+               *(.data)
+               *(.data1)
+               *(.data.*)
+               *(.gnu.linkonce.d*)
+               *(.data1)
+               *(.eh_frame)
+               *(.gcc_except_table)
+               *(.sdata) 
+               *(.sdata.*)
+               *(.gnu.linkonce.s.*)
+               *(__libc_atexit)
+               *(__libc_subinit)
+               *(__libc_subfreeres)
+               *(.note.ABI-tag)
+               . = ALIGN(4) ;
+               *(.ctors.*)
+               *(.ctors)
+               LONG(0)
+               *(.dtors.*)
+               *(.dtors)
+               LONG(0)
+               . = ALIGN(0x10) ;
+               _edata = . ;
+       } > flatmem
+       .bss : {
+               . = ALIGN(0x4) ;
+               _sbss = ALIGN(0x4) ;
+               __bss_start = . ;
+               *(.dynsbss)
+               *(.sbss)
+               *(.sbss.*)
+               *(.scommon)
+               *(.dynbss)
+               *(.bss)
+               *(.bss.*)
+               *(COMMON)
+               . = ALIGN(0x4) ;
+               _ebss = . ;
+               _end = . ;
+               end = . ;
+       } > flatmem
+
+       .junk : {
+               *(.rel*)
+               *(.rela*)
+       } > junk
+}
index a90caf7..b2e410e 100755 (executable)
@@ -30,6 +30,7 @@ then
        SDIRS=
        LDSCRIPT=
        FINAL="yes"
+       MOVDAT=
 
        while [ $# -ne 0 ]
        do
@@ -38,6 +39,9 @@ then
                -elf2flt) ;;                           # we already know this
                -elf2flt*)FLTFLAGS="`expr \"$1\" : '-elf2flt=\(.*\)'` $FLTFLAGS";; 
 
+               -move-rodata)
+                         MOVDAT="y";;                 # Put rodata in ROM if possible
+
                -o)       shift; OFILE="$1";;          # the final outfile
                -o*)      OFILE="`expr \"$1\" : '-o\(.*\)'`";;
 
@@ -65,6 +69,17 @@ then
 
        if [ "$FINAL" = "yes" ]
        then
+               if [ "$MOVDAT" ]
+               then
+                       $LINKER -r -d -o $OFILE.elf2flt $ARG1  || exit $?
+                       if [ "`m68k-elf-objdump -h $OFILE.elf2flt | \
+                                       egrep -A1 '[.]rodata' | grep RELOC`" ]
+                       then
+                               echo "warning: .rodata section contains relocations"
+                       else
+                               [ -z "$LDSCRIPT" ] && LDSCRIPT="elf2flt.movdat.ld"
+                       fi
+               fi
                [ -z "$LDSCRIPT" ] && LDSCRIPT="elf2flt.ld"
                $LINKER -r -d -o $OFILE.elf2flt $ARG1                        || exit $?
                $LINKER $SDIRS -T $LDSCRIPT -Ur -o $OFILE.elf $OFILE.elf2flt || exit $?