This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: Tweaks to ARM SymbianOS configuration


This patch makes several changes for ARM SymbianOS:

1) Paul Brook accidentally changed the SymbianOS configuration to use
   RELA, but like other ARM targets, SymbianOS uses REL.

2) SymbianOS needs several magic symbols defined to mark the
   beginnings and ends of various segments.  There are GNU
   equivalents, but the SymbianOS runtime has to work with multiple
   toolchains, so we need to provide the same names they're using
   elsewhere.

3) SymbianOS wants .plt at the end of the text sgement; their kernel
   depends on this.

4) On SymbianOS, .init_array and friends can be read-only; there are
   no relocations actually applied at runtime, due to the SymbianOS
   DLL model.

OK to apply?

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com

2005-01-23  Mark Mitchell  <mark@codesourcery.com>

	* elf32-arm.c (elf_backend_default_use_rela_p): Define to zero for
	SymbianOS. 

005-01-23  Mark Mitchell  <mark@codesourcery.com>

	* emulparams/armsymbian.sh (OTHER_READONLY_SECTIONS): Define, so
	as to include .ARM.exidx$${Base,Limit}.
	* ld/scripttempl/armbpabi.sc: Move .plt to end of text segment.
	Define IMAGE$$ER_RO$${Base,Limit} and SHT$$INIT_ARRAY$${Base,Limit}.
	Put .init_array, .fini_array, etc. into the read-only data
	segment. 

Index: bfd/elf32-arm.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-arm.c,v
retrieving revision 1.16
diff -c -5 -p -r1.16 elf32-arm.c
*** bfd/elf32-arm.c	11 Jan 2005 09:32:46 -0000	1.16
--- bfd/elf32-arm.c	23 Jan 2005 18:54:32 -0000
*************** elf32_arm_symbian_modify_segment_map (bf
*** 5915,5924 ****
  #undef elf_backend_may_use_rel_p
  #define elf_backend_may_use_rel_p   1
  #undef elf_backend_may_use_rela_p
  #define elf_backend_may_use_rela_p  0
  #undef elf_backend_default_use_rela_p
! #define elf_backend_default_use_rela_p 1
  #undef elf_backend_rela_normal
  #define elf_backend_rela_normal     0
  
  #include "elf32-target.h"
--- 5915,5924 ----
  #undef elf_backend_may_use_rel_p
  #define elf_backend_may_use_rel_p   1
  #undef elf_backend_may_use_rela_p
  #define elf_backend_may_use_rela_p  0
  #undef elf_backend_default_use_rela_p
! #define elf_backend_default_use_rela_p 0
  #undef elf_backend_rela_normal
  #define elf_backend_rela_normal     0
  
  #include "elf32-target.h"
Index: ld/emulparams/armsymbian.sh
===================================================================
RCS file: /cvs/src/src/ld/emulparams/armsymbian.sh,v
retrieving revision 1.5
diff -c -5 -p -r1.5 armsymbian.sh
*** ld/emulparams/armsymbian.sh	26 Oct 2004 18:41:52 -0000	1.5
--- ld/emulparams/armsymbian.sh	23 Jan 2005 18:55:05 -0000
*************** LITTLE_OUTPUT_FORMAT="$OUTPUT_FORMAT"
*** 7,15 ****
--- 7,25 ----
  TARGET1_IS_REL=1
  TARGET2_TYPE=abs
  # On BPABI systems, program headers should not be mapped.
  EMBEDDED=yes
  
+ # As for armelf.sh, but add the SymbianOS-specific
+ # .ARM.exidx$${Base,Limit} symbols.
+ OTHER_READONLY_SECTIONS="
+   .ARM.extab ${RELOCATING-0} : { *(.ARM.extab${RELOCATING+* .gnu.linkonce.armextab.*}) }
+   ${RELOCATING+ .ARM.exidx\$\$Base = . ; }
+   ${RELOCATING+ __exidx_start = .; }
+   .ARM.exidx ${RELOCATING-0} : { *(.ARM.exidx${RELOCATING+* .gnu.linkonce.armexidx.*}) }
+   ${RELOCATING+ __exidx_end = .; }
+   ${RELOCATING+ .ARM.exidx\$\$Limit = . ; }"
+ 
  # This value should match ELF_MAXPAGESIZE in BFD.  Otherwise, elf.c
  # will not place read-write sections in a separate ELF segment from
  # the read-only sections.
  MAXPAGESIZE=0x8000
Index: ld/scripttempl/armbpabi.sc
===================================================================
RCS file: /cvs/src/src/ld/scripttempl/armbpabi.sc,v
retrieving revision 1.3
diff -c -5 -p -r1.3 armbpabi.sc
*** ld/scripttempl/armbpabi.sc	26 Oct 2004 18:41:52 -0000	1.3
--- ld/scripttempl/armbpabi.sc	23 Jan 2005 18:55:20 -0000
*************** ${RELOCATING- /* For some reason, the So
*** 135,145 ****
    bug.  But for now assigning the zero vmas works.  */}
  
  SECTIONS
  {
    /* Read-only sections, merged into text segment: */
!   ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+PROVIDE (__executable_start = ${TEXT_START_ADDR}); . = ${TEXT_BASE_ADDRESS};}}}
    ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_BASE_ADDRESS};}}
    ${CREATE_PIE+${RELOCATING+. = ${SHLIB_BASE_ADDRESS};}}
    ${INITIAL_READONLY_SECTIONS}
  
  EOF
