This is the mail archive of the binutils@sourceware.org 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]

Re: [RFC] slipping in symbol prefixes automagically via PROVIDE() in linker scripts


On Monday 31 July 2006 06:25, Will Newton wrote:
> Hi Nick,
> > > with the new binutils-2.17, it'd be good to switch to using the
> > > generic elf.sc file ... but this _ prefix is standing in the way
> >
> > Which symbols in the elf.sc need this prefix and do not
> > already have it ?  I looked through the file and it seems
> > that most symbols are provided in an underscore prefixed
> > version and a non-underscore prefixed version.
> >   Or is it that you want to have *double* underscore prefixed
> > versions and single underscore prefixed versions ?  (If so,
> > are the double underscore prefixed versions really necessary ?)
>
> I had a similar problem with an unreleased port I maintain. The symbols
> that were problematic, which is by no means an exhaustive list, were:
>
> __preinit_array_start
> __preinit_array_end
> __init_array_start
> __init_array_end
> __fini_array_start
> __fini_array_end

yep, these were the symbols that are causing problems at the moment ... but i 
was looking to see if there was a more general solution than just fixing 
these references

so in C you would be referencing __init_array_start, but gcc would translate 
that to ___init_array_start, so we need to update the linker script to 
provide ___init_array_start

> >    ${RELOCATING+${END_SYMBOLS-_end = .; PROVIDE (${PREFIX}end = .);}}
> >
> > and in your bfin.sh file define PREFIX as "_".
>
> This looks like a much cleaner way of doing it than copying and editing
> elf.sc as we currently do.

yeah, that looks like great ... how about the attached patch ?  it doesnt seem 
to cause any regressions in the x86_64/i686/blackfin make check ... but i'll 
try running it through some blackfin tests now ...
-mike

Attachment: pgp00000.pgp
Description: PGP signature

2006-07-31  Nick Clifton  <nickc@redhat.com>
	    Mike Frysinger  <michael.frysing@analog.com>

	* scripttempl/elf.sc (USER_LABEL_PREFIX): Define.
	(__preinit_array_start, __preinit_array_end, __init_array_start,
	__init_array_end, __fini_array_start, __fini_array_end, edata, end):
	Use ${USER_LABEL_PREFIX}.
	* emulparams/bfin.sh (DATA_END_SYMBOLS,END_SYMBOLS): Unset.
	(USER_LABEL_PREFIX): Set.

--- scripttempl/elf.sc
+++ scripttempl/elf.sc
@@ -52,6 +52,7 @@
 #		so that .got can be in the RELRO area.  It should be set to
 #		the number of bytes in the beginning of .got.plt which can be
 #		in the RELRO area as well.
+#	USER_LABEL_PREFIX - prefix to add to user-visible symbols.
 #
 # When adding sections, do note that the names of some sections are used
 # when specifying the start address of the next.
@@ -379,23 +380,23 @@ cat <<EOF
 
   .preinit_array   ${RELOCATING-0} :
   {
-    ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (__preinit_array_start = .);}}
+    ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_start = .);}}
     KEEP (*(.preinit_array))
-    ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (__preinit_array_end = .);}}
+    ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__preinit_array_end = .);}}
   }
   .init_array   ${RELOCATING-0} :
   {
-     ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (__init_array_start = .);}}
+     ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_start = .);}}
      KEEP (*(SORT(.init_array.*)))
      KEEP (*(.init_array))
-     ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (__init_array_end = .);}}
+     ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__init_array_end = .);}}
   }
   .fini_array   ${RELOCATING-0} :
   {
-    ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (__fini_array_start = .);}}
+    ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_start = .);}}
     KEEP (*(.fini_array))
     KEEP (*(SORT(.fini_array.*)))
-    ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (__fini_array_end = .);}}
+    ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (${USER_LABEL_PREFIX}__fini_array_end = .);}}
   }
   ${SMALL_DATA_CTOR-${RELOCATING+${CTOR}}}
   ${SMALL_DATA_DTOR-${RELOCATING+${DTOR}}}
@@ -431,7 +432,7 @@ cat <<EOF
   ${SDATA_GOT+${OTHER_GOT_SECTIONS}}
   ${SDATA}
   ${OTHER_SDATA_SECTIONS}
-  ${RELOCATING+${DATA_END_SYMBOLS-_edata = .; PROVIDE (edata = .);}}
+  ${RELOCATING+${DATA_END_SYMBOLS-${USER_LABEL_PREFIX}_edata = .; PROVIDE (${USER_LABEL_PREFIX}edata = .);}}
   ${RELOCATING+__bss_start = .;}
   ${RELOCATING+${OTHER_BSS_SYMBOLS}}
   ${SBSS}
@@ -453,7 +454,7 @@ cat <<EOF
   ${LARGE_SECTIONS}
   ${RELOCATING+. = ALIGN(${ALIGNMENT});}
   ${RELOCATING+${OTHER_END_SYMBOLS}}
-  ${RELOCATING+${END_SYMBOLS-_end = .; PROVIDE (end = .);}}
+  ${RELOCATING+${END_SYMBOLS-${USER_LABEL_PREFIX}_end = .; PROVIDE (${USER_LABEL_PREFIX}end = .);}}
   ${RELOCATING+${DATA_SEGMENT_END}}
 
   /* Stabs debugging sections.  */
--- emulparams/bfin.sh
+++ emulparams/bfin.sh
@@ -10,5 +10,4 @@ ENTRY=__start
 TEMPLATE_NAME=elf32
 GENERATE_SHLIB_SCRIPT=yes
 EMBEDDED=yes
-DATA_END_SYMBOLS="__edata = .; PROVIDE (_edata = .);"
-END_SYMBOLS="__end = .; PROVIDE (_end = .);"
+USER_LABEL_PREFIX=_

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