* [PATCH v2] libgcc/mkmap-symver: support skip_underscore (PR74748)
@ 2016-11-26 9:42 Waldemar Brodkorb
2016-11-28 21:31 ` Jeff Law
0 siblings, 1 reply; 2+ messages in thread
From: Waldemar Brodkorb @ 2016-11-26 9:42 UTC (permalink / raw)
To: gcc-patches; +Cc: Thomas Petazzoni, Jeff Law
Hi,
Some platforms, such as Blackfin, have a special prefix for assembly
symbols as opposed to C symbols. For this reason, a function named
"foo()" in C will in fact be visible as a symbol called "_foo" in the
ELF binary.
The current linker version script logic in libgcc doesn't take into
account this situation properly. The Blackfin specific
libgcc/config/bfin/libgcc-glibc.ver has an additional "_" in front of
every symbol so that it matches the output of "nm" (which gets parsed to
produce the final linker version script). But due to this additional
"_", ld no longer matches with the symbols since "ld" does the matching
with the original symbol name, not the one prefixed with "_".
Due to this, none of the symbols in libgcc/config/bfin/libgcc-glibc.ver
are actually matched with symbols in libgcc. This causes all libgcc
symbols to be left as "LOCAL", which causes lots of "undefined
reference" whenever some C or C++ code that calls a function of libgcc
is compiled.
To address this, this commit introduces a "skip_underscore" variable to
the mkmap-symver script. It tells mkmap-symver to ignore the leading
underscore from the "nm" output.
Note that this new argument is different from the existing
"leading_underscore" argument, which *adds* an additional underscore to
the generated linker version script.
Having this functionality paves the way to using the generic linker
version information for Blackfin, instead of using a custom one.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Tested-by: Waldemar Brodkorb <wbx@openadk.org>
2016-11-26 Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
PR gcc/74748
* libgcc/mkmap-symver.awk: add support for skip_underscore
diff --git a/libgcc/mkmap-symver.awk b/libgcc/mkmap-symver.awk
index 266832a..0a57d31 100644
--- a/libgcc/mkmap-symver.awk
+++ b/libgcc/mkmap-symver.awk
@@ -47,7 +47,11 @@ state == "nm" && ($1 == "U" || $2 == "U") {
state == "nm" && NF == 3 {
split ($3, s, "@")
- def[s[1]] = 1;
+ if (skip_underscore && substr(s[1], 1, 1) == "_")
+ symname = substr(s[1], 2);
+ else
+ symname = s[1];
+ def[symname] = 1;
sawsymbol = 1;
next;
}
Thanks in advance,
Waldemar
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v2] libgcc/mkmap-symver: support skip_underscore (PR74748)
2016-11-26 9:42 [PATCH v2] libgcc/mkmap-symver: support skip_underscore (PR74748) Waldemar Brodkorb
@ 2016-11-28 21:31 ` Jeff Law
0 siblings, 0 replies; 2+ messages in thread
From: Jeff Law @ 2016-11-28 21:31 UTC (permalink / raw)
To: Waldemar Brodkorb, gcc-patches; +Cc: Thomas Petazzoni
On 11/26/2016 02:42 AM, Waldemar Brodkorb wrote:
> Hi,
>
> Some platforms, such as Blackfin, have a special prefix for assembly
> symbols as opposed to C symbols. For this reason, a function named
> "foo()" in C will in fact be visible as a symbol called "_foo" in the
> ELF binary.
>
> The current linker version script logic in libgcc doesn't take into
> account this situation properly. The Blackfin specific
> libgcc/config/bfin/libgcc-glibc.ver has an additional "_" in front of
> every symbol so that it matches the output of "nm" (which gets parsed to
> produce the final linker version script). But due to this additional
> "_", ld no longer matches with the symbols since "ld" does the matching
> with the original symbol name, not the one prefixed with "_".
>
> Due to this, none of the symbols in libgcc/config/bfin/libgcc-glibc.ver
> are actually matched with symbols in libgcc. This causes all libgcc
> symbols to be left as "LOCAL", which causes lots of "undefined
> reference" whenever some C or C++ code that calls a function of libgcc
> is compiled.
>
> To address this, this commit introduces a "skip_underscore" variable to
> the mkmap-symver script. It tells mkmap-symver to ignore the leading
> underscore from the "nm" output.
>
> Note that this new argument is different from the existing
> "leading_underscore" argument, which *adds* an additional underscore to
> the generated linker version script.
>
> Having this functionality paves the way to using the generic linker
> version information for Blackfin, instead of using a custom one.
>
> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
> Tested-by: Waldemar Brodkorb <wbx@openadk.org>
>
> 2016-11-26 Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
>
> PR gcc/74748
> * libgcc/mkmap-symver.awk: add support for skip_underscore
THanks. Installed.
jeff
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-11-28 21:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-26 9:42 [PATCH v2] libgcc/mkmap-symver: support skip_underscore (PR74748) Waldemar Brodkorb
2016-11-28 21:31 ` Jeff Law
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).