--- 135,148 ----
    bug.  But for now assigning the zero vmas works.  */}
  
  SECTIONS
  {
    /* Read-only sections, merged into text segment: */
!   ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+PROVIDE (__executable_start = ${TEXT_START_ADDR});}}}
!   /* SymbianOS uses this symbol.  */
!   ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+PROVIDE (Image\$\$ER_RO\$\$Base = ${TEXT_START_ADDR});}}} 
!   ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+ . = ${TEXT_BASE_ADDRESS};}}}
    ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_BASE_ADDRESS};}}
    ${CREATE_PIE+${RELOCATING+. = ${SHLIB_BASE_ADDRESS};}}
    ${INITIAL_READONLY_SECTIONS}
  
  EOF
*************** cat <<EOF
*** 148,159 ****
    { 
      ${RELOCATING+${INIT_START}}
      KEEP (*(.init))
      ${RELOCATING+${INIT_END}}
    } =${NOP-0}
- 
-   ${DATA_PLT-${BSS_PLT-${PLT}}}
    .text         ${RELOCATING-0} :
    {
      ${RELOCATING+${TEXT_START_SYMBOLS}}
      *(.text .stub${RELOCATING+ .text.* .gnu.linkonce.t.*})
      KEEP (*(.text.*personality*))
--- 151,160 ----
*************** cat <<EOF
*** 165,199 ****
    {
      ${RELOCATING+${FINI_START}}
      KEEP (*(.fini))
      ${RELOCATING+${FINI_END}}
    } =${NOP-0}
    ${RELOCATING+PROVIDE (__etext = .);}
    ${RELOCATING+PROVIDE (_etext = .);}
    ${RELOCATING+PROVIDE (etext = .);}
    ${WRITABLE_RODATA-${RODATA}}
    .rodata1      ${RELOCATING-0} : { *(.rodata1) }
    ${CREATE_SHLIB-${SDATA2}}
    ${CREATE_SHLIB-${SBSS2}}
-   ${OTHER_READONLY_SECTIONS}
-   .eh_frame_hdr : { *(.eh_frame_hdr) }
-   .eh_frame     ${RELOCATING-0} : ONLY_IF_RO { KEEP (*(.eh_frame)) }
-   .gcc_except_table ${RELOCATING-0} : ONLY_IF_RO { KEEP (*(.gcc_except_table)) *(.gcc_except_table.*) }
- 
-   /* Adjust the address for the data segment.  We want to adjust up to
-      the same address within the page on the next page up.  */
-   ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+. = ${DATA_ADDR};}}}
-   ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_DATA_ADDR};}}
-   ${CREATE_PIE+${RELOCATING+. = ${SHLIB_DATA_ADDR};}}
- 
-   /* Exception handling  */
-   .eh_frame     ${RELOCATING-0} : ONLY_IF_RW { KEEP (*(.eh_frame)) }
-   .gcc_except_table ${RELOCATING-0} : ONLY_IF_RW { KEEP (*(.gcc_except_table)) *(.gcc_except_table.*) }
  
!   /* Thread Local Storage sections  */
!   .tdata	${RELOCATING-0} : { *(.tdata${RELOCATING+ .tdata.* .gnu.linkonce.td.*}) }
!   .tbss		${RELOCATING-0} : { *(.tbss${RELOCATING+ .tbss.* .gnu.linkonce.tb.*})${RELOCATING+ *(.tcommon)} }
  
    /* Ensure the __preinit_array_start label is properly aligned.  We
       could instead move the label definition inside the section, but
       the linker would then create the section even if it turns out to
       be empty, which isn't pretty.  */
