* [RFC] slipping in symbol prefixes automagically via PROVIDE() in linker scripts
@ 2006-07-30 19:45 Mike Frysinger
2006-07-31 10:12 ` Nick Clifton
0 siblings, 1 reply; 5+ messages in thread
From: Mike Frysinger @ 2006-07-30 19:45 UTC (permalink / raw)
To: binutils; +Cc: Bernd Schmidt, Jie Zhang
[-- Attachment #1: Type: text/plain, Size: 1112 bytes --]
the blackfin architecture has a symbol prefix of '_' (so in gcc,
__USER_LABEL_PREFIX__ is defined to _) ...
with the old binutils blackfin port (2.15), there is a
binutils/ld/scripttempl/bfin.sc which duplicated a lot of stuff from the
normal elf.sc, so adding the _ prefix to symbols was trivial
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 ... there seems to be two
ways to deal with this at the moment:
- copy elf.sc to bfin.sc again and just insert the _ symbols as needed
- tweak PROVIDE() to automatically insert a configurable prefix
from what i can tell after reading the ld docs, PROVIDE is generally for
setting up automatic symbol values when referenced via higher level code
(like C) ... so making PROVIDE "smarter" and having it insert the same
prefixes that higher level language parsers seems like a good idea to me :)
thoughts ? am i off base with the PROVIDE() tweak ? other solutions ? is
blackfin eternally screwed and forced to maintain a mostly duplicate elf.sc ?
-mike
[-- Attachment #2: Type: application/pgp-signature, Size: 827 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC] slipping in symbol prefixes automagically via PROVIDE() in linker scripts
2006-07-30 19:45 [RFC] slipping in symbol prefixes automagically via PROVIDE() in linker scripts Mike Frysinger
@ 2006-07-31 10:12 ` Nick Clifton
0 siblings, 0 replies; 5+ messages in thread
From: Nick Clifton @ 2006-07-31 10:12 UTC (permalink / raw)
To: Mike Frysinger; +Cc: binutils, Bernd Schmidt, Jie Zhang
Hi Mike,
> 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 ?)
... there seems to be two
> ways to deal with this at the moment:
> - copy elf.sc to bfin.sc again and just insert the _ symbols as needed
> - tweak PROVIDE() to automatically insert a configurable prefix
The cleanest way would be to edit elf.sc so that PROVIDEd symbols had an
optional prefix. eg change:
${RELOCATING+${END_SYMBOLS-_end = .; PROVIDE (end = .);}}
to
${RELOCATING+${END_SYMBOLS-_end = .; PROVIDE (${PREFIX}end = .);}}
and in your bfin.sh file define PREFIX as "_".
> from what i can tell after reading the ld docs, PROVIDE is generally for
> setting up automatic symbol values when referenced via higher level code
> (like C) ... so making PROVIDE "smarter" and having it insert the same
> prefixes that higher level language parsers seems like a good idea to me :)
Changing PROVIDE would be a bad idea in my opinion. It would prevent
linker scripts from being able to define symbols outside of the
namespaces of higher level languages, and this might be needed. (eg for
example for defining symbols used by ROM monitors to handle program
start up).
Cheers
Nick
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC] slipping in symbol prefixes automagically via PROVIDE() in linker scripts
2006-07-31 16:47 ` Mike Frysinger
@ 2006-08-02 9:25 ` Nick Clifton
0 siblings, 0 replies; 5+ messages in thread
From: Nick Clifton @ 2006-08-02 9:25 UTC (permalink / raw)
To: Mike Frysinger; +Cc: Will Newton, binutils, Bernd Schmidt, Jie Zhang
Hi Mike,
> 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 ...
Assuming that the patch works for the blackfin as well then it is
approved for application to the sources.
Cheers
Nick
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC] slipping in symbol prefixes automagically via PROVIDE() in linker scripts
2006-07-31 10:25 Will Newton
@ 2006-07-31 16:47 ` Mike Frysinger
2006-08-02 9:25 ` Nick Clifton
0 siblings, 1 reply; 5+ messages in thread
From: Mike Frysinger @ 2006-07-31 16:47 UTC (permalink / raw)
To: Will Newton; +Cc: Nick Clifton, binutils, Bernd Schmidt, Jie Zhang
[-- Attachment #1.1: Type: text/plain, Size: 1756 bytes --]
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 #1.2: Type: application/pgp-signature, Size: 827 bytes --]
[-- Attachment #2: ld-elf-user-label-prefix.patch --]
[-- Type: text/x-diff, Size: 3265 bytes --]
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=_
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [RFC] slipping in symbol prefixes automagically via PROVIDE() in linker scripts
@ 2006-07-31 10:25 Will Newton
2006-07-31 16:47 ` Mike Frysinger
0 siblings, 1 reply; 5+ messages in thread
From: Will Newton @ 2006-07-31 10:25 UTC (permalink / raw)
To: Nick Clifton, Mike Frysinger; +Cc: binutils, Bernd Schmidt, Jie Zhang
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
> ${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.
******************
This e-mail has been sent from Imagination Technologies Limited.
PowerVR, Metagence, Ensigma and PURE Digital are divisions
of Imagination Technologies Limited.
The information contained in this e-mail, including any attachment,
is confidential and may be legally privileged. It is intended solely
for the addressee(s) and access to this e-mail by anyone else is
unauthorised. If you are not the intended recipient, any disclosure,
copying or distribution or use of the information contained in this
e-mail, is prohibited and may be unlawful. If you have received this
e-mail in error, please notify the sender by return e-mail and then
delete it from your system.
Internet communications cannot be guaranteed to be secure,
error or virus-free. The sender does not accept liability for any errors
or omissions which arise as a result.
Any views expressed in this message are those of the author, except
where the author specifies and, with authority, states them to be the
views of Imagination Technologies Limited.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2006-08-02 9:25 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-07-30 19:45 [RFC] slipping in symbol prefixes automagically via PROVIDE() in linker scripts Mike Frysinger
2006-07-31 10:12 ` Nick Clifton
2006-07-31 10:25 Will Newton
2006-07-31 16:47 ` Mike Frysinger
2006-08-02 9:25 ` Nick Clifton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).