--- 166,191 ----
    {
      ${RELOCATING+${FINI_START}}
      KEEP (*(.fini))
      ${RELOCATING+${FINI_END}}
    } =${NOP-0}
+   /* The SymbianOS kernel requires that the PLT go at the end of the
+      text section.  */
+   ${DATA_PLT-${BSS_PLT-${PLT}}}
    ${RELOCATING+PROVIDE (__etext = .);}
    ${RELOCATING+PROVIDE (_etext = .);}
    ${RELOCATING+PROVIDE (etext = .);}
+   /* SymbianOS uses this symbol.  */
+   ${RELOCATING+PROVIDE (Image\$\$ER_RO\$\$Limit = .);}
    ${WRITABLE_RODATA-${RODATA}}
    .rodata1      ${RELOCATING-0} : { *(.rodata1) }
    ${CREATE_SHLIB-${SDATA2}}
    ${CREATE_SHLIB-${SBSS2}}
  
!   /* On SymbianOS, put  .init_array and friends in the read-only
!      segment; there is no runtime relocation applied to these
!      arrays.  */
  
    /* Ensure the __preinit_array_start label is properly aligned.  We
       could instead move the label definition inside the section, but
       the linker would then create the section even if it turns out to
       be empty, which isn't pretty.  */
*************** cat <<EOF
*** 201,217 ****
--- 193,232 ----
    ${RELOCATING+${CREATE_SHLIB-PROVIDE (__preinit_array_start = .);}}
    .preinit_array   ${RELOCATING-0} : { *(.preinit_array) }
    ${RELOCATING+${CREATE_SHLIB-PROVIDE (__preinit_array_end = .);}}
  
    ${RELOCATING+${CREATE_SHLIB-PROVIDE (__init_array_start = .);}}
+   /* SymbianOS uses this symbol.  */
+   ${RELOCATING+${CREATE_SHLIB-PROVIDE (SHT\$\$INIT_ARRAY\$\$Base = .);}}
    .init_array   ${RELOCATING-0} : { *(.init_array) }
+   /* SymbianOS uses this symbol.  */
+   ${RELOCATING+${CREATE_SHLIB-PROVIDE (SHT\$\$INIT_ARRAY\$\$Limit = .);}}
    ${RELOCATING+${CREATE_SHLIB-PROVIDE (__init_array_end = .);}}
  
    ${RELOCATING+${CREATE_SHLIB-PROVIDE (__fini_array_start = .);}}
    .fini_array   ${RELOCATING-0} : { *(.fini_array) }
    ${RELOCATING+${CREATE_SHLIB-PROVIDE (__fini_array_end = .);}}
  
+   ${OTHER_READONLY_SECTIONS}
+   .eh_frame_hdr : { *(.eh_frame_hdr) }
+   .eh_frame     ${RELOCATING-0} : ONLY_IF_RO { KEEP (*(.eh_frame)) }
+   .gcc_except_table ${RELOCATING-0} : ONLY_IF_RO { KEEP (*(.gcc_except_table)) *(.gcc_except_table.*) }
+ 
+   /* Adjust the address for the data segment.  We want to adjust up to
+      the same address within the page on the next page up.  */
+   ${CREATE_SHLIB-${CREATE_PIE-${RELOCATING+. = ${DATA_ADDR};}}}
+   ${CREATE_SHLIB+${RELOCATING+. = ${SHLIB_DATA_ADDR};}}
+   ${CREATE_PIE+${RELOCATING+. = ${SHLIB_DATA_ADDR};}}
+ 
+   /* Exception handling  */
+   .eh_frame     ${RELOCATING-0} : ONLY_IF_RW { KEEP (*(.eh_frame)) }
+   .gcc_except_table ${RELOCATING-0} : ONLY_IF_RW { KEEP (*(.gcc_except_table)) *(.gcc_except_table.*) }
+ 
+   /* Thread Local Storage sections  */
+   .tdata	${RELOCATING-0} : { *(.tdata${RELOCATING+ .tdata.* .gnu.linkonce.td.*}) }
+   .tbss		${RELOCATING-0} : { *(.tbss${RELOCATING+ .tbss.* .gnu.linkonce.tb.*})${RELOCATING+ *(.tcommon)} }
+ 
    ${RELOCATING+${CTOR}}
    ${RELOCATING+${DTOR}}
    .jcr          ${RELOCATING-0} : { KEEP (*(.jcr)) }
  
    ${RELOCATING+${DATARELRO}}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]